obj.instances = cls._ContainerFromDicts(obj.instances, dict, Instance)
return obj
+ def HasAnyDiskOfType(self, dev_type):
+ """Check if in there is at disk of the given type in the configuration.
+
+ @type dev_type: L{constants.LDS_BLOCK}
+ @param dev_type: the type to look for
+ @rtype: boolean
+ @return: boolean indicating if a disk of the given type was found or not
+
+ """
+ for instance in self.instances.values():
+ for disk in instance.disks:
+ if disk.IsBasedOnDiskType(dev_type):
+ return True
+ return False
+
def UpgradeConfig(self):
"""Fill defaults for missing configuration values.
node.UpgradeConfig()
for instance in self.instances.values():
instance.UpgradeConfig()
+ if self.cluster.drbd_usermode_helper is None:
+ # To decide if we set an helper let's check if at least one instance has
+ # a DRBD disk. This does not cover all the possible scenarios but it
+ # gives a good approximation.
+ if self.HasAnyDiskOfType(constants.LD_DRBD8):
+ self.cluster.drbd_usermode_helper = constants.DEFAULT_DRBD_HELPER
class NIC(ConfigObject):
return 0
return -1
+ def IsBasedOnDiskType(self, dev_type):
+ """Check if the disk or its children are based on the given type.
+
+ @type dev_type: L{constants.LDS_BLOCK}
+ @param dev_type: the type to look for
+ @rtype: boolean
+ @return: boolean indicating if a device of the given type was found or not
+
+ """
+ if self.children:
+ for child in self.children:
+ if child.IsBasedOnDiskType(dev_type):
+ return True
+ return self.dev_type == dev_type
+
def GetNodes(self, node):
"""This function returns the nodes this device lives on.
"tcpudp_port_pool",
"mac_prefix",
"volume_group_name",
+ "drbd_usermode_helper",
"default_bridge",
"default_hypervisor",
"master_node",
"modify_ssh_setup",
"maintain_node_health",
"uid_pool",
+ "default_iallocator",
] + _TIMESTAMPS + _UUID
def UpgradeConfig(self):
if self.uid_pool is None:
self.uid_pool = []
+ if self.default_iallocator is None:
+ self.default_iallocator = ""
+
def ToDict(self):
"""Custom function for cluster.