Make “gnt-os diagnose” exit 1 if not all OSes are valid.
authorMichael Hanselmann <hansmi@google.com>
Mon, 15 Oct 2007 11:45:13 +0000 (11:45 +0000)
committerMichael Hanselmann <hansmi@google.com>
Mon, 15 Oct 2007 11:45:13 +0000 (11:45 +0000)
Reviewed-by: iustinp

scripts/gnt-os

index ab57ce9..82c2671 100755 (executable)
@@ -174,6 +174,8 @@ def DiagnoseOS(opts, args):
   logger.ToStdout(format % (max_name, 'Name', max_node, 'Status/Node',
                             'Details'))
 
+  has_bad = False
+
   for os_name in all_os:
     nodes_valid = {}
     nodes_bad = {}
@@ -192,8 +194,10 @@ def DiagnoseOS(opts, args):
       status = "valid"
     elif not nodes_valid and nodes_bad:
       status = "invalid"
+      has_bad = True
     else:
       status = "partial valid"
+      has_bad = True
 
     def _OutputNodeHiddenOSStatus(dobj_list):
       for dobj in dobj_list:
@@ -213,6 +217,8 @@ def DiagnoseOS(opts, args):
     _OutputPerNodeOSStatus(nodes_valid)
     _OutputPerNodeOSStatus(nodes_bad)
 
+  return int(has_bad)
+
 
 commands = {
   'list': (ListOS, ARGS_NONE, [DEBUG_OPT, NOHDR_OPT], "",