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)
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', []) selected_modules = [] 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 modules that are implicitly required if others are present resolve.resolve_required_modules_if_other_is_present() # By default append manifests from all modules resolved through api.require() # otherwise (add_required_to_manifest=False) only append manifests from the selected_modules if args.add_required_to_manifest: modules = resolve.get_required_modules() else: modules = list(module for module in resolve.get_required_modules() if module.name in selected_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 list(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)