Revision 17cfeee9

b/qa/qa_cluster.py
60 60
    AssertEqual(qa_utils.GetCommandOutput(node["primary"], cmd), content)
61 61

  
62 62

  
63
# "gnt-cluster info" fields
64
_CIFIELD_RE = re.compile(r"^[-\s]*(?P<field>[^\s:]+):\s*(?P<value>\S.*)$")
65

  
66

  
67
def _GetBoolClusterField(field):
68
  """Get the Boolean value of a cluster field.
69

  
70
  This function currently assumes that the field name is unique in the cluster
71
  configuration. An assertion checks this assumption.
72

  
73
  @type field: string
74
  @param field: Name of the field
75
  @rtype: bool
76
  @return: The effective value of the field
77

  
78
  """
79
  master = qa_config.GetMasterNode()
80
  infocmd = "gnt-cluster info"
81
  info_out = qa_utils.GetCommandOutput(master["primary"], infocmd)
82
  ret = None
83
  for l in info_out.splitlines():
84
    m = _CIFIELD_RE.match(l)
85
    # FIXME: There should be a way to specify a field through a hierarchy
86
    if m and m.group("field") == field:
87
      # Make sure that ignoring the hierarchy doesn't cause a double match
88
      assert ret is None
89
      ret = (m.group("value").lower() == "true")
90
  if ret is not None:
91
    return ret
92
  raise qa_error.Error("Field not found in cluster configuration: %s" % field)
93

  
94

  
63 95
# Cluster-verify errors (date, "ERROR", then error code)
64 96
_CVERROR_RE = re.compile(r"^[\w\s:]+\s+- ERROR:([A-Z0-9_-]+):")
65 97

  

Also available in: Unified diff