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
def _inject_references(self, components): ref_components = utils.parse_components(self.ref_components) adjusted_components = dict(components) for c in ref_components.keys(): if c not in components: adjusted_components[c] = ref_components.get(c) return adjusted_components