Commit 6e513917 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Make GetDiskTemplateSets output disabled disk templates



This patch extends the 'GetDiskTemplateSets' function to
also output the list of disk templates that were enabled
before this operation, but will be disabled afterwards.
This patch also includes code to check for instances using
disk templates that are about to be disabled.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 87e23f2d
......@@ -793,24 +793,36 @@ class LUClusterSetParams(LogicalUnit):
@staticmethod
def _GetDiskTemplateSetsInner(op_enabled_disk_templates,
old_enabled_disk_templates):
"""Determines the enabled disk templates and the subset of disk templates
that are newly enabled by this operation.
"""Computes three sets of disk templates.
@see: C{_GetDiskTemplateSets} for more details.
"""
enabled_disk_templates = None
new_enabled_disk_templates = []
disabled_disk_templates = []
if op_enabled_disk_templates:
enabled_disk_templates = op_enabled_disk_templates
new_enabled_disk_templates = \
list(set(enabled_disk_templates)
- set(old_enabled_disk_templates))
list(set(enabled_disk_templates)
- set(old_enabled_disk_templates))
disabled_disk_templates = \
list(set(old_enabled_disk_templates)
- set(enabled_disk_templates))
else:
enabled_disk_templates = old_enabled_disk_templates
return (enabled_disk_templates, new_enabled_disk_templates)
return (enabled_disk_templates, new_enabled_disk_templates,
disabled_disk_templates)
def _GetDiskTemplateSets(self, cluster):
"""Determines the enabled disk templates and the subset of disk templates
that are newly enabled by this operation.
"""Computes three sets of disk templates.
The three sets are:
- disk templates that will be enabled after this operation (no matter if
they were enabled before or not)
- disk templates that get enabled by this operation (thus haven't been
enabled before.)
- disk templates that get disabled by this operation
"""
return self._GetDiskTemplateSetsInner(self.op.enabled_disk_templates,
......@@ -945,8 +957,9 @@ class LUClusterSetParams(LogicalUnit):
for node in self.cfg.GetAllNodesInfo().values()
if node.uuid in node_uuids and node.vm_capable]
(enabled_disk_templates, new_enabled_disk_templates) = \
self._GetDiskTemplateSets(cluster)
(enabled_disk_templates, new_enabled_disk_templates,
disabled_disk_templates) = self._GetDiskTemplateSets(cluster)
self._CheckInstancesOfDisabledDiskTemplates(disabled_disk_templates)
self._CheckVgName(vm_capable_node_uuids, enabled_disk_templates,
new_enabled_disk_templates)
......
......@@ -81,11 +81,23 @@ class TestGetEnabledDiskTemplates(unittest.TestCase):
def testNoNew(self):
op_dts = [constants.DT_DISKLESS]
old_dts = [constants.DT_DISKLESS]
(enabled_dts, new_dts) =\
(enabled_dts, new_dts, disabled_dts) =\
cluster.LUClusterSetParams._GetDiskTemplateSetsInner(
op_dts, old_dts)
self.assertEqual(enabled_dts, old_dts)
self.assertEqual(new_dts, [])
self.assertEqual(disabled_dts, [])
def testValid(self):
op_dts = [constants.DT_PLAIN, constants.DT_DRBD8]
old_dts = [constants.DT_DISKLESS, constants.DT_PLAIN]
(enabled_dts, new_dts, disabled_dts) =\
cluster.LUClusterSetParams._GetDiskTemplateSetsInner(
op_dts, old_dts)
self.assertEqual(enabled_dts, op_dts)
self.assertEqual(new_dts, [constants.DT_DRBD8])
self.assertEqual(disabled_dts, [constants.DT_DISKLESS])
if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment