-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Labels
Description
Hello,
I have been wondering on how to properly disable a Process Group handling all those situations where an inner processor is in a "middle state" (stopping/starting instead of stopped/started).
The code below gets the job done in all the cases except the ones stated above.
Not sure how to recognize those "stopping/starting" situations and consequently handle them (retry, raise etc.).
Any suggestion?
def disable_process_group(pg_id):
"""
Disable a Process Group and all components.
Note: Only stopped processors will be disabled.
Args:
pg_id (str): The UUID of the target Process Group
Returns:
(bool): True of successfully disabled, False if not.
"""
assert isinstance(pg_id, six.string_types)
assert isinstance(
get_process_group(pg_id, 'id'),
nipyapi.nifi.ProcessGroupEntity
)
target_state = 'DISABLED'
body = nipyapi.nifi.ScheduleComponentsEntity(
id=pg_id,
state=target_state
)
with nipyapi.utils.rest_exceptions():
result = nipyapi.nifi.FlowApi().schedule_components(
id=pg_id,
body=body
)
if result.state == target_state:
return True
return False
Thanks.
Reactions are currently unavailable