Remove constant for disk wipe block size
[ganeti-local] / qa / qa_node.py
index b71766e..647af19 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2007, 2011 Google Inc.
+# Copyright (C) 2007, 2011, 2012 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -36,32 +36,38 @@ from qa_utils import AssertCommand, AssertEqual
 
 
 def _NodeAdd(node, readd=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', "--no-ssh-key-check"]
-  if node.get('secondary', None):
-    cmd.append('--secondary-ip=%s' % node['secondary'])
+  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", "--no-ssh-key-check"]
+  if node.get("secondary", None):
+    cmd.append("--secondary-ip=%s" % node["secondary"])
   if readd:
-    cmd.append('--readd')
-  cmd.append(node['primary'])
+    cmd.append("--readd")
+  cmd.append(node["primary"])
 
   AssertCommand(cmd)
 
-  node['_added'] = True
+  node["_added"] = True
 
 
 def _NodeRemove(node):
   AssertCommand(["gnt-node", "remove", node["primary"]])
-  node['_added'] = False
+  node["_added"] = False
+
+
+def MakeNodeOffline(node, value):
+  """gnt-node modify --offline=value"""
+  # value in ["yes", "no"]
+  AssertCommand(["gnt-node", "modify", "--offline", value, node["primary"]])
 
 
 def TestNodeAddAll():
   """Adding all nodes to cluster."""
   master = qa_config.GetMasterNode()
-  for node in qa_config.get('nodes'):
+  for node in qa_config.get("nodes"):
     if node != master:
       _NodeAdd(node, readd=False)
 
@@ -73,15 +79,15 @@ def MarkNodeAddedAll():
 
   """
   master = qa_config.GetMasterNode()
-  for node in qa_config.get('nodes'):
+  for node in qa_config.get("nodes"):
     if node != master:
-      node['_added'] = True
+      node["_added"] = True
 
 
 def TestNodeRemoveAll():
   """Removing all nodes from cluster."""
   master = qa_config.GetMasterNode()
-  for node in qa_config.get('nodes'):
+  for node in qa_config.get("nodes"):
     if node != master:
       _NodeRemove(node)
 
@@ -209,6 +215,10 @@ def TestNodeModify(node):
   AssertCommand(["gnt-node", "modify", "--master-candidate=yes",
                  "--auto-promote", node["primary"]])
 
+  # Test setting secondary IP address
+  AssertCommand(["gnt-node", "modify", "--secondary-ip=%s" % node["secondary"],
+                 node["primary"]])
+
 
 def _CreateOobScriptStructure():
   """Create a simple OOB handling script and its structure."""
@@ -253,7 +263,6 @@ def TestOutOfBand():
   node = qa_config.AcquireNode(exclude=master)
 
   master_name = master["primary"]
-  full_master_name = qa_utils.ResolveNodeName(master)
   node_name = node["primary"]
   full_node_name = qa_utils.ResolveNodeName(node)
 
@@ -276,15 +285,9 @@ def TestOutOfBand():
     # Power off on master without options should fail
     AssertCommand(["gnt-node", "power", "-f", "off", master_name], fail=True)
     # With force master it should still fail
-    AssertCommand(["gnt-node", "power", "-f", "--force-master", "off",
-                   master_name], fail=True)
-    AssertCommand(["gnt-node", "power", "-f",  "--ignore-status", "off",
+    AssertCommand(["gnt-node", "power", "-f", "--ignore-status", "off",
                    master_name],
                   fail=True)
-    # This should work again
-    AssertCommand(["gnt-node", "power", "-f", "--ignore-status",
-                   "--force-master", "off", master_name])
-    _AssertOobCall(verify_path, "power-off %s" % full_master_name)
 
     # Verify we can't transform back to online when not yet powered on
     AssertCommand(["gnt-node", "modify", "-O", "no", node_name],
@@ -309,7 +312,7 @@ def TestOutOfBand():
     AssertCommand(["gnt-node", "health"], fail=True)
 
     # Correct Data, exit 0
-    _UpdateOobFile(data_path, serializer.DumpJson({ "powered": True }))
+    _UpdateOobFile(data_path, serializer.DumpJson({"powered": True}))
 
     AssertCommand(["gnt-node", "power", "status", node_name])
     _AssertOobCall(verify_path, "power-status %s" % full_node_name)
@@ -322,7 +325,6 @@ def TestOutOfBand():
 
     AssertCommand(["gnt-node", "health"])
 
-
     # Those commands should fail as they expect no data regardless of exit 0
     AssertCommand(["gnt-node", "power", "on", node_name], fail=True)
     _AssertOobCall(verify_path, "power-on %s" % full_node_name)
@@ -400,43 +402,6 @@ def TestOutOfBand():
       AssertCommand(["gnt-node", "modify", "--node-parameters",
                      "oob_program=default", node_name])
       AssertCommand(["rm", "-f", oob_path2, verify_path2])
-
-    verify_path3 = qa_utils.UploadData(master["primary"], "")
-    oob_script = ("#!/bin/bash\n"
-                  "echo \"$@\" >> %s\n") % verify_path3
-    oob_path3 = qa_utils.UploadData(master["primary"], oob_script, mode=0700)
-
-    AssertCommand(["gnt-cluster", "modify", "--node-parameters",
-                   "oob_program=%s" % oob_path3])
-
-    non_master_nodes = []
-    for node in qa_config.get('nodes'):
-      if node != master:
-        non_master_nodes.append(qa_utils.ResolveNodeName(node))
-
-    try:
-      # Without the --force-master it should not have the master in it
-      verify_content = ["power-cycle %s" % name for name in non_master_nodes]
-      AssertCommand(["gnt-node", "power", "-f", "--all", "cycle"])
-      _AssertOobCall(verify_path3, "\n".join(verify_content))
-
-      # Empty file
-      _UpdateOobFile(verify_path3, "")
-      # With the --force-master it should have the master at last position
-      verify_content.append("power-cycle %s" % full_master_name)
-      AssertCommand(["gnt-node", "power", "--force-master", "-f", "--all",
-                     "cycle"])
-      _AssertOobCall(verify_path3, "\n".join(verify_content))
-
-      # Empty file
-      _UpdateOobFile(verify_path3, "")
-      # With master as first argument it should still be called last
-      cmd = ["gnt-node", "power", "--force-master", "-f", "cycle", master_name]
-      cmd.extend(non_master_nodes)
-      AssertCommand(cmd)
-      _AssertOobCall(verify_path3, "\n".join(verify_content))
-    finally:
-      AssertCommand(["rm", "-f", oob_path3, verify_path3])
   finally:
     AssertCommand(["gnt-cluster", "modify", "--node-parameters",
                    "oob_program="])
@@ -452,3 +417,8 @@ def TestNodeList():
 def TestNodeListFields():
   """gnt-node list-fields"""
   qa_utils.GenericQueryFieldsTest("gnt-node", query.NODE_FIELDS.keys())
+
+
+def TestNodeListDrbd(node):
+  """gnt-node list-drbd"""
+  AssertCommand(["gnt-node", "list-drbd", node["primary"]])