On 30 January 2013 14:42, Michael Hanselmann <[email protected]> wrote:
> 2013/1/30 Bernardo Dal Seno <[email protected]>:
>> On 30 January 2013 13:12, Michael Hanselmann <[email protected]> wrote:
>>> Couldn't this function return the original value, so one can write
>>> code to restore it?
>>
>> It could, but I've found no actual use for that, so I'd prefer to keep
>> the function void like the other tests. It's easy to add this feature
>> if needed. Or have you found places where it should be used?
>
> That means you have to hardcode the (default) setting in different
> places. If you could just restore the original most tests can set it
> to what they need and then restore.

In fact I did make assumption about the settings, and more than I thought.

Interdiff (see also interdiff for 4/17 and 17/17):

diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py
index 93ab049..34a47ef 100755
--- a/qa/ganeti-qa.py
+++ b/qa/ganeti-qa.py
@@ -464,7 +464,7 @@ def RunExclusiveStorageTests():

   node = qa_config.AcquireNode()
   try:
-    qa_cluster.TestSetExclStorCluster(True)
+    old_es = qa_cluster.TestSetExclStorCluster(True)
     if qa_config.TestEnabled("instance-add-plain-disk"):
       # Make sure that the cluster doesn't have any pre-existing problem
       qa_cluster.AssertClusterVerify()
@@ -474,7 +474,7 @@ def RunExclusiveStorageTests():
       qa_cluster.AssertClusterVerify()
       qa_instance.TestInstanceRemove(instance1)
       qa_instance.TestInstanceRemove(instance2)
-    qa_cluster.TestSetExclStorCluster(False)
+    qa_cluster.TestSetExclStorCluster(old_es)
   finally:
     qa_config.ReleaseNode(node)

diff --git a/qa/qa_cluster.py b/qa/qa_cluster.py
index c17cb87..9fbcc3f 100644
--- a/qa/qa_cluster.py
+++ b/qa/qa_cluster.py
@@ -633,11 +633,15 @@ def TestSetExclStorCluster(newvalue):

   @type newvalue: bool
   @param newvalue: New value of exclusive_storage
+  @rtype: bool
+  @return: The old value of exclusive_storage

   """
+  oldvalue = _GetBoolClusterField("exclusive_storage")
   AssertCommand(["gnt-cluster", "modify", "--node-parameters",
                  "exclusive_storage=%s" % newvalue])
   effvalue = _GetBoolClusterField("exclusive_storage")
   if effvalue != newvalue:
     raise qa_error.Error("exclusive_storage has the wrong value: %s instead"
                          " of %s" % (effvalue, newvalue))
+  return oldvalue


Bernardo

Reply via email to