From: Guido Trotter Date: Mon, 29 Oct 2007 15:20:29 +0000 (+0000) Subject: Convert ListOS to use the all helper function. X-Git-Tag: v1.2b2~89 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/cc0451f30bbe16def8b56b14540f05dbd35c1e62 Convert ListOS to use the all helper function. The predicate function gets build by a lambda function. Also add a bit of debugging information to the 'unknown OS diagnose type'. Reviewed-by: iustinp --- diff --git a/scripts/gnt-os b/scripts/gnt-os index 82c2671..a13d2ca 100755 --- a/scripts/gnt-os +++ b/scripts/gnt-os @@ -45,7 +45,7 @@ def _DiagnoseOSValid(obj): elif isinstance(obj, errors.InvalidOS): return False else: - raise errors.ProgrammerError('unknown OS diagnose type') + raise errors.ProgrammerError("unknown OS diagnose type: '%s'" % type(obj)) def _DiagnoseOSName(obj): @@ -126,12 +126,8 @@ def ListOS(opts, args): for os_name, os_node_data in all_os.iteritems(): if len(os_node_data) != num_nodes: continue - valid = True - for l in os_node_data.values(): - if not _DiagnoseOSValid(l[0]): - valid = False - break - if valid: + + if utils.all(os_node_data.values(), lambda l: _DiagnoseOSValid(l[0])): valid_os.append(os_name) if not opts.no_headers: