Ejemplo n.º 1
0
 def _config_adjust(self, contents, config_fn):
     if config_fn == PLUGIN_CONF and self.q_vswitch_service:
         # Need to fix the "Quantum plugin provider module"
         newcontents = contents
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             provider = config.get("PLUGIN", "provider")
             if provider != V_PROVIDER:
                 config.set("PLUGIN", "provider", V_PROVIDER)
                 with io.BytesIO() as outputstream:
                     config.write(outputstream)
                     outputstream.flush()
                     newcontents = cfg.add_header(config_fn, outputstream.getvalue())
         return newcontents
     elif config_fn == AGENT_CONF and self.q_vswitch_agent:
         # Need to adjust the sql connection
         newcontents = contents
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             db_dsn = config.get("DATABASE", "sql_connection")
             if db_dsn:
                 generated_dsn = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME)
                 if generated_dsn != db_dsn:
                     config.set("DATABASE", "sql_connection", generated_dsn)
                     with io.BytesIO() as outputstream:
                         config.write(outputstream)
                         outputstream.flush()
                         newcontents = cfg.add_header(config_fn, outputstream.getvalue())
         return newcontents
     else:
         return comp.PkgInstallComponent._config_adjust(self, contents, config_fn)
Ejemplo n.º 2
0
 def _config_adjust_root(self, contents, fn):
     params = get_shared_params(self.cfg, self.pw_gen)
     with io.BytesIO(contents) as stream:
         config = cfg.IgnoreMissingConfigParser()
         config.readfp(stream)
         config.set('DEFAULT', 'admin_token', params['SERVICE_TOKEN'])
         config.set('DEFAULT', 'admin_port', params['KEYSTONE_AUTH_PORT'])
         config.set('DEFAULT', 'verbose', True)
         config.set('DEFAULT', 'debug', True)
         config.remove_option('DEFAULT', 'log_config')
         config.set(
             'sql', 'connection',
             db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True))
         config.set('catalog', 'template_file',
                    sh.joinpths(self.cfg_dir, CATALOG_CONF))
         config.set('catalog', 'driver',
                    "keystone.catalog.backends.templated.TemplatedCatalog")
         config.set('ec2', 'driver',
                    "keystone.contrib.ec2.backends.sql.Ec2")
         config.set('filter:s3_extension', 'paste.filter_factory',
                    "keystone.contrib.s3:S3Extension.factory")
         config.set('pipeline:admin_api', 'pipeline', (
             'token_auth admin_token_auth xml_body '
             'json_body debug ec2_extension s3_extension crud_extension admin_service'
         ))
         contents = config.stringify(fn)
     # FIXME: LP 966670 fixes this in keystone
     sh.unlink(sh.joinpths(self.app_dir, 'etc', fn))
     return contents
Ejemplo n.º 3
0
 def _config_adjust(self, contents, config_fn):
     if config_fn == ROOT_CONF:
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             config.set('DEFAULT', 'sql_connection', db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True))
             config.set('DEFAULT', 'verbose', True)
             config.set('DEFAULT', 'debug', True)
             contents = config.stringify(config_fn)
     return contents
Ejemplo n.º 4
0
 def _get_param_map(self, config_fn):
     # This dict will be used to fill in the configuration
     # params with actual values
     mp = dict()
     mp['DEST'] = self.app_dir
     mp['SYSLOG'] = self.cfg.getboolean("default", "syslog")
     mp['SQL_CONN'] = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME)
     mp['SERVICE_HOST'] = self.cfg.get('host', 'ip')
     mp['HOST_IP'] = self.cfg.get('host', 'ip')
     mp.update(keystone.get_shared_params(self.cfg, self.pw_gen, 'glance'))
     return mp
Ejemplo n.º 5
0
 def _get_param_map(self, config_fn):
     # This dict will be used to fill in the configuration
     # params with actual values
     mp = dict()
     mp['DEST'] = self.app_dir
     mp['SYSLOG'] = self.cfg.getboolean("default", "syslog")
     mp['SQL_CONN'] = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME)
     mp['SERVICE_HOST'] = self.cfg.get('host', 'ip')
     mp['HOST_IP'] = self.cfg.get('host', 'ip')
     mp.update(keystone.get_shared_params(self.cfg, self.pw_gen, 'glance'))
     return mp
Ejemplo n.º 6
0
 def _get_param_map(self, config_fn):
     # This dict will be used to fill in the configuration
     # params with actual values
     mp = comp.PythonInstallComponent._get_param_map(self, config_fn)
     mp['IMG_DIR'] = self._get_image_dir()
     mp['SYSLOG'] = self.cfg.getboolean("default", "syslog")
     mp['SQL_CONN'] = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True)
     mp['SERVICE_HOST'] = self.cfg.get('host', 'ip')
     mp['HOST_IP'] = self.cfg.get('host', 'ip')
     mp.update(keystone.get_shared_params(self.cfg, self.pw_gen, 'glance'))
     return mp
Ejemplo n.º 7
0
 def _config_adjust_registry(self, contents, fn):
     with io.BytesIO(contents) as stream:
         config = cfg.IgnoreMissingConfigParser()
         config.readfp(stream)
         config.set('DEFAULT', 'debug', True)
         config.set('DEFAULT', 'verbose', True)
         config.remove_option('DEFAULT', 'log_file')
         config.set('DEFAULT', 'sql_connection',
                             db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True))
         config.set('paste_deploy', 'flavor', 'keystone')
         return config.stringify(fn)
     return contents
Ejemplo n.º 8
0
def test_fetch_dbdsn_full():
    cfg = ConfigParser()
    cfg.add_section('db')
    cfg.set('db', 'sql_user', 'sql_user')
    cfg.set('db', 'sql_host', 'sql_host')
    cfg.set('db', 'port', '55')
    cfg.set('db', 'type', 'mysql')
    cfg.add_section('passwords')
    cfg.set('passwords', 'sql', 'password')

    dsn = db.fetch_dbdsn(cfg, passwords.PasswordGenerator(cfg, False))
    assert dsn == 'mysql://*****:*****@sql_host:55/'
Ejemplo n.º 9
0
 def _config_adjust_registry(self, contents, fn):
     with io.BytesIO(contents) as stream:
         config = cfg.IgnoreMissingConfigParser()
         config.readfp(stream)
         config.set('DEFAULT', 'debug', True)
         config.set('DEFAULT', 'verbose', True)
         config.remove_option('DEFAULT', 'log_file')
         config.set(
             'DEFAULT', 'sql_connection',
             db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True))
         config.set('paste_deploy', 'flavor', 'keystone')
         return config.stringify(fn)
     return contents
Ejemplo n.º 10
0
 def _get_param_map(self, config_fn):
     # These be used to fill in the configuration/cmds +
     # params with actual values
     mp = dict()
     mp['SERVICE_HOST'] = self.cfg.get('host', 'ip')
     mp['DEST'] = self.app_dir
     mp['BIN_DIR'] = self.bin_dir
     mp['CONFIG_FILE'] = sh.joinpths(self.cfg_dir, ROOT_CONF)
     if config_fn == ROOT_CONF:
         mp['SQL_CONN'] = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME)
         mp['KEYSTONE_DIR'] = self.app_dir
         mp.update(get_shared_params(self.cfg, self.pw_gen))
     elif config_fn == MANAGE_DATA_CONF:
         mp.update(get_shared_params(self.cfg, self.pw_gen))
     return mp
Ejemplo n.º 11
0
 def _get_param_map(self, config_fn):
     # These be used to fill in the configuration/cmds +
     # params with actual values
     mp = comp.PythonInstallComponent._get_param_map(self, config_fn)
     mp['SERVICE_HOST'] = self.cfg.get('host', 'ip')
     mp['DEST'] = self.app_dir
     mp['BIN_DIR'] = self.bin_dir
     mp['CONFIG_FILE'] = sh.joinpths(self.cfg_dir, ROOT_CONF)
     if config_fn == ROOT_CONF:
         mp['SQL_CONN'] = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True)
         mp['KEYSTONE_DIR'] = self.app_dir
         mp.update(get_shared_params(self.cfg, self.pw_gen))
     elif config_fn == MANAGE_DATA_CONF:
         mp.update(get_shared_params(self.cfg, self.pw_gen))
     return mp
Ejemplo n.º 12
0
 def _config_adjust(self, contents, config_fn):
     if config_fn == ROOT_CONF:
         newcontents = contents
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             db_dsn = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME)
             old_dbsn = config.get('DEFAULT', 'sql_connection')
             if db_dsn != old_dbsn:
                 config.set('DEFAULT', 'sql_connection', db_dsn)
                 with io.BytesIO() as outputstream:
                     config.write(outputstream)
                     outputstream.flush()
                     newcontents = cfg.add_header(config_fn, outputstream.getvalue())
         contents = newcontents
     return contents
Ejemplo n.º 13
0
 def _config_adjust(self, contents, config_fn):
     if config_fn == PLUGIN_CONF and self.q_vswitch_service:
         # Need to fix the "Quantum plugin provider module"
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             config.set("plugin", "provider", "quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin")
             contents = config.stringify(config_fn)
         return contents
     elif config_fn == AGENT_CONF and self.q_vswitch_agent:
         # Need to adjust the sql connection
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             config.set("database", "sql_connection", db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True))
             contents = config.stringify(config_fn)
         return contents
     else:
         return comp.PkgInstallComponent._config_adjust(self, contents, config_fn)
Ejemplo n.º 14
0
 def _config_adjust(self, contents, config_fn):
     if config_fn == PLUGIN_CONF and self.q_vswitch_service:
         # Need to fix the "Quantum plugin provider module"
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             config.set("plugin", "provider", "quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin")
             contents = config.stringify(config_fn)
         return contents
     elif config_fn == AGENT_CONF and self.q_vswitch_agent:
         # Need to adjust the sql connection
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             config.set("database", "sql_connection", db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True))
             contents = config.stringify(config_fn)
         return contents
     else:
         return comp.PkgInstallComponent._config_adjust(self, contents, config_fn)
Ejemplo n.º 15
0
 def _config_adjust_root(self, contents, fn):
     params = get_shared_params(self.cfg, self.pw_gen)
     with io.BytesIO(contents) as stream:
         config = cfg.IgnoreMissingConfigParser()
         config.readfp(stream)
         config.set('DEFAULT', 'admin_token', params['SERVICE_TOKEN'])
         config.set('DEFAULT', 'admin_port', params['KEYSTONE_AUTH_PORT'])
         config.set('DEFAULT', 'verbose', True)
         config.set('DEFAULT', 'debug', True)
         config.remove_option('DEFAULT', 'log_config')
         config.set('sql', 'connection', db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True))
         config.set('catalog', 'template_file', sh.joinpths(self.cfg_dir, CATALOG_CONF))
         config.set('catalog', 'driver', "keystone.catalog.backends.templated.TemplatedCatalog")
         config.set('ec2', 'driver', "keystone.contrib.ec2.backends.sql.Ec2")
         config.set('filter:s3_extension', 'paste.filter_factory', "keystone.contrib.s3:S3Extension.factory")
         config.set('pipeline:admin_api', 'pipeline', ('token_auth admin_token_auth xml_body '
                         'json_body debug ec2_extension s3_extension crud_extension admin_service'))
         contents = config.stringify(fn)
     # FIXME: LP 966670 fixes this in keystone
     sh.unlink(sh.joinpths(self.app_dir, 'etc', fn))
     return contents
Ejemplo n.º 16
0
 def _config_adjust(self, contents, config_fn):
     if config_fn == PLUGIN_CONF and self.q_vswitch_service:
         # Need to fix the "Quantum plugin provider module"
         newcontents = contents
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             provider = config.get("PLUGIN", "provider")
             if provider != V_PROVIDER:
                 config.set("PLUGIN", "provider", V_PROVIDER)
                 with io.BytesIO() as outputstream:
                     config.write(outputstream)
                     outputstream.flush()
                     newcontents = cfg.add_header(config_fn,
                                                  outputstream.getvalue())
         return newcontents
     elif config_fn == AGENT_CONF and self.q_vswitch_agent:
         # Need to adjust the sql connection
         newcontents = contents
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             db_dsn = config.get("DATABASE", "sql_connection")
             if db_dsn:
                 generated_dsn = db.fetch_dbdsn(self.cfg, self.pw_gen,
                                                DB_NAME)
                 if generated_dsn != db_dsn:
                     config.set("DATABASE", "sql_connection", generated_dsn)
                     with io.BytesIO() as outputstream:
                         config.write(outputstream)
                         outputstream.flush()
                         newcontents = cfg.add_header(
                             config_fn, outputstream.getvalue())
         return newcontents
     else:
         return comp.PkgInstallComponent._config_adjust(
             self, contents, config_fn)
Ejemplo n.º 17
0
    def configure(self):
        # Everything built goes in here
        nova_conf = NovaConf()

        # Used more than once so we calculate it ahead of time
        hostip = self.cfg.get('host', 'ip')

        if self._getbool('verbose'):
            nova_conf.add('verbose', True)

        # Check if we have a logdir specified. If we do, we'll make
        # sure that it exists. We will *not* use tracewrite because we
        # don't want to lose the logs when we uninstall
        logdir = self._getstr('logdir')
        if logdir:
            full_logdir = sh.abspth(logdir)
            nova_conf.add('logdir', full_logdir)
            # Will need to be root to create it since it may be in /var/log
            if not sh.isdir(full_logdir):
                LOG.debug("Making sure that nova logdir exists at: %s" % full_logdir)
                with sh.Rooted(True):
                    sh.mkdir(full_logdir)
                    sh.chmod(full_logdir, 0777)

        # Allow the admin api?
        if self._getbool('allow_admin_api'):
            nova_conf.add('allow_admin_api', True)

        # FIXME: ??
        nova_conf.add('allow_resize_to_same_host', True)

        # Which scheduler do u want?
        nova_conf.add('compute_scheduler_driver', self._getstr('scheduler', DEF_SCHEDULER))

        # Setup any network settings
        self._configure_network_settings(nova_conf)

        # Setup nova volume settings
        if self.volumes_enabled:
            self._configure_vols(nova_conf)

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

        # Setup your sql connection
        db_dsn = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME)
        nova_conf.add('sql_connection', db_dsn)

        # Configure anything libvirt related?
        virt_driver = _canon_virt_driver(self._getstr('virt_driver'))
        if virt_driver == 'libvirt':
            libvirt_type = _canon_libvirt_type(self._getstr('libvirt_type'))
            self._configure_libvirt(libvirt_type, nova_conf)

        # How instances will be presented
        instance_template = self._getstr('instance_name_prefix') + self._getstr('instance_name_postfix')
        if not instance_template:
            instance_template = DEF_INSTANCE_TEMPL
        nova_conf.add('instance_name_template', instance_template)

        # Enable the standard extensions
        nova_conf.add('osapi_compute_extension', STD_COMPUTE_EXTS)

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

        # Vnc settings setup
        self._configure_vnc(nova_conf)

        # Where our paste config is
        nova_conf.add('api_paste_config', self.paste_conf_fn)

        # 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._getstr('ec2_dmz_host', hostip))
        nova_conf.add('s3_host', hostip)

        # How is your rabbit setup?
        nova_conf.add('rabbit_host', self.cfg.getdefaulted('default', 'rabbit_host', hostip))
        nova_conf.add('rabbit_password', self.cfg.get("passwords", "rabbit"))

        # Where instances will be stored
        instances_path = self._getstr('instances_path', sh.joinpths(self.component_dir, 'instances'))
        self._configure_instances_path(instances_path, nova_conf)

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

        # Enable syslog??
        self._configure_syslog(nova_conf)

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

        # Annnnnd extract to finish
        return self._get_content(nova_conf)
Ejemplo n.º 18
0
    def configure(self):
        # Everything built goes in here
        nova_conf = NovaConf()

        # Used more than once so we calculate it ahead of time
        hostip = self.cfg.get('host', 'ip')

        if self._getbool('verbose'):
            nova_conf.add('verbose', True)

        # Check if we have a logdir specified. If we do, we'll make
        # sure that it exists. We will *not* use tracewrite because we
        # don't want to lose the logs when we uninstall
        logdir = self._getstr('logdir')
        if logdir:
            full_logdir = sh.abspth(logdir)
            nova_conf.add('logdir', full_logdir)
            # Will need to be root to create it since it may be in /var/log
            if not sh.isdir(full_logdir):
                LOG.debug("Making sure that nova logdir exists at: %s" %
                          full_logdir)
                with sh.Rooted(True):
                    sh.mkdir(full_logdir)
                    sh.chmod(full_logdir, 0777)

        # Allow the admin api?
        if self._getbool('allow_admin_api'):
            nova_conf.add('allow_admin_api', True)

        # FIXME: ??
        nova_conf.add('allow_resize_to_same_host', True)

        # Which scheduler do u want?
        nova_conf.add('compute_scheduler_driver',
                      self._getstr('scheduler', DEF_SCHEDULER))

        # Rate limit the api??
        if self._getbool('api_rate_limit'):
            nova_conf.add('api_rate_limit', str(True))
        else:
            nova_conf.add('api_rate_limit', str(False))

        # Setup any network settings
        self._configure_network_settings(nova_conf)

        # Setup nova volume settings
        if self.volumes_enabled:
            self._configure_vols(nova_conf)

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

        # Setup your sql connection
        nova_conf.add('sql_connection',
                      db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME))

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

        # How instances will be presented
        instance_template = self._getstr(
            'instance_name_prefix') + self._getstr('instance_name_postfix')
        if not instance_template:
            instance_template = DEF_INSTANCE_TEMPL
        nova_conf.add('instance_name_template', instance_template)

        # Enable the standard extensions
        nova_conf.add('osapi_compute_extension', STD_COMPUTE_EXTS)

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

        # Vnc settings setup
        self._configure_vnc(nova_conf)

        # Where our paste config is
        nova_conf.add('api_paste_config', self.paste_conf_fn)

        # 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._getstr('ec2_dmz_host', hostip))
        nova_conf.add('s3_host', hostip)

        # How is your rabbit setup?
        nova_conf.add('rabbit_host',
                      self.cfg.getdefaulted('rabbit', 'rabbit_host', hostip))
        nova_conf.add('rabbit_password', self.cfg.get("passwords", "rabbit"))

        # Where instances will be stored
        instances_path = self._getstr(
            'instances_path', sh.joinpths(self.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)