Пример #1
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
Пример #2
0
 def _config_adjust_paste(self, contents, fn):
     params = keystone.get_shared_params(self.cfg, self.pw_gen, 'nova')
     with io.BytesIO(contents) as stream:
         config = cfg.IgnoreMissingConfigParser()
         config.readfp(stream)
         config.set('filter:authtoken', 'auth_host',
                    params['KEYSTONE_AUTH_HOST'])
         config.set('filter:authtoken', 'auth_port',
                    params['KEYSTONE_AUTH_PORT'])
         config.set('filter:authtoken', 'auth_protocol',
                    params['KEYSTONE_AUTH_PROTOCOL'])
         config.set('filter:authtoken', 'auth_uri',
                    params['SERVICE_ENDPOINT'])
         config.set('filter:authtoken', 'admin_tenant_name',
                    params['SERVICE_TENANT_NAME'])
         config.set('filter:authtoken', 'admin_user',
                    params['SERVICE_USERNAME'])
         config.set('filter:authtoken', 'admin_password',
                    params['SERVICE_PASSWORD'])
         config.set('filter:authtoken', 'service_host',
                    params['KEYSTONE_SERVICE_HOST'])
         config.set('filter:authtoken', 'service_port',
                    params['KEYSTONE_SERVICE_PORT'])
         config.set('filter:authtoken', 'service_protocol',
                    params['KEYSTONE_SERVICE_PROTOCOL'])
         contents = config.stringify(fn)
     return contents
Пример #3
0
 def _config_adjust_logging(self, contents, fn):
     with io.BytesIO(contents) as stream:
         config = cfg.IgnoreMissingConfigParser()
         config.readfp(stream)
         config.set('logger_root', 'level', 'DEBUG')
         config.set('logger_root', 'handlers', "devel,production")
         contents = config.stringify(fn)
     return contents
Пример #4
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)
Пример #5
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
Пример #6
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
Пример #7
0
 def _config_adjust(self, contents, name):
     # Even bother opening??
     if name not in READ_CONFIGS:
         return contents
     # Use config parser and
     # then extract known configs that
     # will need locations/directories/files made (or touched)...
     with io.BytesIO(contents) as stream:
         config = cfg.IgnoreMissingConfigParser()
         config.readfp(stream)
         if config.getboolean('default', 'image_cache_enabled'):
             cache_dir = config.get('default', "image_cache_datadir")
             if cache_dir:
                 LOG.info("Ensuring image cache data directory %s exists "\
                          "(and is empty)" % (cache_dir))
                 # Destroy then recreate the image cache directory
                 sh.deldir(cache_dir)
                 self.tracewriter.dirs_made(*sh.mkdirslist(cache_dir))
         if config.get('default', 'default_store') == 'file':
             file_dir = config.get('default', 'filesystem_store_datadir')
             if file_dir:
                 LOG.info(
                     "Ensuring file system store directory %s exists and is empty."
                     % (file_dir))
                 # Delete existing images
                 # and recreate the image directory
                 sh.deldir(file_dir)
                 self.tracewriter.dirs_made(*sh.mkdirslist(file_dir))
         log_filename = config.get('default', 'log_file')
         if log_filename:
             LOG.info("Ensuring log file %s exists and is empty." %
                      (log_filename))
             log_dir = sh.dirname(log_filename)
             if log_dir:
                 LOG.info("Ensuring log directory %s exists." % (log_dir))
                 self.tracewriter.dirs_made(*sh.mkdirslist(log_dir))
             # Destroy then recreate it (the log file)
             sh.unlink(log_filename)
             self.tracewriter.file_touched(sh.touch_file(log_filename))
         if config.getboolean('default', 'delayed_delete'):
             data_dir = config.get('default', 'scrubber_datadir')
             if data_dir:
                 LOG.info(
                     "Ensuring scrubber data dir %s exists and is empty." %
                     (data_dir))
                 # Destroy then recreate the scrubber data directory
                 sh.deldir(data_dir)
                 self.tracewriter.dirs_made(*sh.mkdirslist(data_dir))
     # Nothing modified so just return the original
     return contents
Пример #8
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)
Пример #9
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
Пример #10
0
 def _config_adjust_api(self, contents, fn):
     with io.BytesIO(contents) as stream:
         config = cfg.IgnoreMissingConfigParser()
         config.readfp(stream)
         img_store_dir = self._get_image_dir()
         config.set('DEFAULT', 'debug', True)
         config.set('DEFAULT', 'verbose', True)
         config.set('DEFAULT', 'default_store', 'file')
         config.set('DEFAULT', 'filesystem_store_datadir', img_store_dir)
         config.remove_option('DEFAULT', 'log_file')
         config.set('paste_deploy', 'flavor', 'keystone')
         LOG.info(
             "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)
Пример #11
0
 def _config_adjust(self, contents, name):
     if name == ROOT_CONF:
         # Use config parser and
         # then extract known configs that
         # ill need locations/directories/files made (or touched)...
         with io.BytesIO(contents) as stream:
             config = cfg.IgnoreMissingConfigParser()
             config.readfp(stream)
             log_filename = config.get('default', 'log_file')
             if log_filename:
                 LOG.info("Ensuring log file %s exists and is empty." %
                          (log_filename))
                 log_dir = sh.dirname(log_filename)
                 if log_dir:
                     LOG.info("Ensuring log directory %s exists." %
                              (log_dir))
                     self.tracewriter.dirs_made(*sh.mkdirslist(log_dir))
                 # Destroy then recreate it (the log file)
                 sh.unlink(log_filename)
                 self.tracewriter.file_touched(sh.touch_file(log_filename))
     elif name == CATALOG_CONF:
         nlines = list()
         if 'swift' in self.options:
             mp = dict()
             mp['SERVICE_HOST'] = self.cfg.get('host', 'ip')
             nlines.append("# Swift additions")
             nlines.extend(utils.param_replace_list(SWIFT_TEMPL_ADDS, mp))
             nlines.append("")
         if 'quantum' in self.options:
             mp = dict()
             mp['SERVICE_HOST'] = self.cfg.get('host', 'ip')
             nlines.append("# Quantum additions")
             nlines.extend(utils.param_replace_list(QUANTUM_TEMPL_ADDS, mp))
             nlines.append("")
         if nlines:
             nlines.insert(0, contents)
             contents = cfg.add_header(name, utils.joinlinesep(*nlines))
     return contents