def stop(self, app_name): trace_dir = self.runtime.get_option('trace_dir') if not sh.isdir(trace_dir): msg = "No trace directory found from which to stop: %s" % (app_name) raise excp.StopException(msg) with sh.Rooted(True): fn_name = FORK_TEMPL % (app_name) (pid_file, stderr_fn, stdout_fn) = self._form_file_names(fn_name) pid = self._extract_pid(pid_file) if not pid: msg = "Could not extract a valid pid from %s" % (pid_file) raise excp.StopException(msg) (killed, attempts) = sh.kill(pid) # Trash the files if it worked if killed: LOG.debug("Killed pid %s after %s attempts." % (pid, attempts)) LOG.debug("Removing pid file %s" % (pid_file)) sh.unlink(pid_file) LOG.debug("Removing stderr file %r" % (stderr_fn)) sh.unlink(stderr_fn) LOG.debug("Removing stdout file %r" % (stdout_fn)) sh.unlink(stdout_fn) trace_fn = tr.trace_filename(trace_dir, fn_name) if sh.isfile(trace_fn): LOG.debug("Removing %r trace file %r" % (app_name, trace_fn)) sh.unlink(trace_fn) else: msg = "Could not stop %r after %s attempts" % (app_name, attempts) raise excp.StopException(msg)
def __init__(self, distro, root_dir, instances, opts=None): self.distro = distro self.root_dir = root_dir self.instances = instances self.opts = opts or {} # Various paths we will use while operating self.deps_dir = sh.joinpths(self.root_dir, "deps") self.downloaded_flag_file = sh.joinpths(self.deps_dir, "pip-downloaded") self.download_dir = sh.joinpths(self.deps_dir, "download") self.log_dir = sh.joinpths(self.deps_dir, "output") self.gathered_requires_filename = sh.joinpths(self.deps_dir, "pip-requires") self.forced_requires_filename = sh.joinpths(self.deps_dir, "forced-requires") self.download_requires_filename = sh.joinpths(self.deps_dir, "download-requires") # Executables we require to operate self.multipip_executable = sh.which("multipip", ["tools/"]) self.pip_executable = sh.which_first(['pip-python', 'pip']) self.pipdownload_executable = sh.which("pip-download", ["tools/"]) # List of requirements self.pips_to_install = [] self.forced_packages = [] # Instances to there app directory (with a setup.py inside) self.package_dirs = self._get_package_dirs(instances) # Instantiate this as late as we can. self._python_names = None # Track what file we create so they can be cleaned up on uninstall. trace_fn = tr.trace_filename(self.root_dir, 'deps') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) self.tracereader = tr.TraceReader(trace_fn) self.requirements = {} for key in ("build-requires", "requires", "conflicts"): req_set = set() for inst in self.instances: req_set |= set(pkg["name"] for pkg in inst.get_option(key) or []) self.requirements[key] = req_set
def __init__(self, distro, root_dir, instances, opts=None): self.distro = distro self.root_dir = root_dir self.instances = instances self.opts = opts or {} self.deps_dir = sh.joinpths(self.root_dir, "deps") self.download_dir = sh.joinpths(self.deps_dir, "download") self.log_dir = sh.joinpths(self.deps_dir, "output") self.gathered_requires_filename = sh.joinpths( self.deps_dir, "pip-requires") self.forced_requires_filename = sh.joinpths( self.deps_dir, "forced-requires") self.pip_executable = str(self.distro.get_command_config('pip')) # list of requirement strings self.pips_to_install = [] self.forced_packages = [] self.package_dirs = self._get_package_dirs(instances) # Instantiate this as late as we can. self._python_names = None # Track what file we create so they can be cleaned up on uninstall. trace_fn = tr.trace_filename(self.root_dir, 'deps') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) self.tracereader = tr.TraceReader(trace_fn) self.requirements = {} for key in ("build-requires", "requires", "conflicts"): req_set = set() for inst in self.instances: req_set |= set(pkg["name"] for pkg in inst.get_option(key) or []) self.requirements[key] = req_set
def __init__(self, *args, **kargs): comp.Component.__init__(self, *args, **kargs) trace_fn = tr.trace_filename(self.get_option('trace_dir'), 'created') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) self.package_dir = sh.joinpths(self.get_option('component_dir'), 'package') self.match_installed = tu.make_bool(kargs.get('match_installed')) self._build_paths = None self._details = None
def __init__(self, *args, **kwargs): comp.Component.__init__(self, *args, **kwargs) self.tracewriter = tr.TraceWriter(tr.trace_filename(self.get_option('trace_dir'), 'created'), break_if_there=False) self.package_dir = sh.joinpths(self.get_option('component_dir'), 'package') self.match_installed = tu.make_bool(kwargs.get('match_installed')) self._build_paths = None self._details = None self._helper = yum_helper.Helper()
def __init__(self, *args, **kwargs): comp.Component.__init__(self, *args, **kwargs) self.tracewriter = tr.TraceWriter( tr.trace_filename(self.get_option("trace_dir"), "created"), break_if_there=False ) self.package_dir = sh.joinpths(self.get_option("component_dir"), "package") self.match_installed = tu.make_bool(kwargs.get("match_installed")) self._build_paths = None self._details = None self._helper = yum_helper.Helper()
def __init__(self, distro, root_dir, instances): super(YumDependencyHandler, self).__init__(distro, root_dir, instances) self.rpmbuild_dir = sh.joinpths(self.deps_dir, "rpmbuild") self.deps_repo_dir = sh.joinpths(self.deps_dir, "openstack-deps") self.deps_src_repo_dir = sh.joinpths(self.deps_dir, "openstack-deps-sources") self.anvil_repo_filename = sh.joinpths(self.deps_dir, self.REPO_FN) # Track what file we create so they can be cleaned up on uninstall. trace_fn = tr.trace_filename(root_dir, 'deps') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) self.tracereader = tr.TraceReader(trace_fn) self.helper = yum_helper.Helper()
def _form_file_names(self, app_name): # Form all files names which should be connected to the given forked application name fork_fn = FORK_TEMPL % (app_name) trace_dir = self.runtime.get_option('trace_dir') trace_fn = None if trace_dir: trace_fn = tr.trace_filename(trace_dir, fork_fn) base_fork_fn = sh.joinpths(trace_dir, fork_fn) return ForkFiles(pid=base_fork_fn + ".pid", stdout=base_fork_fn + ".stdout", stderr=base_fork_fn + ".stderr", trace=trace_fn)
def __init__(self, distro, root_dir, instances, opts, group, prior_groups): self.distro = distro self.root_dir = root_dir self.instances = instances self.prior_groups = prior_groups self.opts = opts or {} self.group = group self.retries = max(0, int(opts.get('pip_retries', self.RETRIES))) self.retry_delay = max( 0, float(opts.get('pip_retry_delay', self.RETRY_DELAY))) # Various paths we will use while operating self.deps_dir = sh.joinpths(self.root_dir, "deps") self.download_dir = sh.joinpths(self.deps_dir, "download") self.log_dir = sh.joinpths(self.deps_dir, "output") sh.mkdir(self.log_dir, recurse=True) self.gathered_requires_filename = sh.joinpths( self.deps_dir, "pip-requires-group-%s" % group) self.forced_requires_filename = sh.joinpths( self.deps_dir, "forced-requires-group-%s" % group) self.download_requires_filename = sh.joinpths( self.deps_dir, "download-requires-group-%s" % group) self.multipip = multipip_helper.Helper() # List of requirements self.pips_to_install = [] self.forced_pips = [] # Instances to there app directory (with a setup.py inside) self.package_dirs = self._get_package_dirs(instances) # Track what file we create so they can be cleaned up on uninstall. trace_fn = tr.trace_filename(self.root_dir, 'deps') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) self.tracereader = tr.TraceReader(trace_fn) self.requirements = {} for key in ("build-requires", "requires", "conflicts"): req_set = set() for inst in self.instances: req_set |= set(pkg["name"] for pkg in inst.get_option(key) or []) self.requirements[key] = req_set ignore_pips = set() ignore_distro_pips = self.distro.get_dependency_config( "ignoreable_pips", quiet=True) if ignore_distro_pips: ignore_pips.update(ignore_distro_pips) self.ignore_pips = ignore_pips
def __init__(self, distro, root_dir, instances, opts): self.distro = distro self.root_dir = root_dir self.instances = instances self.opts = opts or {} # Various paths we will use while operating self.deps_dir = sh.joinpths(self.root_dir, "deps") self.downloaded_flag_file = sh.joinpths(self.deps_dir, "pip-downloaded") self.download_dir = sh.joinpths(self.deps_dir, "download") self.log_dir = sh.joinpths(self.deps_dir, "output") sh.mkdir(self.log_dir, recurse=True) self.gathered_requires_filename = sh.joinpths(self.deps_dir, "pip-requires") self.forced_requires_filename = sh.joinpths(self.deps_dir, "forced-requires") self.download_requires_filename = sh.joinpths(self.deps_dir, "download-requires") self.multipip = multipip_helper.Helper() # List of requirements self.pips_to_install = [] self.forced_packages = [] # Instances to there app directory (with a setup.py inside) self.package_dirs = self._get_package_dirs(instances) # Track what file we create so they can be cleaned up on uninstall. trace_fn = tr.trace_filename(self.root_dir, 'deps') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) self.tracereader = tr.TraceReader(trace_fn) self.requirements = {} for key in ("build-requires", "requires", "conflicts"): req_set = set() for inst in self.instances: req_set |= set(pkg["name"] for pkg in inst.get_option(key) or []) self.requirements[key] = req_set # These pip names we will ignore from being converted/analyzed... ignore_pips = self.distro.get_dependency_config("ignoreable_pips", quiet=True) if not ignore_pips: self.ignore_pips = set() else: self.ignore_pips = set(ignore_pips)
def __init__(self, distro, root_dir, instances, opts, group, prior_groups): self.distro = distro self.root_dir = root_dir self.instances = instances self.prior_groups = prior_groups self.opts = opts or {} self.group = group self.retries = max(0, int(opts.get('pip_retries', self.RETRIES))) self.retry_delay = max(0, float(opts.get('pip_retry_delay', self.RETRY_DELAY))) # Various paths we will use while operating self.deps_dir = sh.joinpths(self.root_dir, "deps") self.download_dir = sh.joinpths(self.deps_dir, "download") self.log_dir = sh.joinpths(self.deps_dir, "output") sh.mkdir(self.log_dir, recurse=True) self.gathered_requires_filename = sh.joinpths(self.deps_dir, "pip-requires-group-%s" % group) self.forced_requires_filename = sh.joinpths(self.deps_dir, "forced-requires-group-%s" % group) self.download_requires_filename = sh.joinpths(self.deps_dir, "download-requires-group-%s" % group) self.multipip = multipip_helper.Helper() # List of requirements self.pips_to_install = [] self.forced_pips = [] # Instances to there app directory (with a setup.py inside) self.package_dirs = self._get_package_dirs(instances) # Track what file we create so they can be cleaned up on uninstall. trace_fn = tr.trace_filename(self.root_dir, 'deps') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) self.tracereader = tr.TraceReader(trace_fn) self.requirements = {} for key in ("build-requires", "requires", "conflicts"): req_set = set() for inst in self.instances: req_set |= set(pkg["name"] for pkg in inst.get_option(key) or []) self.requirements[key] = req_set ignore_pips = set() ignore_distro_pips = self.distro.get_dependency_config("ignoreable_pips", quiet=True) if ignore_distro_pips: ignore_pips.update(ignore_distro_pips) self.ignore_pips = ignore_pips
def __init__(self, *args, **kargs): component.Component.__init__(self, *args, **kargs) trace_fn = tr.trace_filename(self.get_option("trace_dir"), "created") self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False)
def __init__(self, *args, **kargs): component.Component.__init__(self, *args, **kargs) trace_fn = tr.trace_filename(self.get_option("trace_dir"), "created") self.tracereader = tr.TraceReader(trace_fn) self.purge_packages = kargs.get("purge_packages")
def __init__(self, *args, **kargs): ProgramRuntime.__init__(self, *args, **kargs) start_trace = tr.trace_filename(self.get_option("trace_dir"), "start") self.tracewriter = tr.TraceWriter(start_trace, break_if_there=True) self.tracereader = tr.TraceReader(start_trace)
def __init__(self, *args, **kargs): component.Component.__init__(self, *args, **kargs) trace_fn = tr.trace_filename(self.get_option('trace_dir'), 'created') self.tracereader = tr.TraceReader(trace_fn) self.purge_packages = kargs.get('purge_packages')
def __init__(self, *args, **kargs): ProgramRuntime.__init__(self, *args, **kargs) trace_fn = tr.trace_filename(self.get_option('trace_dir'), 'start') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=True) self.tracereader = tr.TraceReader(trace_fn)
def __init__(self, *args, **kargs): super(BasicComponent, self).__init__(*args, **kargs) trace_fn = tr.trace_filename(self.get_option('trace_dir'), 'created') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False)
def __init__(self, *args, **kargs): super(PkgUninstallComponent, self).__init__(*args, **kargs) trace_fn = tr.trace_filename(self.get_option('trace_dir'), 'created') self.tracereader = tr.TraceReader(trace_fn)
def __init__(self, *args, **kargs): super(PkgInstallComponent, self).__init__(*args, **kargs) trace_fn = tr.trace_filename(self.get_option('trace_dir'), 'created') self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) self.configurator = conf.Configurator(self)
def _do_trace(self, fn, kvs): trace_dir = self.runtime.get_option('trace_dir') run_trace = tr.TraceWriter(tr.trace_filename(trace_dir, fn)) for (k, v) in kvs.items(): run_trace.trace(k, v) return run_trace.filename()