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 = self.cfg.get_dbdsn(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)
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)
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 = self.cfg.get_dbdsn(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
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
def _config_adjust(self, contents, config_fn): if config_fn == ROOT_CONF: newcontents = contents with io.BytesIO(contents) as stream: config = cfg.IgnoreMissingConfigParser(cs=False) config.readfp(stream) db_dsn = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True) 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
def _config_adjust_catalog(self, contents, fn): 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(fn, utils.joinlinesep(*nlines)) return contents
def _config_adjust(self, contents, config_fn): if config_fn == PASTE_CONF and settings.KEYSTONE in self.instances: newcontents = contents with io.BytesIO(contents) as stream: config = cfg.IgnoreMissingConfigParser() config.readfp(stream) mods = 0 for section in PASTE_PIPELINE_KEYSTONE_ADJUST.keys(): if config.has_section(section): section_vals = PASTE_PIPELINE_KEYSTONE_ADJUST.get(section) for (k, v) in section_vals.items(): config.set(section, k, v) mods += 1 if mods > 0: with io.BytesIO() as outputstream: config.write(outputstream) outputstream.flush() newcontents = cfg.add_header(config_fn, outputstream.getvalue()) contents = newcontents return contents
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
def _config_adjust(self, contents, name): if name == ROOT_CONF: #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) 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.make_dir(log_dir) #destroy then recreate it (the log file) sh.unlink(log_filename) sh.touch_file(log_filename) self.tracewriter.file_touched(log_filename) elif name == CATALOG_CONF: nlines = list() if utils.service_enabled(settings.SWIFT, self.instances): 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 utils.service_enabled(settings.QUANTUM, self.instances) or \ utils.service_enabled(settings.QUANTUM_CLIENT, self.instances): 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