-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add get_resource_status rule and use it in older rules [DHDO-1371]
- Loading branch information
1 parent
659a891
commit 487ada5
Showing
4 changed files
with
28 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
"""This sub-package contains the rules related to DataHub resources (ingest & destination)""" | ||
# Public rules | ||
from datahubirodsruleset.resources.get_resource_size_for_all_collections import get_resource_size_for_all_collections | ||
from datahubirodsruleset.resources.get_resource_status import get_resource_status | ||
|
||
# Private rules | ||
from datahubirodsruleset.resources.get_direct_ingest_resource_host import get_direct_ingest_resource_host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# /rules/tests/run_test.sh -r get_resource_status -a "replRescUM01" -j | ||
from genquery import row_iterator, AS_LIST # pylint: disable=import-error | ||
|
||
from datahubirodsruleset.decorator import make, Output | ||
|
||
|
||
@make(inputs=[0], outputs=[1], handler=Output.STORE) | ||
def get_resource_status(ctx, resource_name): | ||
""" | ||
Queries the resources to get the resource host of the resc that has the directIngestResc AVU | ||
Returns | ||
------- | ||
str: | ||
The direct ingest resource host | ||
""" | ||
for result in row_iterator( | ||
"RESC_STATUS", | ||
"RESC_NAME = '{}'".format(resource_name), | ||
AS_LIST, | ||
ctx.callback, | ||
): | ||
return result[0] |