@qa_utils.DefineHook('node-add')
-def _NodeAdd(node):
+def _NodeAdd(node, readd=False):
master = qa_config.GetMasterNode()
- if node.get('_added', False):
+ if not readd and node.get('_added', False):
raise qa_error.Error("Node %s already in cluster" % node['primary'])
+ elif readd and not node.get('_added', False):
+ raise qa_error.Error("Node %s not yet in cluster" % node['primary'])
cmd = ['gnt-node', 'add']
if node.get('secondary', None):
cmd.append('--secondary-ip=%s' % node['secondary'])
+ if readd:
+ cmd.append('--readd')
cmd.append(node['primary'])
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
master = qa_config.GetMasterNode()
for node in qa_config.get('nodes'):
if node != master:
- _NodeAdd(node)
+ _NodeAdd(node, readd=False)
def TestNodeRemoveAll():
_NodeRemove(node)
+@qa_utils.DefineHook('node-readd')
+def TestNodeReadd(node):
+ """gnt-node add --readd"""
+ _NodeAdd(node, readd=True)
+
+
@qa_utils.DefineHook('node-info')
def TestNodeInfo():
"""gnt-node info"""
master = qa_config.GetMasterNode()
if qa_utils.GetNodeInstances(node2, secondaries=False):
- raise qa_error.UnusableNodeError("Secondary node has at least one "
- "primary instance. This test requires "
- "it to have no primary instances.")
+ raise qa_error.UnusableNodeError("Secondary node has at least one"
+ " primary instance. This test requires"
+ " it to have no primary instances.")
# Fail over to secondary node
cmd = ['gnt-node', 'failover', '-f', node['primary']]
node3 = qa_config.AcquireNode(exclude=[node, node2])
try:
if qa_utils.GetNodeInstances(node3, secondaries=True):
- raise qa_error.UnusableNodeError("Evacuation node has at least one "
- "secondary instance. This test requires "
- "it to have no secondary instances.")
+ raise qa_error.UnusableNodeError("Evacuation node has at least one"
+ " secondary instance. This test requires"
+ " it to have no secondary instances.")
# Evacuate all secondary instances
cmd = ['gnt-node', 'evacuate', '-f', node2['primary'], node3['primary']]