def test_get_actor(self): actor_return_true = { 'desc': 'returns true', 'actor': 'kingpin.actors.test.test_utils.FakeActor', 'options': {'return_value': True}} ret = utils.get_actor(actor_return_true, dry=True) self.assertEquals(True, ret.options['return_value']) self.assertEquals(FakeActor, type(ret))
def test_get_actor(self): actor_return_true = { 'desc': 'returns true', 'actor': 'kingpin.actors.test.test_utils.FakeActor', 'options': { 'return_value': True } } ret = utils.get_actor(actor_return_true, dry=True) self.assertEqual(True, ret._options['return_value']) self.assertEqual(FakeActor, type(ret))
def _build_action_group(self, context=None): """Build up all of the actors we need to execute. Builds a list of actors to execute and returns the list. The list can then either be yielded as a whole (for an async operation), or individually (for a synchronous operation). Returns: A list of references to <actor objects>. """ actions = [] for act in self.option('acts'): act['init_context'] = context actions.append(utils.get_actor(act, dry=self._dry)) return actions
def _build_action_group(self, context=None): """Build up all of the actors we need to execute. Builds a list of actors to execute and returns the list. The list can then either be yielded as a whole (for an async operation), or individually (for a synchronous operation). Returns: A list of references to <actor objects>. """ actions = [] for act in self.option('acts'): act['init_context'] = context self.log.debug('Building actor: %s' % act) actor = utils.get_actor(act, dry=self._dry) actions.append(actor) return actions
def _build_action_group(self, context=None): """Build up all of the actors we need to execute. Builds a list of actors to execute and returns the list. The list can then either be yielded as a whole (for an async operation), or individually (for a synchronous operation). Returns: A list of references to <actor objects>. """ actions = [] self.log.debug('Building %s actors' % len(self.option('acts'))) for act in self.option('acts'): act['init_context'] = context.copy() act['init_tokens'] = self._init_tokens.copy() actor = utils.get_actor(act, dry=self._dry) actions.append(actor) self.log.debug('Actor %s built' % actor) return actions
def __init__(self, *args, **kwargs): """Pre-parse the script file and compile actors. Note, we override the default init_tokens={} from the base class and default it to a _copy_ of the os.environ dict. """ super(Macro, self).__init__(*args, **kwargs) # Temporary check that macro is a local file. self._check_macro() self.log.info('Preparing actors from %s' % self.option('macro')) # Take the "init tokens" that were supplied to this actor by its parent # and merge them with the explicitly defined tokens in the actor # definition itself. Give priority to the explicitly defined tokens on # any conflicts. self._init_tokens.update(self.option('tokens')) # Copy the tmp file / download a remote macro macro_file = self._get_macro() # Parse script, and insert tokens. config = self._get_config_from_script(macro_file) # Check schema for compatibility self._check_schema(config) # Instantiate the first actor, but don't execute it. # Any errors raised by this actor should be attributed to it, and not # this Macro actor. No try/catch here if type(config) == list: # List is a Sync group actor self.initial_actor = group.Sync(options={'acts': config}, dry=self._dry) else: # After the schema has been checked, pass in whatever tokens _we_ # got, off to the soon-to-be-created actor. config['init_tokens'] = self._init_tokens.copy() self.initial_actor = actor_utils.get_actor(config, dry=self._dry)
def __init__(self, *args, **kwargs): """Pre-parse the json file and compile actors.""" super(Macro, self).__init__(*args, **kwargs) # Temporary check that macro is a local file. self._check_macro() self.log.info('Preparing actors from %s' % self.option('macro')) # Copy the tmp file / download a remote macro macro_file = self._get_macro() # Parse json, and insert tokens. config = self._get_config_from_json(macro_file) # Check schema for compatibility self._check_schema(config) # Instantiate the first actor, but don't execute it. # Any errors raised by this actor should be attributed to it, and not # this Macro actor. No try/catch here self.initial_actor = actor_utils.get_actor(config, dry=self._dry)