Exemple #1
0
def build(args):
    add_default = True
    if args.image_config[0] == "!":
        add_default = False
        args.image_config = args.image_config[1:]
    image_config_file = os.path.join(image_configs_dir,
                                     args.image_config + '.py')
    if os.path.exists(image_config_file):
        print("Using image config: %s" % image_config_file)
        config = resolve.local_import(image_config_file)
        run_list = config.get('run', [])
    else:
        # If images/image_config doesn't exist, assume image_config is a
        # comma-separated list of module names, and build an image from those
        # modules (and their dependencies). The command line to run is to
        # run each of the module's "default" command line, in parallel.
        # You can choose a module's non-default command line, with a dot,
        # e.g.: mgmt.shell use's mgmt's "shell" command line.
        print("No such image configuration: " + args.image_config +
              ". Assuming list of modules.")
        run_list = []
        disabled_modules = set()
        for module in args.image_config.split(","):
            if module[0] == '-':
                disabled_modules.add(module[1:])
        module_names = []
        config = resolve.read_config()
        if add_default and "default" in config:
            module_names += config["default"]
        module_names += args.image_config.split(",")
        for missing in list(disabled_modules - set(module_names)):
            raise Exception("Attempt to disable module %s but not enabled" %
                            missing)
        module_names = [i for i in module_names if not i in disabled_modules]
        for module in module_names:
            if module[0] == '-':
                continue
            a = module.split(".", 1)
            name = a[0]
            variant = a[1] if (len(a) > 1) else "default"
            mod = api.require(name)
            if hasattr(mod, variant):
                run_list.append(getattr(mod, variant))
            elif variant != "default" and variant != "none":
                raise Exception("Attribute %s not set in module %s" %
                                (variant, name))

    modules = resolve.get_required_modules()

    print("Modules:")
    if not modules:
        print("  None")
    for module in modules:
        print("  " + module.name)

    make_modules(modules, args)

    apps_to_run = get_basic_apps(run_list)
    generate_manifests(modules, apps_to_run)
    generate_cmdline(apps_to_run)
Exemple #2
0
def build(args):
    add_default = True
    if args.image_config[0] == "!":
        add_default = False
        args.image_config = args.image_config[1:]
    image_config_file = os.path.join(image_configs_dir, args.image_config + '.py')
    if os.path.exists(image_config_file):
        print("Using image config: %s" % image_config_file)
        config = resolve.local_import(image_config_file)
        run_list = config.get('run', [])
    else:
        # If images/image_config doesn't exist, assume image_config is a
        # comma-separated list of module names, and build an image from those
        # modules (and their dependencies). The command line to run is to
        # run each of the module's "default" command line, in parallel.
        # You can choose a module's non-default command line, with a dot,
        # e.g.: mgmt.shell use's mgmt's "shell" command line.
        print("No such image configuration: " + args.image_config + ". Assuming list of modules.")
        run_list = []
        disabled_modules = set()
        for module in args.image_config.split(","):
            if module[0] == '-':
                disabled_modules.add(module[1:])
        module_names = []
        config = resolve.read_config()
        if add_default and "default" in config:
            module_names +=  config["default"]
        module_names += args.image_config.split(",")
        for missing in list(disabled_modules - set(module_names)):
            raise Exception("Attempt to disable module %s but not enabled" % missing)
        module_names = [i for i in module_names if not i in disabled_modules]
        for module in module_names:
            if module[0] == '-':
                continue
            a = module.split(".", 1)
            name = a[0]
            variant = a[1] if (len(a) > 1) else "default"
            mod = api.require(name)
            if hasattr(mod, variant):
                run_list.append(getattr(mod, variant))
            elif variant != "default" and variant != "none":
                raise Exception("Attribute %s not set in module %s" % (variant, name))

    modules = resolve.get_required_modules()

    print("Modules:")
    if not modules:
        print("  None")
    for module in modules:
        print("  " + module.name)

    make_modules(modules, args)

    apps_to_run = get_basic_apps(run_list)
    generate_manifests(modules, apps_to_run)
    generate_cmdline(apps_to_run)
Exemple #3
0
    parser.add_argument(
        "-c",
        "--image-config",
        action="store",
        default="default",
        help="image configuration name. Looked up in " + image_configs_dir,
    )
    args = parser.parse_args()

    image_config_file = os.path.join(image_configs_dir, args.image_config + ".py")
    if not os.path.exists(image_config_file):
        print "No such image configuration: " + args.image_config
        sys.exit(1)

    print "Using image config: %s" % image_config_file
    config = resolve.local_import(image_config_file)
    modules = resolve.get_required_modules()

    print "Modules:"
    if not modules:
        print "  None"
    for module in modules:
        print "  " + module["name"]

    make_modules(modules)

    run_list = getattr(config, "run", [])
    apps_to_run = get_basic_apps(run_list)
    generate_manifests(modules, apps_to_run)
    generate_cmdline(apps_to_run)
Exemple #4
0
def build(args):
    add_default = True
    if args.image_config[0] == "!":
        add_default = False
        args.image_config = args.image_config[1:]
    image_config_file = os.path.join(image_configs_dir, args.image_config + '.py')
    if os.path.exists(image_config_file):
        print("Using image config: %s" % image_config_file)
        config = resolve.local_import(image_config_file)
        run_list = config.get('run', [])
    else:
        # If images/image_config doesn't exist, assume image_config is a
        # comma-separated list of module names, and build an image from those
        # modules (and their dependencies). The command line to run is to
        # run each of the module's "default" command line, in parallel.
        # You can choose a module's non-default command line, with a dot,
        # e.g.: mgmt.shell use's mgmt's "shell" command line.
        print("No such image configuration: " + args.image_config + ". Assuming list of modules.")
        run_list = []
        disabled_modules = set()
        selected_modules = args.image_config.split(",")
        for module in selected_modules:
            if module[0] == '-':
                disabled_modules.add(module[1:])
        module_names = []
        config = resolve.read_config()
        if add_default and "default" in config:
            module_names += config["default"]
        module_names += selected_modules
        module_names = [i for i in module_names if not i in disabled_modules]
        for missing in list(disabled_modules - set(module_names)):
             raise Exception("Attempt to disable module %s but not enabled" % missing)

        for module in module_names:
            if module[0] == '-':
                continue
            a = module.split(".", 1)
            name = a[0]
            if len(a) > 1:
                api.require_running(name, a[1])
            else:
                api.require_running(name)

        # Add moduless thare are implictly required if others are present
        resolve.resolve_required_modules_if_other_is_present()

    modules = resolve.get_required_modules()
    modules_to_run = resolve.get_modules_to_run()

    print("Modules:")
    if not modules:
        print("  None")
    for module in modules:
        prefix = "  " + module.name
        if module in modules_to_run:
            print(prefix + "." + modules_to_run[module])
        else:
            print(prefix)

    for module, run_config_name in modules_to_run.items():
        run_config = resolve.get_run_config(module, run_config_name)
        if run_config:
            run_list.append(run_config)

    make_modules(modules, args)

    apps_to_run = get_basic_apps(run_list)
    generate_manifests(modules, apps_to_run, args.usrskel)
    generate_cmdline(apps_to_run)
Exemple #5
0
    image_configs_dir = resolve.get_images_dir()

    parser = argparse.ArgumentParser(prog='module.py')
    parser.add_argument("-c",
                        "--image-config",
                        action="store",
                        default="default",
                        help="image configuration name. Looked up in " +
                        image_configs_dir)
    args = parser.parse_args()

    image_config_file = os.path.join(image_configs_dir,
                                     args.image_config + '.py')
    if os.path.exists(image_config_file):
        print "Using image config: %s" % image_config_file
        config = resolve.local_import(image_config_file)
        run_list = config.get('run', [])
    else:
        # If images/image_config doesn't exist, assume image_config is a
        # comma-separated list of module names, and build an image from those
        # modules (and their dependencies). The command line to run is to
        # run each of the module's "default" command line, in parallel.
        # You can choose a module's non-default command line, with a dot,
        # e.g.: mgmt.shell use's mgmt's "shell" command line.
        print "No such image configuration: " + args.image_config + ". Assuming list of modules."
        run_list = []
        for module in args.image_config.split(","):
            a = module.split(".", 1)
            name = a[0]
            variant = a[1] if (len(a) > 1) else "default"
            mod = api.require(name)