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
def _generate_nova_conf(self): conf_fn = self._get_target_config_name(API_CONF) LOG.info("Generating dynamic content for nova: %r" % (conf_fn)) nova_conf_contents = self.conf_maker.configure() self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(conf_fn))) self.tracewriter.cfg_file_written( sh.write_file(conf_fn, nova_conf_contents))
def _do_socketdir_init(self, socketdir, perm): LOG.debug("Making screen socket directory [%s] (with permissions %o)" % (socketdir, perm)) with sh.Rooted(ROOT_GO): dirs = sh.mkdirslist(socketdir) for d in dirs: sh.chmod(d, perm)
def _configure_instances_path(self, instances_path, nova_conf): nova_conf.add('instances_path', instances_path) LOG.debug("Attempting to create instance directory: %s" % (instances_path)) self.tracewriter.dirs_made(*sh.mkdirslist(instances_path)) LOG.debug("Adjusting permissions of instance directory: %s" % (instances_path)) sh.chmod(instances_path, 0777)
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
def _create_nodes(self): for i in range(1, 5): self.tracewriter.dirs_made(sh.mkdirslist(sh.joinpths(self.fs_dev, '%d/node' % i))) link_tgt = sh.joinpths(self.datadir, str(i)) sh.symlink(sh.joinpths(self.fs_dev, str(i)), link_tgt) self.tracewriter.symlink_made(link_tgt) start_port = (6010 + (i - 1) * 5) self._create_node_config(i, start_port) self._delete_templates()
def _start(self): if self.started: return else: trace_dirs = sh.mkdirslist(sh.dirname(self.trace_fn)) sh.touch_file(self.trace_fn) self.trace(TRACE_VERSION, str(TRACE_VER)) self.started = True self.dirs_made(*trace_dirs)
def _fix_quantum(self): if not (utils.service_enabled(settings.QUANTUM_CLIENT, self.instances, False)): #make the fake quantum (apparently needed so imports don't fail???) #TODO remove this... quantum_dir = sh.joinpths(self.dash_dir, 'quantum') if not sh.isdir(quantum_dir): self.tracewriter.dirs_made(*sh.mkdirslist(quantum_dir)) for fn in FAKE_QUANTUM_FILES: self.tracewriter.file_touched(sh.touch_file(sh.joinpths(quantum_dir, fn)))
def _generate_nova_conf(self): LOG.info("Generating dynamic content for nova configuration (%s)." % (API_CONF)) conf_gen = NovaConfConfigurator(self) nova_conf_contents = conf_gen.configure() conf_fn = self._get_target_config_name(API_CONF) LOG.info("Writing nova configuration to %s" % (conf_fn)) LOG.debug(nova_conf_contents) self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(conf_fn))) self.tracewriter.cfg_file_written(sh.write_file(conf_fn, nova_conf_contents))
def _create_nodes(self): for i in range(1, 5): self.tracewriter.dirs_made( sh.mkdirslist(sh.joinpths(self.fs_dev, '%d/node' % i))) link_tgt = sh.joinpths(self.datadir, str(i)) sh.symlink(sh.joinpths(self.fs_dev, str(i)), link_tgt) self.tracewriter.symlink_made(link_tgt) start_port = (6010 + (i - 1) * 5) self._create_node_config(i, start_port) self._delete_templates()
def _gitdownload(storewhere, uri, branch=None): dirsmade = sh.mkdirslist(storewhere) LOG.info("Downloading from %s to %s" % (uri, storewhere)) cmd = ["git", "clone"] + [uri, storewhere] sh.execute(*cmd) if branch and branch != GIT_MASTER_BRANCH: LOG.info("Adjusting git branch to %s" % (branch)) cmd = ['git', 'checkout'] + [branch] sh.execute(*cmd, cwd=storewhere) return dirsmade
def _generate_nova_conf(self): LOG.info("Generating dynamic content for nova configuration (%s)." % (API_CONF)) conf_gen = NovaConfConfigurator(self) nova_conf_contents = conf_gen.configure() conf_fn = self._get_target_config_name(API_CONF) LOG.info("Writing nova configuration to %s" % (conf_fn)) LOG.debug(nova_conf_contents) self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(conf_fn))) self.tracewriter.cfg_file_written( sh.write_file(conf_fn, nova_conf_contents))
def _start(self): if self.started: return else: dirs = sh.mkdirslist(self.root) self.filename = touch_trace(self.root, self.name) self.tracer = Trace(self.filename) self.tracer.trace(TRACE_VERSION, str(TRACE_VER)) if dirs: for d in dirs: self.tracer.trace(DIR_MADE, d) self.started = True
def configure(self): configs_made = nova.NovaInstaller.configure(self) driver_canon = nova.canon_virt_driver(self.cfg.get("nova", "virt_driver")) if driver_canon == "libvirt": (fn, contents) = self._get_policy(self._get_policy_users()) dirs_made = list() with sh.Rooted(True): # TODO check if this dir is restricted before assuming it isn't? dirs_made.extend(sh.mkdirslist(sh.dirname(fn))) sh.write_file(fn, contents) self.tracewriter.cfg_file_written(fn) self.tracewriter.dirs_made(*dirs_made) configs_made += 1 return configs_made
def configure(self): configs_made = comp.PythonInstallComponent.configure(self) self._generate_nova_conf() configs_made += 1 # TODO: maybe this should be a subclass that handles these differences driver_canon = _canon_virt_driver(self.cfg.get('nova', 'virt_driver')) if (self.distro in POLICY_DISTROS) and driver_canon == virsh.VIRT_TYPE: with sh.Rooted(True): dirsmade = sh.mkdirslist(sh.dirname(LIBVIRT_POLICY_FN)) sh.write_file(LIBVIRT_POLICY_FN, LIBVIRT_POLICY_CONTENTS) self.tracewriter.dir_made(*dirsmade) self.tracewriter.cfg_write(LIBVIRT_POLICY_FN) configs_made += 1 return configs_made
def configure(self): configs_made = nova.NovaInstaller.configure(self) driver_canon = nova.canon_virt_driver(self.cfg.get('nova', 'virt_driver')) if driver_canon == 'libvirt': (fn, contents) = self._get_policy(self._get_policy_users()) dirs_made = list() with sh.Rooted(True): # TODO check if this dir is restricted before assuming it isn't? dirs_made.extend(sh.mkdirslist(sh.dirname(fn))) sh.write_file(fn, contents) self.tracewriter.cfg_file_written(fn) self.tracewriter.dirs_made(*dirs_made) configs_made += 1 return configs_made
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)
def download(self): dirsmade = list() if sh.isdir(self.store_where): LOG.info("Existing directory located at %r, leaving it alone." % (self.store_where)) else: LOG.info("Downloading %r to %r" % (self.uri, self.store_where)) dirsmade.extend(sh.mkdirslist(self.store_where)) cmd = list(self.distro.get_command('git', 'clone')) cmd += [self.uri, self.store_where] sh.execute(*cmd) if self.branch and self.branch != GIT_MASTER_BRANCH: LOG.info("Adjusting branch to %r" % (self.branch)) cmd = list(self.distro.get_command('git', 'checkout')) cmd += [self.branch] sh.execute(*cmd, cwd=self.store_where) return dirsmade
def configure(self): configs_made = comp.PythonInstallComponent.configure(self) self._generate_nova_conf() configs_made += 1 driver_canon = _canon_virt_driver(self.cfg.get('nova', 'virt_driver')) # TODO maybe move this?? if driver_canon == 'libvirt' and self.distro.get_command('virt-policy', quiet=True): (fn, contents) = self.distro.get_command('virt-policy') dirs_made = list() with sh.Rooted(True): dirs_made = sh.mkdirslist(sh.dirname(fn)) sh.write_file(fn, contents) self.tracewriter.dirs_made(*dirs_made) self.tracewriter.cfg_file_written(fn) configs_made += 1 return configs_made
def _configure_files(self): config_fns = self._get_config_files() if config_fns: utils.log_iterable(config_fns, logger=LOG, header="Configuring %s files" % (len(config_fns))) for fn in config_fns: tgt_fn = self._get_target_config_name(fn) self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(tgt_fn))) LOG.info("Configuring file %r", fn) (source_fn, contents) = self._get_source_config(fn) LOG.debug("Replacing parameters in file %r", source_fn) contents = self._config_param_replace(fn, contents, self._get_param_map(fn)) LOG.debug("Applying final adjustments in file %r", source_fn) contents = self._config_adjust(contents, fn) LOG.info("Writing configuration file %r => %r", source_fn, tgt_fn) self.tracewriter.cfg_file_written(sh.write_file(tgt_fn, contents)) return len(config_fns)
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)
def _install_python_setups(self): pydirs = self._get_python_directories() if pydirs: LOG.info("Setting up %s python directories (%s)", len(pydirs), pydirs) for (name, wkdir) in pydirs.items(): working_dir = wkdir or self.app_dir self.tracewriter.dirs_made(*sh.mkdirslist(working_dir)) self.tracewriter.py_installed(name, working_dir) (stdout, stderr) = sh.execute(*PY_INSTALL, cwd=working_dir, run_as_root=True) py_trace_name = "%s-%s" % (tr.PY_TRACE, name) py_writer = tr.TraceWriter(tr.trace_fn(self.trace_dir, py_trace_name)) # Format or json encoding isn't really needed here since this is # more just for information output/lookup if desired. py_writer.trace("CMD", " ".join(PY_INSTALL)) py_writer.trace("STDOUT", stdout) py_writer.trace("STDERR", stderr) self.tracewriter.file_touched(py_writer.filename())
def _configure_instances_path(self, instances_path, nova_conf): nova_conf.add('instances_path', instances_path) LOG.debug("Attempting to create instance directory: %r", instances_path) self.tracewriter.dirs_made(*sh.mkdirslist(instances_path)) LOG.debug("Adjusting permissions of instance directory: %r", instances_path) sh.chmod(instances_path, 0777) instance_parent = sh.dirname(instances_path) LOG.debug("Adjusting permissions of instance directory parent: %r", instance_parent) # In cases where you are using kvm + qemu # On certain distros (ie RHEL) this user needs to be able # To enter the parents of the instance path, if this is in /home/BLAH/ then # Without enabling the whole path, this user can't write there. This helps fix that... with sh.Rooted(True): for p in sh.explode_path(instance_parent): if not os.access(p, os.X_OK) and sh.isdir(p): # Need to be able to go into that directory sh.chmod(p, os.stat(p).st_mode | 0755)
def _gitdownload(storewhere, uri, branch=None): dirsmade = list() if sh.isdir(storewhere): LOG.info("Updating code located at [%s]" % (storewhere)) cmd = CHECKOUT_CMD + [GIT_MASTER_BRANCH] sh.execute(*cmd, cwd=storewhere) cmd = PULL_CMD sh.execute(*cmd, cwd=storewhere) else: LOG.info("Downloading from [%s] to [%s]" % (uri, storewhere)) dirsmade.extend(sh.mkdirslist(storewhere)) cmd = CLONE_CMD + [uri, storewhere] sh.execute(*cmd) if branch and branch != GIT_MASTER_BRANCH: LOG.info("Adjusting git branch to [%s]" % (branch)) cmd = CHECKOUT_CMD + [branch] sh.execute(*cmd, cwd=storewhere) return dirsmade
def _install_python_setups(self): pydirs = self._get_python_directories() if pydirs: LOG.info("Setting up %s python directories (%s)" % (len(pydirs), pydirs)) for (name, wkdir) in pydirs.items(): working_dir = wkdir or self.appdir #ensure working dir is there self.tracewriter.dirs_made(*sh.mkdirslist(working_dir)) #do this before write just incase it craps out half way through self.tracewriter.py_installed(name, working_dir) #now actually do it (stdout, stderr) = sh.execute(*PY_INSTALL, cwd=working_dir, run_as_root=True) py_trace_name = "%s-%s" % (tr.PY_TRACE, name) py_writer = tr.TraceWriter(tr.trace_fn(self.tracedir, py_trace_name)) py_writer.trace("CMD", " ".join(PY_INSTALL)) py_writer.trace("STDOUT", stdout) py_writer.trace("STDERR", stderr) self.tracewriter.file_touched(py_writer.filename())
def _configure_files(self): configs = self._get_config_files() if configs: LOG.info("Configuring %s files", len(configs)) for fn in configs: parameters = self._get_param_map(fn) tgt_fn = self._get_target_config_name(fn) self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(tgt_fn))) LOG.info("Configuring file %s", fn) (source_fn, contents) = self._get_source_config(fn) LOG.debug("Replacing parameters in file %s", source_fn) LOG.debug("Replacements = %s", parameters) contents = utils.param_replace(contents, parameters) LOG.debug("Applying side-effects of param replacement for template %s", source_fn) contents = self._config_adjust(contents, fn) LOG.info("Writing configuration file %s", tgt_fn) self.tracewriter.cfg_file_written(sh.write_file(tgt_fn, contents)) return len(configs)
def _configure_files(self): configs = self._get_config_files() if configs: LOG.info("Configuring %s files", len(configs)) for fn in configs: parameters = self._get_param_map(fn) tgt_fn = self._get_target_config_name(fn) self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(tgt_fn))) LOG.info("Configuring file %s", fn) (source_fn, contents) = self._get_source_config(fn) LOG.debug("Replacing parameters in file %s", source_fn) LOG.debug("Replacements = %s", parameters) contents = utils.param_replace(contents, parameters) LOG.debug( "Applying side-effects of param replacement for template %s", source_fn) contents = self._config_adjust(contents, fn) LOG.info("Writing configuration file %s", tgt_fn) self.tracewriter.cfg_file_written( sh.write_file(tgt_fn, contents)) return len(configs)
def _install_python_setups(self): pydirs = self._get_python_directories() if pydirs: LOG.info("Setting up %s python directories (%s)", len(pydirs), pydirs) for (name, wkdir) in pydirs.items(): working_dir = wkdir or self.app_dir self.tracewriter.dirs_made(*sh.mkdirslist(working_dir)) self.tracewriter.py_installed(name, working_dir) (stdout, stderr) = sh.execute(*PY_INSTALL, cwd=working_dir, run_as_root=True) py_trace_name = "%s-%s" % (tr.PY_TRACE, name) py_writer = tr.TraceWriter( tr.trace_fn(self.trace_dir, py_trace_name)) # Format or json encoding isn't really needed here since this is # more just for information output/lookup if desired. py_writer.trace("CMD", " ".join(PY_INSTALL)) py_writer.trace("STDOUT", stdout) py_writer.trace("STDERR", stderr) self.tracewriter.file_touched(py_writer.filename())
def download(self): dirsmade = list() if sh.isdir(self.store_where): LOG.info("Updating using git: located at %r" % (self.store_where)) cmd = list(self.distro.get_command("git", "checkout")) cmd += [GIT_MASTER_BRANCH] sh.execute(*cmd, cwd=self.store_where) cmd = self.distro.get_command("git", "pull") sh.execute(*cmd, cwd=self.store_where) else: LOG.info("Downloading using git: %r to %r" % (self.uri, self.store_where)) dirsmade.extend(sh.mkdirslist(self.store_where)) cmd = list(self.distro.get_command("git", "clone")) cmd += [self.uri, self.store_where] sh.execute(*cmd) if self.branch and self.branch != GIT_MASTER_BRANCH: LOG.info("Adjusting branch using git: %r" % (self.branch)) cmd = list(self.distro.get_command("git", "checkout")) cmd += [self.branch] sh.execute(*cmd, cwd=self.store_where) return dirsmade
def download(self): dirsmade = list() if sh.isdir(self.store_where): LOG.info("Updating using git: located at %r" % (self.store_where)) cmd = list(self.distro.get_command('git', 'checkout')) cmd += [GIT_MASTER_BRANCH] sh.execute(*cmd, cwd=self.store_where) cmd = self.distro.get_command('git', 'pull') sh.execute(*cmd, cwd=self.store_where) else: LOG.info("Downloading using git: %r to %r" % (self.uri, self.store_where)) dirsmade.extend(sh.mkdirslist(self.store_where)) cmd = list(self.distro.get_command('git', 'clone')) cmd += [self.uri, self.store_where] sh.execute(*cmd) if self.branch and self.branch != GIT_MASTER_BRANCH: LOG.info("Adjusting branch using git: %r" % (self.branch)) cmd = list(self.distro.get_command('git', 'checkout')) cmd += [self.branch] sh.execute(*cmd, cwd=self.store_where) return dirsmade
def _configure_files(self): configs = self._get_config_files() if configs: LOG.info("Configuring %s files" % (len(configs))) for fn in configs: #get the params and where it should come from and where it should go parameters = self._get_param_map(fn) tgt_fn = self._get_target_config_name(fn) #ensure directory is there (if not created previously) self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(tgt_fn))) #now configure it LOG.info("Configuring file %s" % (fn)) (source_fn, contents) = self._get_source_config(fn) LOG.debug("Replacing parameters in file %s" % (source_fn)) LOG.debug("Replacements = %s" % (parameters)) contents = utils.param_replace(contents, parameters) LOG.debug("Applying side-effects of param replacement for template %s" % (source_fn)) contents = self._config_adjust(contents, fn) LOG.info("Writing configuration file %s" % (tgt_fn)) #this trace is used to remove the files configured self.tracewriter.cfg_file_written(sh.write_file(tgt_fn, contents)) return len(configs)
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.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 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 pre_install(self): comp.PythonInstallComponent.pre_install(self) self.tracewriter.dirs_made(*sh.mkdirslist(self.log_dir))
def _setup_blackhole(self): # Create an empty directory that apache uses as docroot self.tracewriter.dirs_made( *sh.mkdirslist(sh.joinpths(self.app_dir, BLACKHOLE_DIR)))
def _setup_blackhole(self): # Create an empty directory that apache uses as docroot self.tracewriter.dirs_made(*sh.mkdirslist(sh.joinpths(self.app_dir, BLACKHOLE_DIR)))
def _create_log_dirs(self): self.tracewriter.dirs_made( *sh.mkdirslist(sh.joinpths(self.logdir, 'hourly'))) sh.symlink(sh.joinpths(self.cfg_dir, SYSLOG_CONF), SWIFT_RSYNC_LOC) self.tracewriter.symlink_made(SWIFT_RSYNC_LOC)
def make_dir(self, path): self._start() dirs = sh.mkdirslist(path) self.dir_made(*dirs) return path
def _create_log_dirs(self): self.tracewriter.dirs_made(*sh.mkdirslist(sh.joinpths(self.logdir, 'hourly'))) sh.symlink(sh.joinpths(self.cfg_dir, SYSLOG_CONF), SWIFT_RSYNC_LOC) self.tracewriter.symlink_made(SWIFT_RSYNC_LOC)
def _generate_nova_conf(self): conf_fn = self._get_target_config_name(API_CONF) LOG.info("Generating dynamic content for nova: %r" % (conf_fn)) nova_conf_contents = self.conf_maker.configure() self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(conf_fn))) self.tracewriter.cfg_file_written(sh.write_file(conf_fn, nova_conf_contents))