More fixups for action orderings.

This commit is contained in:
Joshua Harlow 2012-02-27 15:48:02 -08:00
parent 9249441708
commit 3a0fb5963e
2 changed files with 22 additions and 20 deletions

View File

@ -24,21 +24,10 @@ from devstack import settings
from devstack import shell as sh from devstack import shell as sh
from devstack import utils from devstack import utils
from devstack.packaging import apt
from devstack.packaging import yum
from devstack.progs import common from devstack.progs import common
LOG = logging.getLogger("devstack.progs.actions") 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 # This is used to map an action to a useful string for
# the welcome display # the welcome display
_WELCOME_MAP = { _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): def _pre_run(action_name, root_dir, pkg_manager, config, component_order, all_instances):
loaded_env = False loaded_env = False
try: try:
@ -238,8 +219,8 @@ def _gen_localrc(config, fn):
def _run_components(action_name, component_order, components, distro, root_dir, program_args): 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("Will run action [%s] using root directory [%s]" % (action_name, root_dir))
LOG.info("In the following order: %s" % ("->".join(component_order))) 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() 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) 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) _pre_run(action_name, root_dir, pkg_manager, config, component_order, all_instances)
LOG.info("Activating components required to complete action %s." % (action_name)) LOG.info("Activating components required to complete action %s." % (action_name))

View File

@ -36,6 +36,9 @@ from devstack.components import quantum_client
from devstack.components import rabbit from devstack.components import rabbit
from devstack.components import swift from devstack.components import swift
from devstack.packaging import apt
from devstack.packaging import yum
# This determines what classes to use to install/uninstall/... # This determines what classes to use to install/uninstall/...
ACTION_CLASSES = { ACTION_CLASSES = {
settings.INSTALL: { settings.INSTALL: {
@ -88,10 +91,20 @@ ACTION_CLASSES = {
}, },
} }
# Just a copy
ACTION_CLASSES[settings.STOP] = ACTION_CLASSES[settings.START] ACTION_CLASSES[settings.STOP] = ACTION_CLASSES[settings.START]
# Used only for figuring out deps
_FAKE_ROOT_DIR = tempfile.gettempdir() _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 get_default_components(distro):
def_components = dict() def_components = dict()
@ -134,6 +147,14 @@ def get_action_cls(action_name, component_name, distro):
return cls 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(): def get_config():
cfg_fn = sh.canon_path(settings.STACK_CONFIG_LOCATION) cfg_fn = sh.canon_path(settings.STACK_CONFIG_LOCATION)
config_instance = cfg.StackConfigParser() config_instance = cfg.StackConfigParser()