def TestNodeModify(node):

  default_pool_size = 10
  nodes = qa_config.GetAllNodes()
  test_pool_size = len(nodes) - 1

  # Reduce the number of master candidates, because otherwise all
  # subsequent 'gnt-cluster verify' commands fail due to not enough
  # master candidates.
  AssertCommand(["gnt-cluster", "modify",
                 "--candidate-pool-size=%s" % test_pool_size])

  # make sure enough master candidates will be available by disabling the
  # master candidate role first with --auto-promote
  AssertCommand(["gnt-node", "modify", "--master-candidate=no",
                "--auto-promote", node.primary])

  # now it's save to force-remove the master candidate role
  for flag in ["master-candidate", "drained", "offline"]:
    for value in ["yes", "no"]:
      AssertCommand(["gnt-node", "modify", "--force",
                     "--%s=%s" % (flag, value), node.primary])
      AssertCommand(["gnt-cluster", "verify"])

  AssertCommand(["gnt-node", "modify", "--master-candidate=yes", node.primary])

  # Test setting secondary IP address
  AssertCommand(["gnt-node", "modify", "--secondary-ip=%s" % node.secondary,
                 node.primary])

  AssertRedirectedCommand(["gnt-cluster", "verify"])
  AssertCommand(["gnt-cluster", "modify",
                 "--candidate-pool-size=%s" % default_pool_size])

  # For test clusters with more nodes than the default pool size,
  # we now have too many master candidates. To readjust to the original
  # size, manually demote all nodes and rely on auto-promotion to adjust.
  if len(nodes) > default_pool_size:
    master = qa_config.GetMasterNode()
    for n in nodes:
      if n.primary != master.primary:
        AssertCommand(["gnt-node", "modify", "--master-candidate=no",
                       "--auto-promote", n.primary])
gnt-node modify
dataset/ETHPy150Open ganeti/ganeti/qa/qa_node.py/TestNodeModify