示例#1
0
def _run_action(args):
    defaulted_components = False
    components = settings.parse_components(args.pop("components"))
    if not components:
        defaulted_components = True
        components = _get_def_components()
    action = _clean_action(args.pop("action"))
    if not action:
        cprint("No valid action specified!", "red")
        return False
    rootdir = args.pop("dir")
    if rootdir is None:
        cprint("No root directory specified!", "red")
        return False
    #ensure os/distro is known
    (distro, platform) = utils.determine_distro()
    if distro is None:
        print("Unsupported platform " + colored(platform, "red") + "!")
        return False
    #start it
    (rep, maxlen) = utils.welcome(_WELCOME_MAP.get(action))
    header = utils.center_text("Action Runner", rep, maxlen)
    print(header)
    #need to figure out dependencies for components (if any)
    ignore_deps = args.pop('ignore_deps', False)
    if not defaulted_components:
        LOG.info("Activating components [%s]" % (", ".join(sorted(components.keys()))))
    else:
        LOG.info("Activating default components [%s]" % (", ".join(sorted(components.keys()))))
    if not ignore_deps:
        new_components = settings.resolve_dependencies(components.keys())
        component_diff = new_components.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_skips = _check_roots(action, rootdir, components.keys())
    for c in component_skips:
        components.pop(c)
    if not components:
        LOG.error("After checking the various components roots, no components ended up being specified!")
        return False
    #get the right component order (by priority)
    component_order = settings.prioritize_components(components.keys())
    if action in _REVERSE_ACTIONS:
        #reverse them so that we stop in the reverse order
        #and that we uninstall in the reverse order which seems to make sense
        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 = settings.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))
    results = _run_components(action, component_order, components, distro, rootdir, args)
    LOG.info("Finished action [%s] on %s" % (action, date.rcf8222date()))
    if results:
        LOG.info('Check [%s] for traces of what happened.' % ", ".join(results))
    return True
示例#2
0
def _run_describe_comps(args):
    components = settings.parse_components(args.get("components"), True)
    c_keys = sorted(components.keys())
    for c in c_keys:
        print("Name: " + colored(c, "green", attrs=['bold']) + "")
        describer = _DESCR_MAP.get(c)
        print(describer(components.get(c)))
示例#3
0
def _run_list_deps(args):
    components = settings.parse_components(args.get("components"), True).keys()
    components = sorted(components)
    components.reverse()
    return log_deps(components)