From 1e8d54478179d36e5416d7d937a58ee6fbd8c744 Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Tue, 23 May 2023 13:43:06 +0200 Subject: commandline: Add a CLI option to specify the template install image Let users bring their own base image. The reason is simple, they may need to install a bunch of packages and perform some system setup which is an expensive procedure to do every single time when booting off of the stripped down vendor provided cloud images. Signed-off-by: Erik Skultety --- lcitool/commandline.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lcitool/commandline.py b/lcitool/commandline.py index 607b32d..0b774ed 100644 --- a/lcitool/commandline.py +++ b/lcitool/commandline.py @@ -121,6 +121,12 @@ class CommandLine: help="force download of a new image (only with --strategy=cloud)" ) + installfromtemplate = argparse.ArgumentParser(add_help=False) + installfromtemplate.add_argument( + "--template", + help="template image to instantiate (only with --strategy=template)", + ) + update_projectopt = argparse.ArgumentParser(add_help=False) update_projectopt.add_argument( "projects", @@ -244,6 +250,7 @@ class CommandLine: installhostopt, installstrategyopt, installforceopt, + installfromtemplate, ], ) installparser.set_defaults(func=Application._action_install) @@ -360,6 +367,15 @@ class CommandLine: log.error("--script is required") sys.exit(1) + @staticmethod + def _validate_install(args): + if args.strategy == "template": + if not args.template: + log.error("--template is required with with --strategy=template") + sys.exit(1) + + return + # Main CLI validating method def _validate(self, args): """ @@ -373,6 +389,9 @@ class CommandLine: if args.action == "container": self._validate_container(args) + elif args.action == "install": + self._validate_install(args) + return args def parse(self): -- cgit v1.1