def _run_action(): executor = exe.get_executor(cfg.CONF.executor.type) return executor.run_action( action, self.action_ex.id if self.action_ex is not None else None, safe_rerun, self._prepare_execution_context(), target=target, timeout=timeout)
def _run_actions(): executor = exe.get_executor(cfg.CONF.executor.type) for action_ex, action_def, target in _get_queue(): executor.run_action(action_ex.id, action_def.action_class, action_def.attributes or {}, action_ex.input, action_ex.runtime_context.get('safe_rerun', False), target=target)
def _run_action(): executor = exe.get_executor(cfg.CONF.executor.type) executor.run_action(self.action_ex.id, self.action_def.action_class, self.action_def.attributes or {}, self.action_ex.input, self.action_ex.runtime_context.get( 'safe_rerun', False), execution_context, target=target, timeout=timeout)
def _run_action(): executor = exe.get_executor(cfg.CONF.executor.type) executor.run_action( self.action_ex.id, self.action_def.action_class, self.action_def.attributes or {}, self.action_ex.input, self.action_ex.runtime_context.get('safe_rerun', False), execution_context, target=target, timeout=timeout )
def run(self, input_dict, target, index=0, desc='', save=True, safe_rerun=False, timeout=None): assert not self.action_ex self.validate_input(input_dict) prepared_input_dict = self._prepare_input(input_dict) # Assign the action execution ID here to minimize database calls. # Otherwise, the input property of the action execution DB object needs # to be updated with the action execution ID after the action execution # DB object is created. action_ex_id = utils.generate_unicode_uuid() if save: self._create_action_execution(prepared_input_dict, self._prepare_runtime_context( index, safe_rerun), self.is_sync(input_dict), desc=desc, action_ex_id=action_ex_id) executor = exe.get_executor(cfg.CONF.executor.type) execution_context = self._prepare_execution_context() result = executor.run_action( self.action_ex.id if self.action_ex else None, self.action_def.action_class, self.action_def.attributes or {}, prepared_input_dict, safe_rerun, execution_context, target=target, async_=False, timeout=timeout) return self._prepare_output(result)
def run(self, input_dict, target, index=0, desc='', save=True, safe_rerun=False, timeout=None): assert not self.action_ex self.action_desc.check_parameters(input_dict) try: action = self.action_desc.instantiate(input_dict, {}) except Exception: raise exc.InvalidActionException( 'Failed to instantiate an action' ' [action_desc=%s, input_dict=%s]' % (self.action_desc, input_dict)) # Assign the action execution ID here to minimize database calls. # Otherwise, the input property of the action execution DB object needs # to be updated with the action execution ID after the action execution # DB object is created. action_ex_id = utils.generate_unicode_uuid() if save: self._create_action_execution(input_dict, self._prepare_runtime_context( index, safe_rerun), desc=desc, action_ex_id=action_ex_id, is_sync=action.is_sync()) executor = exe.get_executor(cfg.CONF.executor.type) return executor.run_action( action, self.action_ex.id if self.action_ex is not None else None, safe_rerun, self._prepare_execution_context(), target=target, async_=False, timeout=timeout)
def _process_queue(queue): executor = exe.get_executor(cfg.CONF.executor.type) for operation, args in queue: if operation == _RUN_ACTION: action_ex, action_def, target = args executor.run_action(action_ex.id, action_def.action_class, action_def.attributes or {}, action_ex.input, action_ex.runtime_context.get( 'safe_rerun', False), target=target) elif operation == _ON_ACTION_COMPLETE: action_ex_id, result, wf_action = args rpc.get_engine_client().on_action_complete(action_ex_id, result, wf_action)
def run(self, input_dict, target, index=0, desc='', save=True, safe_rerun=False, timeout=None): assert not self.action_ex self.validate_input(input_dict) prepared_input_dict = self._prepare_input(input_dict) # Assign the action execution ID here to minimize database calls. # Otherwise, the input property of the action execution DB object needs # to be updated with the action execution ID after the action execution # DB object is created. action_ex_id = utils.generate_unicode_uuid() if save: self._create_action_execution( prepared_input_dict, self._prepare_runtime_context(index, safe_rerun), self.is_sync(input_dict), desc=desc, action_ex_id=action_ex_id ) executor = exe.get_executor(cfg.CONF.executor.type) execution_context = self._prepare_execution_context() result = executor.run_action( self.action_ex.id if self.action_ex else None, self.action_def.action_class, self.action_def.attributes or {}, prepared_input_dict, safe_rerun, execution_context, target=target, async_=False, timeout=timeout ) return self._prepare_output(result)
def test_get_remote_executor(self): executor = exe.get_executor('remote') self.assertIsInstance(executor, r.RemoteExecutor)
def test_get_local_executor(self): executor = exe.get_executor('local') self.assertIsInstance(executor, d.DefaultExecutor)
def setUp(self): super(EngineTestCase, self).setUp() # We assume that most tests don't need a remote executor. # But this option can be overridden on a test level, if needed, # because an executor instance (local or a client to a remote one) # is obtained by engine dynamically on every need. self.override_config('type', 'local', 'executor') # Get transport here to let oslo.messaging setup default config # before changing the rpc_backend to the fake driver; otherwise, # oslo.messaging will throw exception. messaging.get_transport(cfg.CONF) # Set the transport to 'fake' for Engine tests. cfg.CONF.set_default('transport_url', 'fake:/') # Drop all RPC objects (transport, clients). rpc_base.cleanup() rpc_clients.cleanup() exe.cleanup() self.threads = [] # Start remote executor. if cfg.CONF.executor.type == 'remote': LOG.info("Starting remote executor threads...") self.executor_client = rpc_clients.get_executor_client() exe_svc = executor_server.get_oslo_service(setup_profiler=False) self.executor = exe_svc.executor self.threads.append(eventlet.spawn(launch_service, exe_svc)) self.addCleanup(exe_svc.stop, True) else: self.executor = exe.get_executor(cfg.CONF.executor.type) # Start remote notifier. if cfg.CONF.notifier.type == 'remote': LOG.info("Starting remote notifier threads...") self.notifier_client = rpc_clients.get_notifier_client() notif_svc = notif_server.get_oslo_service(setup_profiler=False) self.notifier = notif_svc.notifier self.threads.append(eventlet.spawn(launch_service, notif_svc)) self.addCleanup(notif_svc.stop, True) # Start engine. LOG.info("Starting engine threads...") self.engine_client = rpc_clients.get_engine_client() eng_svc = engine_server.get_oslo_service(setup_profiler=False) self.engine = eng_svc.engine self.threads.append(eventlet.spawn(launch_service, eng_svc)) self.addCleanup(eng_svc.stop, True) self.addOnException(self.print_executions) self.addCleanup(self.kill_threads) # This call ensures that all plugged in action providers are # properly initialized. action_service.get_system_action_provider() # Make sure that both services fully started, otherwise # the test may run too early. if cfg.CONF.executor.type == 'remote': exe_svc.wait_started() if cfg.CONF.notifier.type == 'remote': notif_svc.wait_started() eng_svc.wait_started()