From 3a0fb5963ed99e55d5669fc98a95577609a379a2 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 27 Feb 2012 15:48:02 -0800 Subject: [PATCH] More fixups for action orderings. --- devstack/progs/actions.py | 21 +-------------------- devstack/progs/common.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/devstack/progs/actions.py b/devstack/progs/actions.py index 7fdee6d3..46d131f0 100644 --- a/devstack/progs/actions.py +++ b/devstack/progs/actions.py @@ -24,21 +24,10 @@ from devstack import settings from devstack import shell as sh from devstack import utils -from devstack.packaging import apt -from devstack.packaging import yum - from devstack.progs import common LOG = logging.getLogger("devstack.progs.actions") -# This map controls which distro has -# which package management class -_PKGR_MAP = { - settings.UBUNTU11: apt.AptPackager, - settings.RHEL6: yum.YumPackager, - settings.FEDORA16: yum.YumPackager, -} - # This is used to map an action to a useful string for # the welcome display _WELCOME_MAP = { @@ -145,14 +134,6 @@ ACTION_MP = { } -def _get_pkg_manager(distro, keep_packages): - cls = _PKGR_MAP.get(distro) - if not cls: - msg = "No package manager found for distro %s!" % (distro) - raise excp.StackException(msg) - return cls(distro, keep_packages) - - def _pre_run(action_name, root_dir, pkg_manager, config, component_order, all_instances): loaded_env = False try: @@ -238,8 +219,8 @@ def _gen_localrc(config, fn): def _run_components(action_name, component_order, components, distro, root_dir, program_args): LOG.info("Will run action [%s] using root directory [%s]" % (action_name, root_dir)) LOG.info("In the following order: %s" % ("->".join(component_order))) - pkg_manager = _get_pkg_manager(distro, program_args.get('keep_packages', True)) config = common.get_config() + pkg_manager = common.get_packager(distro, program_args.get('keep_packages', True)) all_instances = _instanciate_components(action_name, components, distro, pkg_manager, config, root_dir) _pre_run(action_name, root_dir, pkg_manager, config, component_order, all_instances) LOG.info("Activating components required to complete action %s." % (action_name)) diff --git a/devstack/progs/common.py b/devstack/progs/common.py index f3fc92c8..308a6973 100644 --- a/devstack/progs/common.py +++ b/devstack/progs/common.py @@ -36,6 +36,9 @@ from devstack.components import quantum_client from devstack.components import rabbit from devstack.components import swift +from devstack.packaging import apt +from devstack.packaging import yum + # This determines what classes to use to install/uninstall/... ACTION_CLASSES = { settings.INSTALL: { @@ -88,10 +91,20 @@ ACTION_CLASSES = { }, } +# Just a copy ACTION_CLASSES[settings.STOP] = ACTION_CLASSES[settings.START] +# Used only for figuring out deps _FAKE_ROOT_DIR = tempfile.gettempdir() +# This map controls which distro has +# which package management class +_PKGR_MAP = { + settings.UBUNTU11: apt.AptPackager, + settings.RHEL6: yum.YumPackager, + settings.FEDORA16: yum.YumPackager, +} + def get_default_components(distro): def_components = dict() @@ -134,6 +147,14 @@ def get_action_cls(action_name, component_name, distro): return cls +def get_packager(distro, keep_packages): + cls = _PKGR_MAP.get(distro) + if not cls: + msg = "No package manager found for distro %s!" % (distro) + raise excp.StackException(msg) + return cls(distro, keep_packages) + + def get_config(): cfg_fn = sh.canon_path(settings.STACK_CONFIG_LOCATION) config_instance = cfg.StackConfigParser()