diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 478e7675e3302c6338c594ce75b9ffa96d57b14a..74abf21068578175f67377afb367a6c8ad8a80a2 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -10495,6 +10495,16 @@ class LUInstanceCreate(LogicalUnit): " from the first disk's node group will be" " used") + if not self.op.disk_template in constants.DTS_EXCL_STORAGE: + nodes = [pnode] + if self.op.disk_template in constants.DTS_INT_MIRROR: + nodes.append(snode) + has_es = lambda n: _IsExclusiveStorageEnabledNode(self.cfg, n) + if compat.any(map(has_es, nodes)): + raise errors.OpPrereqError("Disk template %s not supported with" + " exclusive storage" % self.op.disk_template, + errors.ECODE_STATE) + nodenames = [pnode.name] + self.secondaries # Verify instance specs @@ -12416,14 +12426,22 @@ class LUInstanceGrowDisk(LogicalUnit): utils.FormatUnit(self.delta, "h"), errors.ECODE_INVAL) - if instance.disk_template not in (constants.DT_FILE, - constants.DT_SHARED_FILE, - constants.DT_RBD, - constants.DT_EXT): + self._CheckDiskSpace(nodenames, self.disk.ComputeGrowth(self.delta)) + + def _CheckDiskSpace(self, nodenames, req_vgspace): + template = self.instance.disk_template + if template not in (constants.DTS_NO_FREE_SPACE_CHECK): # TODO: check the free disk space for file, when that feature will be # supported - _CheckNodesFreeDiskPerVG(self, nodenames, - self.disk.ComputeGrowth(self.delta)) + nodes = map(self.cfg.GetNodeInfo, nodenames) + es_nodes = filter(lambda n: _IsExclusiveStorageEnabledNode(self.cfg, n), + nodes) + if es_nodes: + # With exclusive storage we need to something smarter than just looking + # at free space; for now, let's simply abort the operation. + raise errors.OpPrereqError("Cannot grow disks when exclusive_storage" + " is enabled", errors.ECODE_STATE) + _CheckNodesFreeDiskPerVG(self, nodenames, req_vgspace) def Exec(self, feedback_fn): """Execute disk grow. @@ -13292,6 +13310,19 @@ class LUInstanceSetParams(LogicalUnit): " from the first disk's node group will be" " used") + if not self.op.disk_template in constants.DTS_EXCL_STORAGE: + # Make sure none of the nodes require exclusive storage + nodes = [pnode_info] + if self.op.disk_template in constants.DTS_INT_MIRROR: + assert snode_info + nodes.append(snode_info) + has_es = lambda n: _IsExclusiveStorageEnabledNode(self.cfg, n) + if compat.any(map(has_es, nodes)): + errmsg = ("Cannot convert disk template from %s to %s when exclusive" + " storage is enabled" % (instance.disk_template, + self.op.disk_template)) + raise errors.OpPrereqError(errmsg, errors.ECODE_STATE) + def CheckPrereq(self): """Check prerequisites. diff --git a/lib/constants.py b/lib/constants.py index 2501f0be5f1e1e7fa3b15361627e6c77d8dfa6d6..5bc6cf36c09a324813ddd2fe5994111515de2067 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -420,6 +420,17 @@ DTS_FILEBASED = compat.UniqueFrozenset([ DT_SHARED_FILE, ]) +# the set of disk templates that are supported by exclusive_storage +DTS_EXCL_STORAGE = frozenset([DT_PLAIN]) + +# templates for which we don't perform checks on free space +DTS_NO_FREE_SPACE_CHECK = frozenset([ + DT_FILE, + DT_SHARED_FILE, + DT_RBD, + DT_EXT, + ]) + # logical disk types LD_LV = "lvm" LD_DRBD8 = "drbd8"