def start(self): # Select how we are going to start it cls = RUNNER_CLS_MAPPING[cfg_helpers.fetch_run_type(self.cfg)] instance = cls(self.cfg, self.component_name, self.trace_dir) am_started = 0 for app_info in self._get_apps_to_start(): app_name = app_info["name"] app_pth = app_info.get("path", app_name) app_dir = app_info.get("app_dir", self.app_dir) # Adjust the program options now that we have real locations program_opts = utils.param_replace_list( self._get_app_options(app_name), self._get_param_map(app_name), ) # Start it with the given settings LOG.debug("Starting [%s] with options [%s]", app_name, ", ".join(program_opts)) info_fn = instance.start( app_name, (app_pth, app_dir, program_opts), ) LOG.debug("Started [%s] details are in [%s]", app_name, info_fn) # This trace is used to locate details about what to stop self.tracewriter.started_info(app_name, info_fn) am_started += 1 return am_started
def start(self): # Select how we are going to start it cls = RUNNER_CLS_MAPPING[self._fetch_run_type()] instance = cls(self.cfg, self.component_name, self.trace_dir) am_started = 0 for app_info in self._get_apps_to_start(): app_name = app_info["name"] app_pth = app_info.get("path", app_name) app_dir = app_info.get("app_dir", self.app_dir) # Adjust the program options now that we have real locations program_opts = utils.param_replace_list( self._get_app_options(app_name), self._get_param_map(app_name), ) # Start it with the given settings LOG.debug("Starting %r with options (%s)", app_name, ", ".join(program_opts)) info_fn = instance.start(app_name, (app_pth, app_dir, program_opts), ) LOG.info("Started %r details are in %r", app_name, info_fn) # This trace is used to locate details about what to stop self.tracewriter.started_info(app_name, info_fn) am_started += 1 return am_started
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, 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
def _generate_lines(self, param_dict=None): gen_lines = list() for line_entry in self.lines: key = line_entry.get('key') opts = line_entry.get('options') if not key: continue if opts is None: key_str = self._form_key(key, False) full_line = key_str else: key_str = self._form_key(key, True) filled_opts = utils.param_replace_list(opts, param_dict) full_line = key_str + ",".join(filled_opts) gen_lines.append(full_line) return gen_lines
def configure(self): # First make a pass and make sure all runtime (e.g. upstart) config files are in place.... cls = RUNNER_CLS_MAPPING[utils.fetch_run_type(self.cfg)] instance = cls(self.cfg, self.component_name, self.tracedir) tot_am = 0 for app_info in self._get_apps_to_start(): app_name = app_info["name"] app_pth = app_info.get("path", app_name) app_dir = app_info.get("app_dir", self.appdir) # Adjust the program options now that we have real locations program_opts = utils.param_replace_list(self._get_app_options(app_name), self._get_param_map(app_name)) # Configure it with the given settings LOG.info("Configuring runner for program [%s]" % (app_name)) cfg_am = instance.configure(app_name, (app_pth, app_dir, program_opts)) LOG.info("Configured %s files for runner for program [%s]" % (cfg_am, app_name)) tot_am += cfg_am return tot_am
def configure(self): # First make a pass and make sure all runtime (e.g. upstart) # config files are in place.... cls = RUNNER_CLS_MAPPING[cfg_helpers.fetch_run_type(self.cfg)] instance = cls(self.cfg, self.component_name, self.trace_dir) tot_am = 0 for app_info in self._get_apps_to_start(): app_name = app_info["name"] app_pth = app_info.get("path", app_name) app_dir = app_info.get("app_dir", self.app_dir) # Adjust the program options now that we have real locations program_opts = utils.param_replace_list( self._get_app_options(app_name), self._get_param_map(app_name), ) # Configure it with the given settings LOG.debug("Configuring runner for program [%s]", app_name) cfg_am = instance.configure(app_name, (app_pth, app_dir, program_opts)) LOG.debug("Configured %s files for runner for program [%s]", cfg_am, app_name) tot_am += cfg_am return tot_am
def _gen_cmd(self, base_cmd, params=dict()): return utils.param_replace_list(base_cmd, params)