Skip to content
Snippets Groups Projects
Commit 0a863192 authored by Nadav Har'El's avatar Nadav Har'El Committed by Pekka Enberg
Browse files

build: convenient shortcut for image with several modules


A previous patch made it possible to run "make image=rogue" when a
module rogue exists, without creating a images/rogue file.

This patch expands this feature to be even more powerful:

First, it allows choosing alternative command lines of a particular
module. For example:

        make image=mgmt.shell

Creates an image with the mgmt module (and its dependencies), and its
command line will be mgmt's "shell" command line (i.e., run just the
shell without the web server) instead of the "default" command line.

Second, instead of specifying just one module to put in the image (plus its
dependencies), we now allow giving a comma-separated list of unrelated
modules, all of which are put in the image. For example:

        make image=memcached,netperf,tests

The default command line of the image will be to run in parallel the
"default" command line of each of the modules, if it exists. In the above
example, the "tests" module has no command line labeled "default", so only
those of memcached and netperf will run, but tests' files will still be
included in the image.

As above, a non-default command line of the module can also be chosen,
for example:

        make image=memcached,mgmt.shell

Will build an image with the memcached and mgmt modules, and will run
in parallel memcached's "default" command line and mgmt's "shell"
command line.

If you want to include some module's files in the image, but not run
its command line, use the special word "none". For example:

        make image=memcached,netperf.none

will create an image with both memcached and netperf's files, but only
run memcached's command line.

Reviewed-by: default avatarTomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent a30c58f7
No related branches found
No related tags found
No related merge requests found
......@@ -133,8 +133,23 @@ if __name__ == "__main__":
config = resolve.local_import(image_config_file)
run_list = config.get('run', [])
else:
print "No such image configuration: " + args.image_config + ". Trying module with this name"
run_list = api.require(args.image_config).default;
# 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)
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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment