From: Ondrej Lichtner <olichtne(a)redhat.com>
Sometimes we want to ignore automatically loaded config files and just
force use a specific file. I added a new option for this '-C' that
reloads the Controller Config defaults and then loads the specified
config file. It's possible to use the option multiple times (each time
will reset the defaults) and it's also possible to use the '-c' option
after using '-C'.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst-ctl | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lnst-ctl b/lnst-ctl
index 5ec08b5..42aad02 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -44,6 +44,8 @@ def usage(retval=0):
"will override any other definitions in the recipe"
print " -a, --define-alias name=value define top-level alias"
print " -c, --config=FILE load additional config file"
+ print " -C, --config-override=FILE reset config defaults and load "
\
+ "the following config file"
print " -d, --debug emit debugging messages"
print " --dump-config dumps the join of all loaded " \
"configuration files on stdout and exits"
@@ -238,11 +240,12 @@ def main():
try:
opts, args = getopt.getopt(
sys.argv[1:],
- "A:a:c:dhmoprs:t:ux:v",
+ "A:a:c:C:dhmoprs:t:ux:v",
[
"override_alias=",
"define_alias=",
"config=",
+ "config-override=",
"debug",
"dump-config",
"help",
@@ -308,6 +311,14 @@ def main():
usage(RETVAL_ERR)
else:
lnst_config.load_config(arg)
+ elif opt in ("-C", "--config-override"):
+ if not os.path.isfile(arg):
+ print "File '%s' doesn't exist!" % arg
+ usage(RETVAL_ERR)
+ else:
+ print >> sys.stderr, "Reloading config defaults!"
+ lnst_config.controller_init()
+ lnst_config.load_config(arg)
elif opt in ("-x", "--result"):
result_path = arg
elif opt in ("-t", "--html"):
--
2.8.3