Example #1
0
def _GetJobStatuses():
    """ Invokes gnt-job list and extracts an id to status dictionary.

  @rtype: dict of string to string
  @return: A dictionary mapping job ids to matching statuses

  """
    master = qa_config.GetMasterNode()
    list_output = GetCommandOutput(
        master.primary, "gnt-job list --no-headers --output=id,status")
    return dict(map(lambda s: s.split(), list_output.splitlines()))
Example #2
0
def _GetJobStatuses():
  """ Invokes gnt-job list and extracts an id to status dictionary.

  @rtype: dict of string to string
  @return: A dictionary mapping job ids to matching statuses

  """
  master = qa_config.GetMasterNode()
  list_output = GetCommandOutput(
    master.primary, "gnt-job list --no-headers --output=id,status"
  )
  return dict(map(lambda s: s.split(), list_output.splitlines()))
Example #3
0
def TestClusterEpo():
    """gnt-cluster epo"""
    master = qa_config.GetMasterNode()

    # Assert that OOB is unavailable for all nodes
    result_output = GetCommandOutput(
        master.primary, "gnt-node list --verbose --no-headers -o"
        " powered")
    AssertEqual(
        compat.all(powered == "(unavail)"
                   for powered in result_output.splitlines()), True)

    # Conflicting
    AssertCommand(["gnt-cluster", "epo", "--groups", "--all"], fail=True)
    # --all doesn't expect arguments
    AssertCommand(["gnt-cluster", "epo", "--all", "some_arg"], fail=True)

    # Unless --all is given master is not allowed to be in the list
    AssertCommand(["gnt-cluster", "epo", "-f", master.primary], fail=True)

    # This shouldn't fail
    AssertCommand(["gnt-cluster", "epo", "-f", "--all"])

    # All instances should have been stopped now
    result_output = GetCommandOutput(
        master.primary, "gnt-instance list --no-headers -o status")
    # ERROR_down because the instance is stopped but not recorded as such
    AssertEqual(
        compat.all(status == "ERROR_down"
                   for status in result_output.splitlines()), True)

    # Now start everything again
    AssertCommand(["gnt-cluster", "epo", "--on", "-f", "--all"])

    # All instances should have been started now
    result_output = GetCommandOutput(
        master.primary, "gnt-instance list --no-headers -o status")
    AssertEqual(
        compat.all(status == "running"
                   for status in result_output.splitlines()), True)
Example #4
0
def TestClusterEpo():
  """gnt-cluster epo"""
  master = qa_config.GetMasterNode()

  # Assert that OOB is unavailable for all nodes
  result_output = GetCommandOutput(master.primary,
                                   "gnt-node list --verbose --no-headers -o"
                                   " powered")
  AssertEqual(compat.all(powered == "(unavail)"
                         for powered in result_output.splitlines()), True)

  # Conflicting
  AssertCommand(["gnt-cluster", "epo", "--groups", "--all"], fail=True)
  # --all doesn't expect arguments
  AssertCommand(["gnt-cluster", "epo", "--all", "some_arg"], fail=True)

  # Unless --all is given master is not allowed to be in the list
  AssertCommand(["gnt-cluster", "epo", "-f", master.primary], fail=True)

  # This shouldn't fail
  AssertCommand(["gnt-cluster", "epo", "-f", "--all"])

  # All instances should have been stopped now
  result_output = GetCommandOutput(master.primary,
                                   "gnt-instance list --no-headers -o status")
  # ERROR_down because the instance is stopped but not recorded as such
  AssertEqual(compat.all(status == "ERROR_down"
                         for status in result_output.splitlines()), True)

  # Now start everything again
  AssertCommand(["gnt-cluster", "epo", "--on", "-f", "--all"])

  # All instances should have been started now
  result_output = GetCommandOutput(master.primary,
                                   "gnt-instance list --no-headers -o status")
  AssertEqual(compat.all(status == "running"
                         for status in result_output.splitlines()), True)
Example #5
0
def TestNodeListDrbd(node, is_drbd):
  """gnt-node list-drbd"""
  master = qa_config.GetMasterNode()
  result_output = GetCommandOutput(master.primary,
                                   "gnt-node list-drbd --no-header %s" %
                                   node.primary)
  # Meaningful to note: there is but one instance, and the node is either the
  # primary or one of the secondaries
  if is_drbd:
    # Invoked for both primary and secondary
    per_disk_info = result_output.splitlines()
    for line in per_disk_info:
      try:
        drbd_node, _, _, _, _, drbd_peer = line.split()
      except ValueError:
        raise qa_error.Error("Could not examine list-drbd output: expected a"
                             " single row of 6 entries, found the following:"
                             " %s" % line)

      AssertIn(node.primary, [drbd_node, drbd_peer],
               msg="The output %s does not contain the node" % line)
  else:
    # Output should be empty, barring newlines
    AssertEqual(result_output.strip(), "")
Example #6
0
 def AssertInGroup(group, nodes):
   real_output = GetCommandOutput(master_node,
                                  "gnt-node list --no-headers -o group " +
                                  utils.ShellQuoteArgs(nodes))
   AssertEqual(real_output.splitlines(), [group] * len(nodes))