Add a force option to the ClusterSetParams Opcode
authorKlaus Aehlig <aehlig@google.com>
Tue, 4 Jun 2013 12:23:13 +0000 (14:23 +0200)
committerKlaus Aehlig <aehlig@google.com>
Tue, 4 Jun 2013 18:06:31 +0000 (20:06 +0200)
If set, the op code will, in particular, try to set the master IP
on the new netdev, even if shutting down the master IP on the old
netdev failed.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

lib/cmdlib/cluster.py
lib/opcodes.py
src/Ganeti/OpCodes.hs
test/hs/Test/Ganeti/OpCodes.hs

index 8756ecd..3ab296b 100644 (file)
@@ -1021,7 +1021,13 @@ class LUClusterSetParams(LogicalUnit):
                   self.cluster.master_netdev)
       result = self.rpc.call_node_deactivate_master_ip(master_params.name,
                                                        master_params, ems)
-      result.Raise("Could not disable the master ip")
+      if not self.op.force:
+        result.Raise("Could not disable the master ip")
+      else:
+        if result.fail_msg:
+          msg = ("Could not disable the master ip (continuing anyway): %s" %
+                 result.fail_msg)
+          feedback_fn(msg)
       feedback_fn("Changing master_netdev from %s to %s" %
                   (master_params.netdev, self.op.master_netdev))
       self.cluster.master_netdev = self.op.master_netdev
index ee4da31..9cc8028 100644 (file)
@@ -918,6 +918,7 @@ class OpClusterSetParams(OpCode):
 
   """
   OP_PARAMS = [
+    _PForce,
     _PHvState,
     _PDiskState,
     ("vg_name", None, ht.TMaybe(ht.TString), "Volume group name"),
index 3b30350..92f5644 100644 (file)
@@ -149,7 +149,8 @@ $(genOpCode "OpCode"
      [ pName
      ])
   , ("OpClusterSetParams",
-     [ pHvState
+     [ pForce
+     , pHvState
      , pDiskState
      , pVgName
      , pEnabledHypervisors
index 6044322..eb539a6 100644 (file)
@@ -152,7 +152,7 @@ instance Arbitrary OpCodes.OpCode where
       "OP_CLUSTER_RENAME" ->
         OpCodes.OpClusterRename <$> genNameNE
       "OP_CLUSTER_SET_PARAMS" ->
-        OpCodes.OpClusterSetParams <$> emptyMUD <*> emptyMUD <*>
+        OpCodes.OpClusterSetParams <$> arbitrary <*> emptyMUD <*> emptyMUD <*>
           arbitrary <*> genMaybe (listOf1 arbitrary >>= mkNonEmpty) <*>
           genMaybe genEmptyContainer <*> emptyMUD <*>
           genMaybe genEmptyContainer <*> genMaybe genEmptyContainer <*>