summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-12-16 16:06:50 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-12-19 10:37:33 +0000
commit6862edbe757b367ad0eeb95cad678825ea719673 (patch)
tree0b5ca628eb644ca63dbb779a9e53d7fd7f59b6ea
parent12f3681b335ae9b3a2f32e3e715d22f28eb7b7f4 (diff)
downloaddefinitions-6862edbe757b367ad0eeb95cad678825ea719673.tar.gz
pxeboot.check: Fail with a nice error if PXEBOOT_MODE is needed and not set
This is needed because now pxeboot.check doesn't fail if the options specified in the environment match more than one mode.
-rwxr-xr-xpxeboot.check11
1 files changed, 9 insertions, 2 deletions
diff --git a/pxeboot.check b/pxeboot.check
index df1fcc0e..fabe8138 100755
--- a/pxeboot.check
+++ b/pxeboot.check
@@ -61,8 +61,15 @@ elif len(complete_matches) > 1:
if 'PXEBOOT_MODE' in os.environ:
mode = os.environ['PXEBOOT_MODE']
else:
- mode, = (mode for (mode, opt_set) in valid_option_sets
- if all(o in os.environ for o in opt_set))
+ try:
+ mode, = (mode for (mode, opt_set) in valid_option_sets
+ if all(o in os.environ for o in opt_set))
+
+ except ValueError as e:
+ print ('More than one candidate for PXEBOOT_MODE, please '
+ 'set a value for it. Type `morph help pxeboot.write for '
+ 'more info')
+ sys.exit(1)
if mode not in valid_modes:
print('%s is not a valid PXEBOOT_MODE' % mode)