예제 #1
0
 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)
예제 #2
0
파일: base.py 프로젝트: skybobbi/anvil
 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
예제 #3
0
파일: base.py 프로젝트: aababilov/anvil
 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
예제 #4
0
 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
예제 #5
0
 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()
예제 #6
0
 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()
예제 #7
0
파일: yum.py 프로젝트: apugachev-gd/anvil
 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()
예제 #8
0
 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)
예제 #9
0
파일: yum.py 프로젝트: apugachev-gd/anvil
 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()
예제 #10
0
 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
예제 #11
0
 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)
예제 #12
0
파일: base.py 프로젝트: jzako/anvil
 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
예제 #13
0
 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
예제 #14
0
파일: base.py 프로젝트: AsherBond/anvil
 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)
예제 #15
0
 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)
예제 #16
0
 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")
예제 #17
0
 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)
예제 #18
0
 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')
예제 #19
0
 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)
예제 #20
0
파일: base.py 프로젝트: minacel/anvil
 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)
예제 #21
0
 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)
예제 #22
0
 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)
예제 #23
0
 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)
예제 #24
0
 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)
예제 #25
0
 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')
예제 #26
0
 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)
예제 #27
0
 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()