Open
Description
We use nipyapi to enable controller services instead of clicking them in the UI, and very often one controller service depends on the other controller service(s), which means some controller services must be enabled before the other controller services.
One function I implement
def enable_controller_services_recur(controller_services):
if not controller_services:
return
else:
invalid_services = []
for service in controller_services:
if service.component.validation_status == 'VALID':
nipyapi.canvas.schedule_controller(service, True)
else:
invalid_service = nipyapi.canvas.get_controller(identifier=service.id, identifier_type="id")
invalid_services.append(invalid_service)
enable_controller_services_recur(invalid_services)
and the input parameter I use is the processor group
controller_services = nipyapi.nifi.FlowApi().get_controller_services_from_group(pg.id,
include_descendant_groups=True)\
.controller_services
I could send a merge request with a more generic function as the following if the maintainer think it's useful.
Proposal
I would put this function in canvas.py
closed to the function schedule_controller(controller, scheduled)
, and make it behave like
def schedule_controllers(controllers, scheduled):
"""
Start/Enable or Stop/Disable Controller Services with existing dependencies
Args:
controllers list(ControllerServiceEntity): Target Controllers to schedule
scheduled (bool): True to start, False to stop
Returns:
list(ControllerServiceEntity)
""