(2.10) Hotplug: objects and constants additions
authorDimitris Aragiorgis <dimara@grnet.gr>
Thu, 9 Aug 2012 10:54:18 +0000 (13:54 +0300)
committerDimitris Aragiorgis <dimara@grnet.gr>
Thu, 27 Mar 2014 07:56:43 +0000 (09:56 +0200)
Add pci slot in NIC/Disk objects. This slot will be used only
by hypervisor code. Currently only KVM will use it and store it
temporarily in runtime files.
Add HOTPLUG_* constants to define device types an hotplug actions.

(fix) Add missing opcode parameter

In stable-2.10 opcodes.py is auto-generated from haskell ones.
Add hotplug* params to OpInstanceSetParams.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

lib/constants.py
lib/objects.py
lib/opcodes.py

index 2966efe..64d9836 100644 (file)
@@ -694,6 +694,24 @@ DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
   ]))
 # TODO: DDM_SWAP, DDM_MOVE?
 
+# device types to hotplug
+HOTPLUG_TARGET_DISK = "hotdisk"
+HOTPLUG_TARGET_NIC = "hotnic"
+HOTPLUG_ALL_TARGETS = frozenset([
+  HOTPLUG_TARGET_DISK,
+  HOTPLUG_TARGET_NIC
+  ])
+
+# hotplug actions
+HOTPLUG_ACTION_ADD = "hotadd"
+HOTPLUG_ACTION_REMOVE = "hotremove"
+HOTPLUG_ACTION_MODIFY = "hotmod"
+HOTPLUG_ALL_ACTIONS = frozenset([
+  HOTPLUG_ACTION_ADD,
+  HOTPLUG_ACTION_REMOVE,
+  HOTPLUG_ACTION_MODIFY
+  ])
+
 # common exit codes
 EXIT_SUCCESS = 0
 EXIT_FAILURE = 1
index 396f6a2..c8d66aa 100644 (file)
@@ -489,7 +489,8 @@ class ConfigData(ConfigObject):
 
 class NIC(ConfigObject):
   """Config object representing a network card."""
-  __slots__ = ["name", "mac", "ip", "network", "nicparams", "netinfo"] + _UUID
+  __slots__ = ["name", "mac", "ip", "network",
+               "nicparams", "netinfo", "pci"] + _UUID
 
   @classmethod
   def CheckParameterSyntax(cls, nicparams):
@@ -513,7 +514,7 @@ class NIC(ConfigObject):
 class Disk(ConfigObject):
   """Config object representing a block device."""
   __slots__ = ["name", "dev_type", "logical_id", "physical_id",
-               "children", "iv_name", "size", "mode", "params"] + _UUID
+               "children", "iv_name", "size", "mode", "params", "pci"] + _UUID
 
   def CreateOnSecondary(self):
     """Test if this device needs to be created on a secondary node."""
index d7e90ba..7b4a05d 100644 (file)
@@ -1720,6 +1720,8 @@ class OpInstanceSetParams(OpCode):
      "Whether to wait for the disk to synchronize, when changing template"),
     ("offline", None, ht.TMaybeBool, "Whether to mark instance as offline"),
     ("conflicts_check", True, ht.TBool, "Check for conflicting IPs"),
+    ("hotplug", False, ht.TBool, "Whether to hotplug device"),
+    ("hotplug_if_possible", False, ht.TBool, "If possible then hotplug device"),
     ]
   OP_RESULT = _TSetParamsResult