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-23 16:27:56 +0100
commit201ecd52efd3cb5a44a5e9b6928146934b66012e (patch)
treeba18d03b0719b43cf70e917c0cc322e44985e82a
parent8c1637e938416e068a086071d133b596543c9ecd (diff)
downloaddefinitions-201ecd52efd3cb5a44a5e9b6928146934b66012e.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)