From 41a1df349f8cd1c2efb97be3a4609e3498e78051 Mon Sep 17 00:00:00 2001 From: Dimitris Aragiorgis <dimara@grnet.gr> Date: Thu, 9 Aug 2012 13:54:18 +0300 Subject: [PATCH] Hoplug: objects modifications/additions Introduce new HotplugInfo object as part of Instance object. hotplug_info { 'nics': 0, 'disks': 0, 'pci_pool': [16, 17, 18] } nics/disks is an index used for device identification and naming. Everytime a new device (disk/nic) is hotadded these values get incremented. pci_pool is a list of pci slots where a device can be placed. Every time a device gets hot-plugged/unplugged a pci slot gets popped/appended. Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr> --- lib/objects.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/objects.py b/lib/objects.py index d79e08566..a10e23ca9 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -503,10 +503,13 @@ class ConfigData(ConfigObject): if self.HasAnyDiskOfType(constants.LD_DRBD8): self.cluster.drbd_usermode_helper = constants.DEFAULT_DRBD_HELPER +class HotplugInfo(ConfigObject): + __slots__ = ["nics", "disks", "pci_pool"] + class NIC(ConfigObject): """Config object representing a network card.""" - __slots__ = ["mac", "ip", "nicparams"] + __slots__ = ["idx", "pci", "mac", "ip", "nicparams"] @classmethod def CheckParameterSyntax(cls, nicparams): @@ -530,7 +533,7 @@ class NIC(ConfigObject): class Disk(ConfigObject): """Config object representing a block device.""" - __slots__ = ["dev_type", "logical_id", "physical_id", + __slots__ = ["idx", "pci", "dev_type", "logical_id", "physical_id", "children", "iv_name", "size", "mode", "params"] def CreateOnSecondary(self): @@ -1033,6 +1036,7 @@ class Instance(TaggableObject): "admin_state", "nics", "disks", + "hotplug_info", "disk_template", "network_port", "serial_no", @@ -1163,6 +1167,8 @@ class Instance(TaggableObject): else: nlist = [] bo[attr] = nlist + if self.hotplug_info: + bo['hotplug_info'] = self.hotplug_info.ToDict() return bo @classmethod @@ -1180,6 +1186,8 @@ class Instance(TaggableObject): obj = super(Instance, cls).FromDict(val) obj.nics = cls._ContainerFromDicts(obj.nics, list, NIC) obj.disks = cls._ContainerFromDicts(obj.disks, list, Disk) + if "hotplug_info" in val: + obj.hotplug_info = HotplugInfo.FromDict(val["hotplug_info"]) return obj def UpgradeConfig(self): -- GitLab