X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/b894f5a892a14327e9bd63260f4cdfd9c205fd34..a162cf5b6e67d48b048df0cd03bdaeb8e5bbdb70:/lib/objects.py?ds=sidebyside diff --git a/lib/objects.py b/lib/objects.py index 5282e9f..0feefbe 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -29,6 +29,7 @@ pass to and from external parties. import ConfigParser import re +import copy from cStringIO import StringIO from ganeti import errors @@ -49,7 +50,7 @@ class ConfigObject(object): as None instead of raising an error Classes derived from this must always declare __slots__ (we use many - config objects and the memory reduction is useful. + config objects and the memory reduction is useful) """ __slots__ = [] @@ -237,7 +238,7 @@ class TaggableObject(ConfigObject): class ConfigData(ConfigObject): """Top-level config object.""" - __slots__ = ["cluster", "nodes", "instances"] + __slots__ = ["version", "cluster", "nodes", "instances", "serial_no"] def ToDict(self): """Custom function for top-level config data. @@ -273,7 +274,7 @@ class NIC(ConfigObject): class Disk(ConfigObject): """Config object representing a block device.""" __slots__ = ["dev_type", "logical_id", "physical_id", - "children", "iv_name", "size"] + "children", "iv_name", "size", "mode"] def CreateOnSecondary(self): """Test if this device needs to be created on a secondary node.""" @@ -412,7 +413,7 @@ class Disk(ConfigObject): if self.logical_id is None and self.physical_id is not None: return if self.dev_type in constants.LDS_DRBD: - pnode, snode, port = self.logical_id + pnode, snode, port, pminor, sminor, secret = self.logical_id if target_node not in (pnode, snode): raise errors.ConfigurationError("DRBD device not knowing node %s" % target_node) @@ -421,12 +422,12 @@ class Disk(ConfigObject): if pnode_ip is None or snode_ip is None: raise errors.ConfigurationError("Can't find primary or secondary node" " for %s" % str(self)) + p_data = (pnode_ip, port) + s_data = (snode_ip, port) if pnode == target_node: - self.physical_id = (pnode_ip, port, - snode_ip, port) + self.physical_id = p_data + s_data + (pminor, secret) else: # it must be secondary, we tested above - self.physical_id = (snode_ip, port, - pnode_ip, port) + self.physical_id = s_data + p_data + (sminor, secret) else: self.physical_id = self.logical_id return @@ -458,6 +459,10 @@ class Disk(ConfigObject): obj.logical_id = tuple(obj.logical_id) if obj.physical_id and isinstance(obj.physical_id, list): obj.physical_id = tuple(obj.physical_id) + if obj.dev_type in constants.LDS_DRBD: + # we need a tuple of length six here + if len(obj.logical_id) < 6: + obj.logical_id += (None,) * (6 - len(obj.logical_id)) return obj def __str__(self): @@ -467,6 +472,7 @@ class Disk(ConfigObject): if self.dev_type == constants.LD_LV: val = "