Beispiel #1
0
 def _config_adjust_root(self, contents, fn):
     params = khelper.get_shared_params(**utils.merge_dicts(
         self.options, khelper.get_shared_passwords(self)))
     with io.BytesIO(contents) as stream:
         config = cfg.create_parser(cfg.RewritableConfigParser, self)
         config.readfp(stream)
         config.set('DEFAULT', 'admin_token', params['service_token'])
         config.set('DEFAULT', 'admin_port',
                    params['endpoints']['admin']['port'])
         config.set('DEFAULT', 'public_port',
                    params['endpoints']['public']['port'])
         config.set('DEFAULT', 'verbose', True)
         config.set('DEFAULT', 'debug', True)
         if self.get_bool_option('enable-pki'):
             config.set('signing', 'token_format', 'PKI')
             for (k, v) in PKI_FILES.items():
                 path = sh.joinpths(self.link_dir, v)
                 config.set('signing', k, path)
         else:
             config.set('signing', 'token_format', 'UUID')
         config.set('catalog', 'driver',
                    'keystone.catalog.backends.sql.Catalog')
         config.remove_option('DEFAULT', 'log_config')
         config.set(
             'sql', 'connection',
             dbhelper.fetch_dbdsn(dbname=DB_NAME,
                                  utf8=True,
                                  dbtype=self.get_option('db', 'type'),
                                  **utils.merge_dicts(
                                      self.get_option('db'),
                                      dbhelper.get_shared_passwords(self))))
         config.set('ec2', 'driver',
                    "keystone.contrib.ec2.backends.sql.Ec2")
         contents = config.stringify(fn)
     return contents
Beispiel #2
0
 def _config_adjust_root(self, contents, fn):
     params = khelper.get_shared_params(**utils.merge_dicts(self.options, khelper.get_shared_passwords(self)))
     with io.BytesIO(contents) as stream:
         config = cfg.create_parser(cfg.RewritableConfigParser, self)
         config.readfp(stream)
         config.set("DEFAULT", "admin_token", params["service_token"])
         config.set("DEFAULT", "admin_port", params["endpoints"]["admin"]["port"])
         config.set("DEFAULT", "public_port", params["endpoints"]["public"]["port"])
         config.set("DEFAULT", "verbose", True)
         config.set("DEFAULT", "debug", True)
         config.set("catalog", "driver", "keystone.catalog.backends.sql.Catalog")
         config.remove_option("DEFAULT", "log_config")
         config.set(
             "sql",
             "connection",
             dbhelper.fetch_dbdsn(
                 dbname=DB_NAME,
                 utf8=True,
                 dbtype=self.get_option("db", "type"),
                 **utils.merge_dicts(self.get_option("db"), dbhelper.get_shared_passwords(self))
             ),
         )
         config.set("ec2", "driver", "keystone.contrib.ec2.backends.sql.Ec2")
         contents = config.stringify(fn)
     return contents
 def _config_adjust_root(self, contents, fn):
     params = khelper.get_shared_params(**utils.merge_dicts(self.options,
                                                            khelper.get_shared_passwords(self)))
     with io.BytesIO(contents) as stream:
         config = cfg.create_parser(cfg.RewritableConfigParser, self)
         config.readfp(stream)
         config.set('DEFAULT', 'admin_token', params['service_token'])
         config.set('DEFAULT', 'admin_port', params['endpoints']['admin']['port'])
         config.set('DEFAULT', 'public_port', params['endpoints']['public']['port'])
         config.set('DEFAULT', 'verbose', True)
         config.set('DEFAULT', 'debug', True)
         if self.get_bool_option('enable-pki'):
             config.set('signing', 'token_format', 'PKI')
             for (k, v) in PKI_FILES.items():
                 path = sh.joinpths(self.link_dir, v)
                 config.set('signing', k, path)
         else:
             config.set('signing', 'token_format', 'UUID')
         config.set('catalog', 'driver', 'keystone.catalog.backends.sql.Catalog')
         config.remove_option('DEFAULT', 'log_config')
         config.set('sql', 'connection', dbhelper.fetch_dbdsn(dbname=DB_NAME,
                                                              utf8=True,
                                                              dbtype=self.get_option('db', 'type'),
                                                              **utils.merge_dicts(self.get_option('db'),
                                                                                  dbhelper.get_shared_passwords(self))))
         config.set('ec2', 'driver', "keystone.contrib.ec2.backends.sql.Ec2")
         contents = config.stringify(fn)
     return contents
Beispiel #4
0
 def _setup_db(self):
     dbhelper.drop_db(distro=self.distro,
                      dbtype=self.get_option('db', 'type'),
                      dbname=DB_NAME,
                      **utils.merge_dicts(self.get_option('db'),
                                          dbhelper.get_shared_passwords(self)))
     dbhelper.create_db(distro=self.distro,
                        dbtype=self.get_option('db', 'type'),
                        dbname=DB_NAME,
                        **utils.merge_dicts(self.get_option('db'),
                                            dbhelper.get_shared_passwords(self)))
Beispiel #5
0
 def _setup_db(self):
     dbhelper.drop_db(distro=self.distro,
                      dbtype=self.get_option('db', 'type'),
                      dbname=DB_NAME,
                      **utils.merge_dicts(self.get_option('db'),
                                          dbhelper.get_shared_passwords(self)))
     dbhelper.create_db(distro=self.distro,
                        dbtype=self.get_option('db', 'type'),
                        dbname=DB_NAME,
                        **utils.merge_dicts(self.get_option('db'),
                                            dbhelper.get_shared_passwords(self)))
Beispiel #6
0
 def setup_db(self):
     dbhelper.drop_db(
         distro=self.installer.distro,
         dbtype=self.installer.get_option("db", "type"),
         dbname=self.DB_NAME,
         **utils.merge_dicts(self.installer.get_option("db"), dbhelper.get_shared_passwords(self.installer))
     )
     dbhelper.create_db(
         distro=self.installer.distro,
         dbtype=self.installer.get_option("db", "type"),
         dbname=self.DB_NAME,
         **utils.merge_dicts(self.installer.get_option("db"), dbhelper.get_shared_passwords(self.installer))
     )
Beispiel #7
0
 def _setup_db(self):
     dbhelper.drop_db(distro=self.distro,
                      dbtype=self.get_option('db', 'type'),
                      dbname=DB_NAME,
                      **utils.merge_dicts(self.get_option('db'),
                                          dbhelper.get_shared_passwords(self)))
     # Explicitly use latin1: to avoid lp#829209, nova expects the database to
     # use latin1 by default, and then upgrades the database to utf8 (see the
     # 082_essex.py in nova)
     dbhelper.create_db(distro=self.distro,
                        dbtype=self.get_option('db', 'type'),
                        dbname=DB_NAME,
                        charset='latin1',
                        **utils.merge_dicts(self.get_option('db'),
                                            dbhelper.get_shared_passwords(self)))
Beispiel #8
0
 def _config_adjust_api_reg(self, contents, fn):
     gparams = ghelper.get_shared_params(**self.options)
     with io.BytesIO(contents) as stream:
         config = cfg.create_parser(cfg.RewritableConfigParser, self)
         config.readfp(stream)
         config.set('DEFAULT', 'debug', self.get_bool_option('verbose'))
         config.set('DEFAULT', 'verbose', self.get_bool_option('verbose'))
         if fn in [REG_CONF]:
             config.set('DEFAULT', 'bind_port', gparams['endpoints']['registry']['port'])
         else:
             config.set('DEFAULT', 'bind_port', gparams['endpoints']['public']['port'])
         config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME,
                                                                      utf8=True,
                                                                      dbtype=self.get_option('db', 'type'),
                                                                      **utils.merge_dicts(self.get_option('db'),
                                                                                          dbhelper.get_shared_passwords(self))))
         config.remove_option('DEFAULT', 'log_file')
         config.set('paste_deploy', 'flavor', self.get_option('paste_flavor'))
         for (k, v) in self._fetch_keystone_params().items():
             config.set('keystone_authtoken', k, v)
         if fn in [API_CONF]:
             config.set('DEFAULT', 'default_store', 'file')
             img_store_dir = sh.joinpths(self.get_option('component_dir'), 'images')
             config.set('DEFAULT', 'filesystem_store_datadir', img_store_dir)
             LOG.debug("Ensuring file system store directory %r exists and is empty." % (img_store_dir))
             if sh.isdir(img_store_dir):
                 sh.deldir(img_store_dir)
             sh.mkdirslist(img_store_dir, tracewriter=self.tracewriter, adjust_suids=True)
         return config.stringify(fn)
Beispiel #9
0
 def _construct_siblings(self, name, siblings, base_params,
                         sibling_instances):
     # First setup the sibling instance action references
     for (action, _entry_point) in siblings.items():
         if action not in sibling_instances:
             sibling_instances[action] = {}
     there_siblings = {}
     for (action, entry_point) in siblings.items():
         sibling_params = utils.merge_dicts(base_params,
                                            self.cli_opts,
                                            preserve=True)
         # Give the sibling the reference to all other siblings being created
         # which will be populated when they are created (now or later) for
         # the same action
         sibling_params['instances'] = sibling_instances[action]
         a_sibling = importer.construct_entry_point(entry_point,
                                                    **sibling_params)
         # Update the sibling we are returning and the corresponding
         # siblings for that action (so that the sibling can have the
         # correct 'sibling' instances associated with it, if it needs those...)
         there_siblings[action] = a_sibling
         # Update all siblings being constructed so that there siblings will
         # be correct when fetched...
         sibling_instances[action][name] = a_sibling
     return there_siblings
Beispiel #10
0
 def post_start(self):
     if not sh.isfile(self.init_fn) and self.get_bool_option('do-init'):
         self.wait_active()
         LOG.info("Running commands to initialize keystone.")
         (fn, contents) = utils.load_template(self.name, INIT_WHAT_FN)
         LOG.debug("Initializing with contents of %s", fn)
         params = {}
         params['keystone'] = khelper.get_shared_params(**utils.merge_dicts(self.options, khelper.get_shared_passwords(self)))
         params['glance'] = ghelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('glance'))
         params['nova'] = nhelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('nova'))
         params['quantum'] = qhelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('quantum'))
         params['cinder'] = chelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('cinder'))
         wait_urls = [
             params['keystone']['endpoints']['admin']['uri'],
             params['keystone']['endpoints']['public']['uri'],
         ]
         for url in wait_urls:
             utils.wait_for_url(url)
         init_what = utils.load_yaml_text(contents)
         init_what = utils.expand_template_deep(self._filter_init(init_what), params)
         khelper.Initializer(params['keystone']['service_token'],
                             params['keystone']['endpoints']['admin']['uri']).initialize(**init_what)
         # Writing this makes sure that we don't init again
         sh.write_file(self.init_fn, utils.prettify_yaml(init_what))
         LOG.info("If you wish to re-run initialization, delete %s", colorizer.quote(self.init_fn))
Beispiel #11
0
    def load(self, distro, component, persona=None, origins_patch=None):
        # NOTE (vnovikov): applying takes place before loading reference links
        self._apply_persona(component, persona)

        dir_opts = self._get_dir_opts(component)
        distro_opts = distro.options
        origins_opts = {}
        if self._origins_path:
            try:
                origins = _origins.load(self._origins_path,
                                        patch_file=origins_patch)
                origins_opts = origins[component]
            except KeyError:
                pass
        general_component_opts = self._base_loader.load('general')
        component_specific_opts = self._base_loader.load(component)

        # NOTE (vnovikov): merge order is the same as arguments order below.
        merged_opts = utils.merge_dicts(
            dir_opts,
            distro_opts,
            origins_opts,
            general_component_opts,
            component_specific_opts,
        )
        return merged_opts
Beispiel #12
0
    def load(self, distro, component, persona=None, origins_patch=None):
        # NOTE (vnovikov): applying takes place before loading reference links
        self._apply_persona(component, persona)

        dir_opts = self._get_dir_opts(component)
        distro_opts = distro.options
        origins_opts = {}
        if self._origins_path:
            try:
                origins = _origins.load(self._origins_path,
                                        patch_file=origins_patch)
                origins_opts = origins[component]
            except KeyError:
                pass

        component_opts = []
        for conf in ('general', component):
            try:
                component_opts.append(self._base_loader.load(conf))
            except exceptions.YamlConfigNotFoundException:
                LOG.warn("Unable to find component specific configuration"
                         " for component '%s'", conf, exc_info=True)

        # NOTE (vnovikov): merge order is the same as arguments order below.
        merged_opts = utils.merge_dicts(
            dir_opts,
            distro_opts,
            origins_opts,
            *component_opts
        )
        return merged_opts
Beispiel #13
0
 def fetch_dbdsn(self):
     return dbhelper.fetch_dbdsn(
         dbname=self.DB_NAME,
         utf8=True,
         dbtype=self.installer.get_option('db', 'type'),
         **utils.merge_dicts(self.installer.get_option('db'),
                             dbhelper.get_shared_passwords(self.installer)))
Beispiel #14
0
    def _config_adjust_paste(self, contents, fn):
        params = khelper.get_shared_params(
            ip=self.get_option('ip'),
            service_user='******',
            **utils.merge_dicts(self.get_option('keystone'),
                                khelper.get_shared_passwords(self)))

        with io.BytesIO(contents) as stream:
            config = cfg.create_parser(cfg.RewritableConfigParser, self)
            config.readfp(stream)

            config.set('filter:authtoken', 'auth_host',
                       params['endpoints']['admin']['host'])
            config.set('filter:authtoken', 'auth_port',
                       params['endpoints']['admin']['port'])
            config.set('filter:authtoken', 'auth_protocol',
                       params['endpoints']['admin']['protocol'])

            config.set('filter:authtoken', 'service_host',
                       params['endpoints']['internal']['host'])
            config.set('filter:authtoken', 'service_port',
                       params['endpoints']['internal']['port'])
            config.set('filter:authtoken', 'service_protocol',
                       params['endpoints']['internal']['protocol'])

            config.set('filter:authtoken', 'admin_tenant_name',
                       params['service_tenant'])
            config.set('filter:authtoken', 'admin_user',
                       params['service_user'])
            config.set('filter:authtoken', 'admin_password',
                       params['service_password'])

            contents = config.stringify(fn)
        return contents
Beispiel #15
0
 def _config_adjust_api_reg(self, contents, fn):
     gparams = ghelper.get_shared_params(**self.options)
     with io.BytesIO(contents) as stream:
         config = cfg.create_parser(cfg.RewritableConfigParser, self)
         config.readfp(stream)
         config.set('DEFAULT', 'debug', self.get_bool_option('verbose'))
         config.set('DEFAULT', 'verbose', self.get_bool_option('verbose'))
         if fn in [REG_CONF]:
             config.set('DEFAULT', 'bind_port', gparams['endpoints']['registry']['port'])
         else:
             config.set('DEFAULT', 'bind_port', gparams['endpoints']['public']['port'])
         config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME,
                                                                      utf8=True,
                                                                      dbtype=self.get_option('db', 'type'),
                                                                      **utils.merge_dicts(self.get_option('db'),
                                                                                          dbhelper.get_shared_passwords(self))))
         config.remove_option('DEFAULT', 'log_file')
         config.set('paste_deploy', 'flavor', self.get_option('paste_flavor'))
         for (k, v) in self._fetch_keystone_params().items():
             config.set('keystone_authtoken', k, v)
         if fn in [API_CONF]:
             config.set('DEFAULT', 'default_store', 'file')
             img_store_dir = sh.joinpths(self.get_option('component_dir'), 'images')
             config.set('DEFAULT', 'filesystem_store_datadir', img_store_dir)
             LOG.debug("Ensuring file system store directory %r exists and is empty." % (img_store_dir))
             if sh.isdir(img_store_dir):
                 sh.deldir(img_store_dir)
             sh.mkdirslist(img_store_dir, tracewriter=self.tracewriter, adjust_suids=True)
         return config.stringify(fn)
Beispiel #16
0
 def post_start(self):
     if not sh.isfile(self.init_fn) and self.get_bool_option("do-init"):
         self.wait_active()
         LOG.info("Running commands to initialize keystone.")
         (fn, contents) = utils.load_template(self.name, INIT_WHAT_FN)
         LOG.debug("Initializing with contents of %s", fn)
         params = {}
         params["keystone"] = khelper.get_shared_params(
             **utils.merge_dicts(self.options, khelper.get_shared_passwords(self))
         )
         params["glance"] = ghelper.get_shared_params(ip=self.get_option("ip"), **self.get_option("glance"))
         params["nova"] = nhelper.get_shared_params(ip=self.get_option("ip"), **self.get_option("nova"))
         wait_urls = [
             params["keystone"]["endpoints"]["admin"]["uri"],
             params["keystone"]["endpoints"]["public"]["uri"],
         ]
         for url in wait_urls:
             utils.wait_for_url(url)
         init_what = utils.load_yaml_text(contents)
         init_what = utils.expand_template_deep(self._filter_init(init_what), params)
         khelper.Initializer(
             params["keystone"]["service_token"], params["keystone"]["endpoints"]["admin"]["uri"]
         ).initialize(**init_what)
         # Writing this makes sure that we don't init again
         sh.write_file(self.init_fn, utils.prettify_yaml(init_what))
         LOG.info("If you wish to re-run initialization, delete %s", colorizer.quote(self.init_fn))
Beispiel #17
0
 def post_start(self):
     if not sh.isfile(self.init_fn) and self.get_bool_option('do-init'):
         self.wait_active()
         LOG.info("Running commands to initialize keystone.")
         (fn, contents) = utils.load_template(self.name, INIT_WHAT_FN)
         LOG.debug("Initializing with contents of %s", fn)
         params = {}
         params['keystone'] = khelper.get_shared_params(**utils.merge_dicts(self.options, khelper.get_shared_passwords(self)))
         params['glance'] = ghelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('glance'))
         params['nova'] = nhelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('nova'))
         params['neutron'] = net_helper.get_shared_params(ip=self.get_option('ip'), **self.get_option('neutron'))
         params['cinder'] = chelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('cinder'))
         wait_urls = [
             params['keystone']['endpoints']['admin']['uri'],
             params['keystone']['endpoints']['public']['uri'],
         ]
         for url in wait_urls:
             utils.wait_for_url(url)
         init_what = utils.load_yaml_text(contents)
         init_what = utils.expand_template_deep(init_what, params)
         try:
             init_how = khelper.Initializer(params['keystone']['service_token'],
                                            params['keystone']['endpoints']['admin']['uri'])
             init_how.initialize(**init_what)
         except RuntimeError:
             LOG.exception("Failed to initialize keystone, is the keystone client library available?")
         else:
             # Writing this makes sure that we don't init again
             sh.write_file(self.init_fn, utils.prettify_yaml(init_what))
             LOG.info("If you wish to re-run initialization, delete %s", colorizer.quote(self.init_fn))
Beispiel #18
0
    def _config_adjust_paste(self, contents, fn):
        params = khelper.get_shared_params(
            ip=self.get_option("ip"),
            service_user="******",
            **utils.merge_dicts(self.get_option("keystone"), khelper.get_shared_passwords(self))
        )

        with io.BytesIO(contents) as stream:
            config = cfg.create_parser(cfg.RewritableConfigParser, self)
            config.readfp(stream)

            config.set("filter:authtoken", "auth_host", params["endpoints"]["admin"]["host"])
            config.set("filter:authtoken", "auth_port", params["endpoints"]["admin"]["port"])
            config.set("filter:authtoken", "auth_protocol", params["endpoints"]["admin"]["protocol"])

            config.set("filter:authtoken", "service_host", params["endpoints"]["internal"]["host"])
            config.set("filter:authtoken", "service_port", params["endpoints"]["internal"]["port"])
            config.set("filter:authtoken", "service_protocol", params["endpoints"]["internal"]["protocol"])

            config.set("filter:authtoken", "admin_tenant_name", params["service_tenant"])
            config.set("filter:authtoken", "admin_user", params["service_user"])
            config.set("filter:authtoken", "admin_password", params["service_password"])

            contents = config.stringify(fn)
        return contents
Beispiel #19
0
 def fetch_dbdsn(self):
     return dbhelper.fetch_dbdsn(
         dbname=self.DB_NAME,
         utf8=True,
         dbtype=self.installer.get_option('db', 'type'),
         **utils.merge_dicts(self.installer.get_option('db'),
                             dbhelper.get_shared_passwords(self.installer)))
Beispiel #20
0
 def _config_adjust_api(self, contents, fn):
     params = ghelper.get_shared_params(**self.options)
     with io.BytesIO(contents) as stream:
         config = cfg.create_parser(cfg.RewritableConfigParser, self)
         config.readfp(stream)
         img_store_dir = sh.joinpths(self.get_option('component_dir'),
                                     'images')
         config.set('DEFAULT', 'debug', self.get_bool_option('verbose', ))
         config.set('DEFAULT', 'verbose', self.get_bool_option('verbose'))
         config.set('DEFAULT', 'default_store', 'file')
         config.set('DEFAULT', 'filesystem_store_datadir', img_store_dir)
         config.set('DEFAULT', 'bind_port',
                    params['endpoints']['public']['port'])
         config.set(
             'DEFAULT', 'sql_connection',
             dbhelper.fetch_dbdsn(dbname=DB_NAME,
                                  utf8=True,
                                  dbtype=self.get_option('db', 'type'),
                                  **utils.merge_dicts(
                                      self.get_option('db'),
                                      dbhelper.get_shared_passwords(self))))
         config.remove_option('DEFAULT', 'log_file')
         config.set('paste_deploy', 'flavor',
                    self.get_option('paste_flavor'))
         LOG.debug(
             "Ensuring file system store directory %r exists and is empty."
             % (img_store_dir))
         sh.deldir(img_store_dir)
         self.tracewriter.dirs_made(*sh.mkdirslist(img_store_dir))
         return config.stringify(fn)
Beispiel #21
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 {}
     wanted_components = persona.wanted_components or []
     # All siblings for the current persona
     instances = {}
     # Keeps track of all sibling instances across all components + actions
     # so that each instance or sibling instance will be connected to the
     # right set of siblings....
     sibling_instances = {}
     for c in wanted_components:
         d_component = self.distro.extract_component(c, self.lookup_name)
         LOG.debug("Constructing component %r (%s)", c,
                   d_component.entry_point)
         d_subsystems = d_component.options.pop('subsystems', {})
         sibling_params = {}
         sibling_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...
         active_subsystems = self._merge_subsystems(
             distro_subsystems=d_subsystems,
             desired_subsystems=persona_subsystems.get(c, []))
         sibling_params['subsystems'] = active_subsystems
         sibling_params['siblings'] = {
         }  # This gets adjusted during construction
         sibling_params['passwords'] = self.passwords
         sibling_params['distro'] = self.distro
         sibling_params['options'] = self._merge_options(
             c,
             component_opts=self._get_interpolated_options(c),
             distro_opts=d_component.options,
             persona_opts={})
         LOG.debug("Constructing %r %s siblings...", c,
                   len(d_component.siblings))
         my_siblings = self._construct_siblings(c, d_component.siblings,
                                                sibling_params,
                                                sibling_instances)
         # Now inject the full options and create the target instance
         # with the full set of options and not the restricted set that
         # siblings get...
         instance_params = dict(sibling_params)
         instance_params['instances'] = instances
         instance_params['options'] = self._merge_options(
             c,
             component_opts=self._get_interpolated_options(c),
             distro_opts=d_component.options,
             persona_opts=persona_opts.get(c, {}))
         instance_params['siblings'] = my_siblings
         instance_params = utils.merge_dicts(instance_params,
                                             self.cli_opts,
                                             preserve=True)
         instances[c] = importer.construct_entry_point(
             d_component.entry_point, **instance_params)
     return instances
Beispiel #22
0
 def _setup_db(self):
     dbhelper.drop_db(distro=self.distro,
                      dbtype=self.get_option('db', 'type'),
                      dbname=DB_NAME,
                      **utils.merge_dicts(
                          self.get_option('db'),
                          dbhelper.get_shared_passwords(self)))
     # Explicitly use latin1: to avoid lp#829209, nova expects the database to
     # use latin1 by default, and then upgrades the database to utf8 (see the
     # 082_essex.py in nova)
     dbhelper.create_db(distro=self.distro,
                        dbtype=self.get_option('db', 'type'),
                        dbname=DB_NAME,
                        charset='latin1',
                        **utils.merge_dicts(
                            self.get_option('db'),
                            dbhelper.get_shared_passwords(self)))
Beispiel #23
0
 def env_exports(self):
     params = khelper.get_shared_params(**utils.merge_dicts(self.options,
                                                            khelper.get_shared_passwords(self)))
     to_set = {}
     to_set['OS_PASSWORD'] = params['admin_password']
     to_set['OS_TENANT_NAME'] = params['demo_tenant']
     to_set['OS_USERNAME'] = params['demo_user']
     to_set['OS_AUTH_URL'] = params['endpoints']['public']['uri']
     to_set['SERVICE_ENDPOINT'] = params['endpoints']['admin']['uri']
     return to_set
Beispiel #24
0
 def _config_adjust_root(self, contents, fn):
     params = khelper.get_shared_params(**utils.merge_dicts(self.options,
                                                            khelper.get_shared_passwords(self)))
     with io.BytesIO(contents) as stream:
         config = cfg.RewritableConfigParser()
         config.readfp(stream)
         config.set('DEFAULT', 'admin_token', params['service_token'])
         config.set('DEFAULT', 'admin_port', params['endpoints']['admin']['port'])
         config.set('DEFAULT', 'public_port', params['endpoints']['public']['port'])
         config.set('DEFAULT', 'verbose', True)
         config.set('DEFAULT', 'debug', True)
         config.set('catalog', 'driver', 'keystone.catalog.backends.sql.Catalog')
         config.remove_option('DEFAULT', 'log_config')
         config.set('sql', 'connection', dbhelper.fetch_dbdsn(dbname=DB_NAME,
                                                              utf8=True,
                                                              dbtype=self.get_option('db', 'type'),
                                                              **utils.merge_dicts(self.get_option('db'),
                                                                                  dbhelper.get_shared_passwords(self))))
         config.set('ec2', 'driver', "keystone.contrib.ec2.backends.sql.Ec2")
         contents = config.stringify(fn)
     return contents
Beispiel #25
0
 def post_start(self):
     comp.PythonRuntime.post_start(self)
     if self.get_bool_option('load-images'):
         # Install any images that need activating...
         self.wait_active()
         params = {}
         params['glance'] = ghelper.get_shared_params(**self.options)
         params['keystone'] = khelper.get_shared_params(ip=self.get_option('ip'),
                                                        service_user='******',
                                                        **utils.merge_dicts(self.get_option('keystone'),
                                                                            khelper.get_shared_passwords(self)))
         ghelper.UploadService(params).install(self._get_image_urls())
Beispiel #26
0
 def _config_adjust_paste(self, contents, fn):
     params = khelper.get_shared_params(ip=self.get_option('ip'),
                                        service_user='******',
                                        **utils.merge_dicts(self.get_option('keystone'), 
                                                            khelper.get_shared_passwords(self)))
     with io.BytesIO(contents) as stream:
         config = cfg.create_parser(cfg.RewritableConfigParser, self)
         config.readfp(stream)
         for (k, v) in self._fetch_keystone_params().items():
             config.set('filter:authtoken', k, v)
         contents = config.stringify(fn)
     return contents
Beispiel #27
0
 def post_start(self):
     comp.PythonRuntime.post_start(self)
     if self.get_bool_option('load-images'):
         # Install any images that need activating...
         self.wait_active()
         params = {}
         params['glance'] = ghelper.get_shared_params(**self.options)
         params['keystone'] = khelper.get_shared_params(
             ip=self.get_option('ip'),
             service_user='******',
             **utils.merge_dicts(self.get_option('keystone'),
                                 khelper.get_shared_passwords(self)))
         ghelper.UploadService(params).install(self._get_image_urls())
Beispiel #28
0
 def env_exports(self):
     params = khelper.get_shared_params(**utils.merge_dicts(self.options,
                                                            khelper.get_shared_passwords(self)))
     to_set = OrderedDict()
     to_set['OS_PASSWORD'] = params['admin_password']
     to_set['OS_TENANT_NAME'] = params['admin_tenant']
     to_set['OS_USERNAME'] = params['admin_user']
     to_set['OS_AUTH_URL'] = params['endpoints']['public']['uri']
     for (endpoint, details) in params['endpoints'].items():
         if endpoint.find('templated') != -1:
             continue
         to_set[("KEYSTONE_%s_URI" % (endpoint.upper()))] = details['uri']
     return to_set
Beispiel #29
0
 def env_exports(self):
     params = khelper.get_shared_params(**utils.merge_dicts(self.options,
                                                            khelper.get_shared_passwords(self)))
     to_set = OrderedDict()
     to_set['OS_PASSWORD'] = params['admin_password']
     to_set['OS_TENANT_NAME'] = params['admin_tenant']
     to_set['OS_USERNAME'] = params['admin_user']
     to_set['OS_AUTH_URL'] = params['endpoints']['public']['uri']
     for (endpoint, details) in params['endpoints'].items():
         if endpoint.find('templated') != -1:
             continue
         to_set[("KEYSTONE_%s_URI" % (endpoint.upper()))] = details['uri']
     return to_set
Beispiel #30
0
 def _config_adjust_paste(self, contents, fn):
     params = khelper.get_shared_params(
         ip=self.get_option('ip'),
         service_user='******',
         **utils.merge_dicts(self.get_option('keystone'),
                             khelper.get_shared_passwords(self)))
     with io.BytesIO(contents) as stream:
         config = cfg.create_parser(cfg.RewritableConfigParser, self)
         config.readfp(stream)
         for (k, v) in self._fetch_keystone_params().items():
             config.set('filter:authtoken', k, v)
         contents = config.stringify(fn)
     return contents
Beispiel #31
0
 def env_exports(self):
     params = khelper.get_shared_params(**utils.merge_dicts(self.options, khelper.get_shared_passwords(self)))
     to_set = OrderedDict()
     to_set["OS_PASSWORD"] = params["admin_password"]
     to_set["OS_TENANT_NAME"] = params["admin_tenant"]
     to_set["OS_USERNAME"] = params["admin_user"]
     to_set["OS_AUTH_URL"] = params["endpoints"]["public"]["uri"]
     to_set["SERVICE_ENDPOINT"] = params["endpoints"]["admin"]["uri"]
     for (endpoint, details) in params["endpoints"].items():
         if endpoint.find("templated") != -1:
             continue
         to_set[("KEYSTONE_%s_URI" % (endpoint.upper()))] = details["uri"]
     return to_set
Beispiel #32
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 {}
     wanted_components = persona.wanted_components or []
     # All siblings for the current persona
     instances = {}
     # Keeps track of all sibling instances across all components + actions
     # so that each instance or sibling instance will be connected to the
     # right set of siblings....
     sibling_instances = {}
     for c in wanted_components:
         d_component = self.distro.extract_component(c, self.lookup_name)
         LOG.debug("Constructing component %r (%s)", c, d_component.entry_point)
         d_subsystems = d_component.options.pop("subsystems", {})
         sibling_params = {}
         sibling_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...
         active_subsystems = self._merge_subsystems(
             distro_subsystems=d_subsystems, desired_subsystems=persona_subsystems.get(c, [])
         )
         sibling_params["subsystems"] = active_subsystems
         sibling_params["siblings"] = {}  # This gets adjusted during construction
         sibling_params["passwords"] = self.passwords
         sibling_params["distro"] = self.distro
         sibling_params["options"] = self._merge_options(
             c, component_opts=self._get_interpolated_options(c), distro_opts=d_component.options, persona_opts={}
         )
         LOG.debug("Constructing %r %s siblings...", c, len(d_component.siblings))
         my_siblings = self._construct_siblings(c, d_component.siblings, sibling_params, sibling_instances)
         # Now inject the full options and create the target instance
         # with the full set of options and not the restricted set that
         # siblings get...
         instance_params = dict(sibling_params)
         instance_params["instances"] = instances
         instance_params["options"] = self._merge_options(
             c,
             component_opts=self._get_interpolated_options(c),
             distro_opts=d_component.options,
             persona_opts=persona_opts.get(c, {}),
         )
         instance_params["siblings"] = my_siblings
         instance_params = utils.merge_dicts(instance_params, self.cli_opts, preserve=True)
         instances[c] = importer.construct_entry_point(d_component.entry_point, **instance_params)
     return instances
Beispiel #33
0
 def _construct_instances(self, persona):
     """Create component objects for each component in the persona."""
     # Keeps track of all sibling instances across all components + actions
     # so that each instance or sibling instance will be connected to the
     # right set of siblings....
     sibling_instances = {}
     components_created = set()
     groups = []
     for group in persona.matched_components:
         instances = utils.OrderedDict()
         for c in group:
             if c in components_created:
                 raise RuntimeError("Can not duplicate component %s in a"
                                    " later group %s" % (c, group.id))
             d_component = self.distro.extract_component(
                 c, self.lookup_name, default_entry_point_creator=self._make_default_entry_points)
             LOG.debug("Constructing component %r (%s)", c, d_component.entry_point)
             d_subsystems = d_component.options.pop('subsystems', {})
             sibling_params = {}
             sibling_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...
             active_subsystems = self._merge_subsystems(distro_subsystems=d_subsystems,
                                                        desired_subsystems=persona.wanted_subsystems.get(c, []))
             sibling_params['subsystems'] = active_subsystems
             sibling_params['siblings'] = {}  # This gets adjusted during construction
             sibling_params['distro'] = self.distro
             sibling_params['options'] = self.config_loader.load(
                 distro=d_component, component=c,
                 origins_patch=self.cli_opts.get('origins_patch'))
             LOG.debug("Constructing %r %s siblings...", c, len(d_component.siblings))
             my_siblings = self._construct_siblings(c, d_component.siblings, sibling_params, sibling_instances)
             # Now inject the full options and create the target instance
             # with the full set of options and not the restricted set that
             # siblings get...
             instance_params = dict(sibling_params)
             instance_params['instances'] = instances
             instance_params['options'] = self.config_loader.load(
                 distro=d_component, component=c, persona=persona,
                 origins_patch=self.cli_opts.get('origins_patch'))
             instance_params['siblings'] = my_siblings
             instance_params = utils.merge_dicts(instance_params, self.cli_opts, preserve=True)
             instances[c] = importer.construct_entry_point(d_component.entry_point, **instance_params)
             if c not in SPECIAL_GROUPS:
                 components_created.add(c)
         groups.append((group.id, instances))
     return groups
Beispiel #34
0
 def _fetch_keystone_params(self):
     params = khelper.get_shared_params(ip=self.get_option('ip'),
                                        service_user='******',
                                        **utils.merge_dicts(self.get_option('keystone'),
                                                            khelper.get_shared_passwords(self)))
     return {
         'auth_host': params['endpoints']['admin']['host'],
         'auth_port': params['endpoints']['admin']['port'],
         'auth_protocol': params['endpoints']['admin']['protocol'],
         # This uses the public uri not the admin one...
         'auth_uri': params['endpoints']['public']['uri'],
         'admin_tenant_name': params['service_tenant'],
         'admin_user': params['service_user'],
         'admin_password': params['service_password'],
     }
Beispiel #35
0
 def _fetch_keystone_params(self):
     params = khelper.get_shared_params(ip=self.get_option('ip'),
                                        service_user='******',
                                        **utils.merge_dicts(self.get_option('keystone'),
                                                            khelper.get_shared_passwords(self)))
     return {
         'auth_host': params['endpoints']['admin']['host'],
         'auth_port': params['endpoints']['admin']['port'],
         'auth_protocol': params['endpoints']['admin']['protocol'],
         # This uses the public uri not the admin one...
         'auth_uri': params['endpoints']['public']['uri'],
         'admin_tenant_name': params['service_tenant'],
         'admin_user': params['service_user'],
         'admin_password': params['service_password'],
     }
Beispiel #36
0
 def _construct_siblings(self, name, siblings, params, sibling_instances):
     there_siblings = {}
     for (action, cls_name) in siblings.items():
         if action not in sibling_instances:
             sibling_instances[action] = {}
         cls = importer.import_entry_point(cls_name)
         sibling_params = utils.merge_dicts(params, self.cli_opts, preserve=True)
         sibling_params["instances"] = sibling_instances[action]
         LOG.debug("Construction of sibling component %r (%r) params are:", name, action)
         utils.log_object(sibling_params, logger=LOG, level=logging.DEBUG)
         a_sibling = cls(**sibling_params)
         # Update the sibling we are returning and the corresponding
         # siblings for that action (so that the sibling can have the
         # correct 'sibling' instances associated with it, if it needs those...)
         there_siblings[action] = a_sibling
         sibling_instances[action][name] = a_sibling
     return there_siblings
Beispiel #37
0
 def _config_adjust_registry(self, contents, fn):
     params = ghelper.get_shared_params(**self.options)
     with io.BytesIO(contents) as stream:
         config = cfg.RewritableConfigParser()
         config.readfp(stream)
         config.set('DEFAULT', 'debug', self.get_bool_option('verbose'))
         config.set('DEFAULT', 'verbose', self.get_bool_option('verbose'))
         config.set('DEFAULT', 'bind_port', params['endpoints']['registry']['port'])
         config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME,
                                                                      utf8=True,
                                                                      dbtype=self.get_option('db', 'type'),
                                                                      **utils.merge_dicts(self.get_option('db'),
                                                                                          dbhelper.get_shared_passwords(self))))
         config.remove_option('DEFAULT', 'log_file')
         config.set('paste_deploy', 'flavor', self.get_option('paste_flavor'))
         return config.stringify(fn)
     return contents
Beispiel #38
0
    def load(self, distro, component, persona=None):
        # NOTE (vnovikov): applying takes place before loading reference links
        self._apply_persona(component, persona)

        dir_opts = self._get_dir_opts(component)
        distro_opts = distro.options
        general_component_opts = self._base_loader.load('general')
        component_specific_opts = self._base_loader.load(component)

        # NOTE (vnovikov): merge order is the same as arguments order below.
        merged_opts = utils.merge_dicts(
            dir_opts,
            distro_opts,
            general_component_opts,
            component_specific_opts,
        )

        return merged_opts
Beispiel #39
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
Beispiel #40
0
 def _config_adjust_root(self, config):
     params = khelper.get_shared_params(**utils.merge_dicts(self.installer.options,
                                                            khelper.get_shared_passwords(self.installer)))
     config.add('admin_token', params['service_token'])
     config.add('admin_port', params['endpoints']['admin']['port'])
     config.add('public_port', params['endpoints']['public']['port'])
     config.add('verbose', True)
     config.add('debug', True)
     if self.installer.get_bool_option('enable-pki'):
         config.add_with_section('signing', 'token_format', 'PKI')
         for (k, v) in PKI_FILES.items():
             path = sh.joinpths(self.link_dir, v)
             config.add_with_section('signing', k, path)
     else:
         config.add_with_section('signing', 'token_format', 'UUID')
     config.add_with_section('catalog', 'driver', 'keystone.catalog.backends.sql.Catalog')
     config.remove('DEFAULT', 'log_config')
     config.add_with_section('sql', 'connection', self.fetch_dbdsn())
     config.add_with_section('ec2', 'driver', "keystone.contrib.ec2.backends.sql.Ec2")
Beispiel #41
0
    def _config_adjust_paste(self, contents, fn):
        params = khelper.get_shared_params(ip=self.get_option('ip'),
                                           service_user='******',
                                           **utils.merge_dicts(self.get_option('keystone'), 
                                                               khelper.get_shared_passwords(self)))
        with io.BytesIO(contents) as stream:
            config = cfg.RewritableConfigParser()
            config.readfp(stream)
            config.set('filter:authtoken', 'auth_host', params['endpoints']['admin']['host'])
            config.set('filter:authtoken', 'auth_port', params['endpoints']['admin']['port'])
            config.set('filter:authtoken', 'auth_protocol', params['endpoints']['admin']['protocol'])

            # This uses the public uri not the admin one...
            config.set('filter:authtoken', 'auth_uri', params['endpoints']['public']['uri'])

            config.set('filter:authtoken', 'admin_tenant_name', params['service_tenant'])
            config.set('filter:authtoken', 'admin_user', params['service_user'])
            config.set('filter:authtoken', 'admin_password', params['service_password'])
            contents = config.stringify(fn)
        return contents
Beispiel #42
0
 def _construct_siblings(self, name, siblings, params, sibling_instances):
     there_siblings = {}
     for (action, cls_name) in siblings.items():
         if action not in sibling_instances:
             sibling_instances[action] = {}
         cls = importer.import_entry_point(cls_name)
         sibling_params = utils.merge_dicts(params,
                                            self.cli_opts,
                                            preserve=True)
         sibling_params['instances'] = sibling_instances[action]
         LOG.debug("Construction of sibling component %r (%r) params are:",
                   name, action)
         utils.log_object(sibling_params, logger=LOG, level=logging.DEBUG)
         a_sibling = cls(**sibling_params)
         # Update the sibling we are returning and the corresponding
         # siblings for that action (so that the sibling can have the
         # correct 'sibling' instances associated with it, if it needs those...)
         there_siblings[action] = a_sibling
         sibling_instances[action][name] = a_sibling
     return there_siblings
Beispiel #43
0
 def _construct_siblings(self, name, siblings, base_params, sibling_instances):
     # First setup the sibling instance action references
     for (action, _entry_point) in siblings.items():
         if action not in sibling_instances:
             sibling_instances[action] = {}
     there_siblings = {}
     for (action, entry_point) in siblings.items():
         sibling_params = utils.merge_dicts(base_params, self.cli_opts, preserve=True)
         # Give the sibling the reference to all other siblings being created
         # which will be populated when they are created (now or later) for
         # the same action
         sibling_params['instances'] = sibling_instances[action]
         a_sibling = importer.construct_entry_point(entry_point, **sibling_params)
         # Update the sibling we are returning and the corresponding
         # siblings for that action (so that the sibling can have the
         # correct 'sibling' instances associated with it, if it needs those...)
         there_siblings[action] = a_sibling
         # Update all siblings being constructed so that there siblings will
         # be correct when fetched...
         sibling_instances[action][name] = a_sibling
     return there_siblings
Beispiel #44
0
 def _config_adjust_registry(self, contents, fn):
     params = ghelper.get_shared_params(**self.options)
     with io.BytesIO(contents) as stream:
         config = cfg.create_parser(cfg.RewritableConfigParser, self)
         config.readfp(stream)
         config.set('DEFAULT', 'debug', self.get_bool_option('verbose'))
         config.set('DEFAULT', 'verbose', self.get_bool_option('verbose'))
         config.set('DEFAULT', 'bind_port',
                    params['endpoints']['registry']['port'])
         config.set(
             'DEFAULT', 'sql_connection',
             dbhelper.fetch_dbdsn(dbname=DB_NAME,
                                  utf8=True,
                                  dbtype=self.get_option('db', 'type'),
                                  **utils.merge_dicts(
                                      self.get_option('db'),
                                      dbhelper.get_shared_passwords(self))))
         config.remove_option('DEFAULT', 'log_file')
         config.set('paste_deploy', 'flavor',
                    self.get_option('paste_flavor'))
         return config.stringify(fn)
     return contents
Beispiel #45
0
 def _config_adjust_api(self, contents, fn):
     params = ghelper.get_shared_params(**self.options)
     with io.BytesIO(contents) as stream:
         config = cfg.RewritableConfigParser()
         config.readfp(stream)
         img_store_dir = sh.joinpths(self.get_option('component_dir'), 'images')
         config.set('DEFAULT', 'debug', self.get_bool_option('verbose',))
         config.set('DEFAULT', 'verbose', self.get_bool_option('verbose'))
         config.set('DEFAULT', 'default_store', 'file')
         config.set('DEFAULT', 'filesystem_store_datadir', img_store_dir)
         config.set('DEFAULT', 'bind_port', params['endpoints']['public']['port'])
         config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME,
                                                                      utf8=True,
                                                                      dbtype=self.get_option('db', 'type'),
                                                                      **utils.merge_dicts(self.get_option('db'), 
                                                                                          dbhelper.get_shared_passwords(self))))
         config.remove_option('DEFAULT', 'log_file')
         config.set('paste_deploy', 'flavor', self.get_option('paste_flavor'))
         LOG.debug("Ensuring file system store directory %r exists and is empty." % (img_store_dir))
         sh.deldir(img_store_dir)
         self.tracewriter.dirs_made(*sh.mkdirslist(img_store_dir))
         return config.stringify(fn)
Beispiel #46
0
 def _config_adjust_root(self, config):
     params = khelper.get_shared_params(
         **utils.merge_dicts(self.installer.options,
                             khelper.get_shared_passwords(self.installer)))
     config.add('admin_token', params['service_token'])
     config.add('admin_port', params['endpoints']['admin']['port'])
     config.add('public_port', params['endpoints']['public']['port'])
     config.add('verbose', True)
     config.add('debug', True)
     if self.installer.get_bool_option('enable-pki'):
         config.add_with_section('signing', 'token_format', 'PKI')
         for (k, v) in PKI_FILES.items():
             path = sh.joinpths(self.link_dir, v)
             config.add_with_section('signing', k, path)
     else:
         config.add_with_section('signing', 'token_format', 'UUID')
     config.add_with_section('catalog', 'driver',
                             'keystone.catalog.backends.sql.Catalog')
     config.remove('DEFAULT', 'log_config')
     config.add_with_section('sql', 'connection', self.fetch_dbdsn())
     config.add_with_section('ec2', 'driver',
                             "keystone.contrib.ec2.backends.sql.Ec2")
Beispiel #47
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
Beispiel #48
0
    def load(self, distro, component, persona=None):
        # NOTE (vnovikov): applying takes place before loading reference links
        self._apply_persona(component, persona)

        dir_opts = self._get_dir_opts(component)
        distro_opts = distro.options
        origins_opts = {}
        if self._origins_path:
            try:
                origins_opts = utils.load_yaml(self._origins_path)[component]
            except KeyError:
                pass
        general_component_opts = self._base_loader.load('general')
        component_specific_opts = self._base_loader.load(component)

        # NOTE (vnovikov): merge order is the same as arguments order below.
        merged_opts = utils.merge_dicts(
            dir_opts,
            distro_opts,
            origins_opts,
            general_component_opts,
            component_specific_opts,
        )
        return merged_opts
Beispiel #49
0
 def get_keystone_params(self, service_user):
     return khelper.get_shared_params(
         ip=self.installer.get_option('ip'),
         service_user=service_user,
         **utils.merge_dicts(self.installer.get_option('keystone'),
                             khelper.get_shared_passwords(self.installer)))
Beispiel #50
0
 def _construct_instances(self, persona):
     """Create component objects for each component in the persona."""
     # Keeps track of all sibling instances across all components + actions
     # so that each instance or sibling instance will be connected to the
     # right set of siblings....
     sibling_instances = {}
     components_created = set()
     groups = []
     for group in persona.matched_components:
         instances = utils.OrderedDict()
         for c in group:
             if c in components_created:
                 raise RuntimeError("Can not duplicate component %s in a"
                                    " later group %s" % (c, group.id))
             d_component = self.distro.extract_component(
                 c,
                 self.lookup_name,
                 default_entry_point_creator=self._make_default_entry_points
             )
             LOG.debug("Constructing component %r (%s)", c,
                       d_component.entry_point)
             d_subsystems = d_component.options.pop('subsystems', {})
             sibling_params = {}
             sibling_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...
             active_subsystems = self._merge_subsystems(
                 distro_subsystems=d_subsystems,
                 desired_subsystems=persona.wanted_subsystems.get(c, []))
             sibling_params['subsystems'] = active_subsystems
             sibling_params['siblings'] = {
             }  # This gets adjusted during construction
             sibling_params['distro'] = self.distro
             sibling_params['options'] = self.config_loader.load(
                 distro=d_component,
                 component=c,
                 origins_patch=self.cli_opts.get('origins_patch'))
             LOG.debug("Constructing %r %s siblings...", c,
                       len(d_component.siblings))
             my_siblings = self._construct_siblings(c, d_component.siblings,
                                                    sibling_params,
                                                    sibling_instances)
             # Now inject the full options and create the target instance
             # with the full set of options and not the restricted set that
             # siblings get...
             instance_params = dict(sibling_params)
             instance_params['instances'] = instances
             instance_params['options'] = self.config_loader.load(
                 distro=d_component,
                 component=c,
                 persona=persona,
                 origins_patch=self.cli_opts.get('origins_patch'))
             instance_params['siblings'] = my_siblings
             instance_params = utils.merge_dicts(instance_params,
                                                 self.cli_opts,
                                                 preserve=True)
             instances[c] = importer.construct_entry_point(
                 d_component.entry_point, **instance_params)
             if c not in SPECIAL_GROUPS:
                 components_created.add(c)
         groups.append((group.id, instances))
     return groups
Beispiel #51
0
    def generate(self, fn):

        # Everything built goes in here
        nova_conf = Conf(fn, self.installer)

        # Used more than once so we calculate it ahead of time
        hostip = self.installer.get_option('ip')

        nova_conf.add('verbose', self.installer.get_bool_option('verbose'))

        # Allow destination machine to match source for resize.
        nova_conf.add('allow_resize_to_same_host', True)

        # Which scheduler do u want?
        nova_conf.add(
            'compute_scheduler_driver',
            self.installer.get_option(
                'scheduler',
                default_value='nova.scheduler.filter_scheduler.FilterScheduler'
            ))

        # Rate limit the api??
        nova_conf.add('api_rate_limit',
                      self.installer.get_bool_option('api_rate_limit'))

        # Setup nova network/settings
        self._configure_network_settings(nova_conf)

        # Setup nova volume/settings
        if self.installer.get_option('volumes'):
            self._configure_vols(nova_conf)

        # The ip of where we are running
        nova_conf.add('my_ip', hostip)

        # Setup your sql connection
        dbdsn = dbhelper.fetch_dbdsn(
            dbname=DB_NAME,
            utf8=True,
            dbtype=self.installer.get_option('db', 'type'),
            **utils.merge_dicts(self.installer.get_option('db'),
                                dbhelper.get_shared_passwords(self.installer)))
        nova_conf.add('sql_connection', dbdsn)

        # Configure anything libvirt related?
        virt_driver = canon_virt_driver(
            self.installer.get_option('virt_driver'))
        if virt_driver == 'libvirt':
            self._configure_libvirt(
                lv.canon_libvirt_type(
                    self.installer.get_option('libvirt_type')), nova_conf)

        # How instances will be presented
        instance_template = "%s%s" % (
            self.installer.get_option('instance_name_prefix'),
            self.installer.get_option('instance_name_postfix'))
        if not instance_template:
            instance_template = 'instance-%08x'
        nova_conf.add('instance_name_template', instance_template)

        # Enable the standard extensions
        nova_conf.add(
            'osapi_compute_extension',
            'nova.api.openstack.compute.contrib.standard_extensions')

        # Auth will be using keystone
        nova_conf.add('auth_strategy', 'keystone')

        # Is config drive being forced?
        if self.installer.get_bool_option('force_cfg_drive'):
            nova_conf.add('force_config_drive', 'always')

        # Don't always force images to raw
        nova_conf.add('force_raw_images',
                      self.installer.get_bool_option('force_raw_images'))

        # Add a checksum for images fetched to a hypervisor
        nova_conf.add('checksum_base_images',
                      self.installer.get_bool_option('checksum_base_images'))

        # Vnc settings setup
        self._configure_vnc(nova_conf)

        # Where our paste config is
        nova_conf.add('api_paste_config',
                      self.installer.target_config(PASTE_CONF))

        # What our imaging service will be
        self._configure_image_service(nova_conf, hostip)

        # Configs for ec2 / s3 stuff
        nova_conf.add(
            'ec2_dmz_host',
            self.installer.get_option('ec2_dmz_host', default_value=hostip))
        nova_conf.add('s3_host', hostip)

        # How is your message queue setup?
        mq_type = canon_mq_type(self.installer.get_option('mq-type'))
        if mq_type == 'rabbit':
            nova_conf.add(
                'rabbit_host',
                self.installer.get_option('rabbit',
                                          'host',
                                          default_value=hostip))
            nova_conf.add('rabbit_password',
                          rbhelper.get_shared_passwords(self.installer)['pw'])
            nova_conf.add('rabbit_userid',
                          self.installer.get_option('rabbit', 'user_id'))
            nova_conf.add('rpc_backend', 'nova.rpc.impl_kombu')

        # The USB tablet device is meant to improve mouse behavior in
        # the VNC console, but it has the side effect of increasing
        # the CPU usage of an idle VM tenfold.
        nova_conf.add('use_usb_tablet', False)

        # Where instances will be stored
        instances_path = self.installer.get_option('instances_path')
        if not instances_path:
            instances_path = sh.joinpths(
                self.installer.get_option('component_dir'), 'instances')
        self._configure_instances_path(instances_path, nova_conf)

        # Is this a multihost setup?
        self._configure_multihost(nova_conf)

        # Handle any virt driver specifics
        self._configure_virt_driver(nova_conf)

        # Annnnnd extract to finish
        return self._get_content(nova_conf)
Beispiel #52
0
 def _merge_options(self, name, distro_opts, component_opts, persona_opts):
     return utils.merge_dicts(self._get_component_dirs(name),
                              distro_opts, component_opts, persona_opts)