+ enabled = templ in self.GetEnabledDiskTemplates()
+ return enabled and (not self.GetExclusiveStorage() or
+ templ in constants.DTS_EXCL_STORAGE)
+
+ def IsStorageTypeSupported(self, storage_type):
+ """Is the given storage type supported by the current configuration?
+
+ This is determined by looking if at least one of the disk templates
+ which is associated with the storage type is enabled in the configuration.
+
+ """
+ enabled_disk_templates = self.GetEnabledDiskTemplates()
+ if storage_type == constants.ST_LVM_PV:
+ disk_templates = utils.GetDiskTemplatesOfStorageType(constants.ST_LVM_VG)
+ else:
+ disk_templates = utils.GetDiskTemplatesOfStorageType(storage_type)
+ return bool(set(enabled_disk_templates).intersection(set(disk_templates)))
+
+ def AreSpindlesSupported(self):
+ """Are spindles supported by the current configuration?
+
+ """
+ return self.GetExclusiveStorage()
+
+ def GetVclusterSettings(self):
+ """Returns settings for virtual cluster.
+
+ """
+ master = self.get(_VCLUSTER_MASTER_KEY)
+ basedir = self.get(_VCLUSTER_BASEDIR_KEY)
+
+ return (master, basedir)
+
+ def GetDiskOptions(self):
+ """Return options for the disks of the instances.
+
+ Get 'disks' parameter from the configuration data. If 'disks' is missing,
+ try to create it from the legacy 'disk' and 'disk-growth' parameters.
+
+ """
+ try:
+ return self._data["disks"]
+ except KeyError:
+ pass
+
+ # Legacy interface
+ sizes = self._data.get("disk")
+ growths = self._data.get("disk-growth")
+ if sizes or growths:
+ if (sizes is None or growths is None or len(sizes) != len(growths)):
+ raise qa_error.Error("Config options 'disk' and 'disk-growth' must"
+ " exist and have the same number of items")
+ disks = []
+ for (size, growth) in zip(sizes, growths):
+ disks.append({"size": size, "growth": growth})
+ return disks
+ else:
+ return None