Rename masterfailover to master-failover
[ganeti-local] / qa / qa_os.py
index fbdaa27..28c2c73 100644 (file)
@@ -39,7 +39,6 @@ _TEMP_OS_NAME = "TEMP-Ganeti-QA-OS"
 _TEMP_OS_PATH = os.path.join(constants.OS_SEARCH_PATH[0], _TEMP_OS_NAME)
 
 
-@qa_utils.DefineHook('os-list')
 def TestOsList():
   """gnt-os list"""
   master = qa_config.GetMasterNode()
@@ -49,7 +48,6 @@ def TestOsList():
                        utils.ShellQuoteArgs(cmd)).wait(), 0)
 
 
-@qa_utils.DefineHook('os-diagnose')
 def TestOsDiagnose():
   """gnt-os diagnose"""
   master = qa_config.GetMasterNode()
@@ -59,6 +57,24 @@ def TestOsDiagnose():
                        utils.ShellQuoteArgs(cmd)).wait(), 0)
 
 
+def _TestOsModify(hvp_dict, expected_result=0):
+  """gnt-os modify"""
+  master = qa_config.GetMasterNode()
+
+  cmd = ['gnt-os', 'modify']
+
+  for hv_name, hv_params in hvp_dict.items():
+    cmd.append('-H')
+    options = []
+    for key, value in hv_params.items():
+      options.append("%s=%s" % (key, value))
+    cmd.append('%s:%s' % (hv_name, ','.join(options)))
+
+  cmd.append(_TEMP_OS_NAME)
+  AssertEqual(StartSSH(master['primary'],
+                       utils.ShellQuoteArgs(cmd)).wait(), expected_result)
+
+
 def _SetupTempOs(node, dir, valid):
   """Creates a temporary OS definition on the given node.
 
@@ -74,7 +90,7 @@ def _SetupTempOs(node, dir, valid):
   if valid:
     parts.append(sq(["ln", "-fs", "/bin/true", "create"]))
 
-  parts.append(sq(["echo", str(constants.OS_API_VERSION)]) +
+  parts.append(sq(["echo", str(constants.OS_API_V10)]) +
                " >ganeti_api_version")
 
   cmd = ' && '.join(parts)
@@ -128,19 +144,40 @@ def _TestOs(mode):
       _RemoveTempOs(node, dir)
 
 
-@qa_utils.DefineHook('os-valid')
 def TestOsValid():
   """Testing valid OS definition"""
   return _TestOs(1)
 
 
-@qa_utils.DefineHook('os-invalid')
 def TestOsInvalid():
   """Testing invalid OS definition"""
   return _TestOs(0)
 
 
-@qa_utils.DefineHook('os-partially-valid')
 def TestOsPartiallyValid():
   """Testing partially valid OS definition"""
   return _TestOs(2)
+
+
+def TestOsModifyValid():
+  """Testing a valid os modify invocation"""
+  hv_dict = {
+    constants.HT_XEN_PVM: {
+      constants.HV_ROOT_PATH: "/dev/sda5",
+      },
+    constants.HT_XEN_HVM: {
+      constants.HV_ACPI: False,
+      constants.HV_PAE: True,
+      },
+    }
+
+  return _TestOsModify(hv_dict)
+
+
+def TestOsModifyInvalid():
+  """Testing an invalid os modify invocation"""
+  hv_dict = {
+    "blahblahblubb": {"bar": ""},
+    }
+
+  return _TestOsModify(hv_dict, 1)