def __init__(self, distro, action, directory, config, pkg_manager, **kargs): self.distro = distro self.action = action self.directory = directory self.cfg = config self.pkg_manager = pkg_manager self.kargs = kargs self.components = dict() def_components = common.get_default_components() unclean_components = kargs.pop("components") if not unclean_components: self.components = def_components else: for (c, opts) in unclean_components.items(): if opts is None and c in def_components: self.components[c] = def_components[c] elif opts is None: self.components[c] = list() else: self.components[c] = opts self.force = kargs.get('force', False) self.ignore_deps = kargs.get('ignore_deps', False) self.ref_components = kargs.get("ref_components") self.rc_file = sh.abspth(settings.OSRC_FN) self.gen_rc = action in _RC_FILE_MAKE_ACTIONS
def _run_action(args): defaulted_components = False components = utils.parse_components(args.pop("components")) if not components: defaulted_components = True components = common.get_default_components() action = _clean_action(args.pop("action")) if not action: print(utils.color_text("No valid action specified!", "red")) return False rootdir = args.pop("dir") if rootdir is None: print(utils.color_text("No root directory specified!", "red")) return False #ensure os/distro is known (distro, platform) = utils.determine_distro() if distro is None: print("Unsupported platform " + utils.color_text(platform, "red") + "!") return False #start it (rep, maxlen) = utils.welcome(_WELCOME_MAP.get(action)) header = utils.center_text("Action Runner", rep, maxlen) print(header) #here on out should be using the logger if not defaulted_components: LOG.info("Activating components [%s]" % (", ".join(sorted(components.keys())))) else: LOG.info("Activating default components [%s]" % (", ".join(sorted(components.keys())))) #need to figure out dependencies for components (if any) ignore_deps = args.pop('ignore_deps', False) component_order = None if not ignore_deps: all_components_deps = common.get_components_deps(action, components) component_diff = set(all_components_deps.keys()).difference(components.keys()) if component_diff: LOG.info("Having to activate dependent components: [%s]" \ % (", ".join(sorted(component_diff)))) for new_component in component_diff: components[new_component] = list() component_order = utils.get_components_order(all_components_deps) else: component_order = components.keys() #reverse them so that we stop in the reverse order #and that we uninstall in the reverse order which seems to make sense if action in _REVERSE_ACTIONS: component_order.reverse() #add in any that will just be referenced but which will not actually do anything (ie the action will not be applied to these) ref_components = utils.parse_components(args.pop("ref_components")) for c in ref_components.keys(): if c not in components: components[c] = ref_components.get(c) #now do it! LOG.info("Starting action [%s] on %s for distro [%s]" % (action, date.rcf8222date(), distro)) _run_components(action, component_order, components, distro, rootdir, args) LOG.info("Finished action [%s] on %s" % (action, date.rcf8222date())) return True
import objgraph import inspect import sys import os possible_topdir = os.path.normpath( os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)) sys.path.insert(0, possible_topdir) from devstack import settings from devstack.progs import common distro = settings.RHEL6 comps = common.get_default_components() def filter_c(c): if not inspect.isclass(c): return False if c is object: return False return True actions = settings.ACTIONS for action in actions: klss = list() for c in comps.keys(): kls = common.get_action_cls(action, c, distro) klss.append(kls)