diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-12-16 16:06:50 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-12-16 17:56:09 +0000 |
commit | 7bf91d8b8a6c9bb3080d77b1c12e2ebec3c4601b (patch) | |
tree | 156e63767f6eaf34ed6336f72568fd6bcfe94fdc /pxeboot.check | |
parent | 3169683f2a9ab356b5bea1f1afba01621b6fc80b (diff) | |
download | definitions-7bf91d8b8a6c9bb3080d77b1c12e2ebec3c4601b.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.
Diffstat (limited to 'pxeboot.check')
-rwxr-xr-x | pxeboot.check | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pxeboot.check b/pxeboot.check index df1fcc0e..885a0541 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) |