def __init__(self, msg, package, **kwargs): """Constructor. :param msg: task message :type msg: str :param package: package reference :type package: object :param kwargs: additional keyword arguments :type kwargs: dict """ super(OrchestrateTask, self).__init__(**kwargs) self.msg = msg # create the orchestrator object self.orchestrator = ActionOrchestrator(package)
def _get_orchestrator_instance(self): """Get the orchestrator instance to perform clean up actions with. :return: orchestrator class instance :rtype: object """ # set package attributes to get actual asset objects over strings cleanup = getattr(self.package, 'cleanup') setattr(cleanup, 'all_hosts', getattr(self.package, 'all_hosts')) setattr(cleanup, 'hosts', getattr(self.package, 'hosts')) # create the orchestrator plugin object return ActionOrchestrator(cleanup)
class OrchestrateTask(TefloTask): """Orchestrate task.""" __task_name__ = 'orchestrate' __concurrent__ = False def __init__(self, msg, package, **kwargs): """Constructor. :param msg: task message :type msg: str :param package: package reference :type package: object :param kwargs: additional keyword arguments :type kwargs: dict """ super(OrchestrateTask, self).__init__(**kwargs) self.msg = msg # create the orchestrator object self.orchestrator = ActionOrchestrator(package) def run(self): """Run. This method is the main entry point to the task. """ self.logger.info(self.msg) try: # run the configuration with the given orchestrator self.orchestrator.run() except Exception as ex: self.logger.error('Failed to run orchestration %s ' % self.name) stackmsg = self.get_formatted_traceback() self.logger.error(ex) self.logger.error(stackmsg) raise