示例#1
0
 def _construct_instances(self, persona):
     """
     Create component objects for each component in the persona.
     """
     persona_subsystems = persona.wanted_subsystems or {}
     persona_opts = persona.component_options or {}
     instances = {}
     sibling_instances = {}
     for c in persona.wanted_components:
         ((cls, distro_opts),
          siblings) = self.distro.extract_component(c, self.lookup_name)
         LOG.debug("Constructing component %r (%s)", c, tu.obj_name(cls))
         instance_params = {}
         instance_params['name'] = c
         # First create its siblings with a 'minimal' set of options
         # This is done, so that they will work in a minimal state, they do not
         # get access to the persona options since those are action specific (or could be),
         # if this is not useful, we can give them full access, unsure if its worse or better...
         instance_params['subsystems'] = {}
         instance_params['siblings'] = {}
         instance_params['passwords'] = self.passwords
         instance_params['distro'] = self.distro
         instance_params['options'] = self._merge_options(
             c, self._get_interp_options(c), distro_opts, {})
         LOG.debug("Constructing %r siblings...", c)
         siblings = self._construct_siblings(c, siblings, instance_params,
                                             sibling_instances)
         # Now inject the full options
         instance_params['instances'] = instances
         instance_params['options'] = self._merge_options(
             c, self._get_interp_options(c), distro_opts,
             (persona_opts.get(c) or {}))
         instance_params['subsystems'] = self._merge_subsystems(
             (distro_opts.pop('subsystems', None) or {}),
             (persona_subsystems.get(c) or {}))
         instance_params['siblings'] = siblings
         instance_params = utils.merge_dicts(instance_params,
                                             self.cli_opts,
                                             preserve=True)
         LOG.debug("Construction of %r params are:", c)
         utils.log_object(instance_params, logger=LOG, level=logging.DEBUG)
         instances[c] = cls(**instance_params)
     return instances
示例#2
0
 def __str__(self):
     return "%s@%s" % (tu.obj_name(self), self.name)