Commit 1d9f9df7 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Downgrade 'xen_cmd'



This downgrades the cluster's hypervisor parameters for the
xen hypervisors with respect to the 'xen_cmd' attribute.
A unit tests is provided.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent d7f5fc77
......@@ -391,6 +391,19 @@ class TestCfgupgrade(unittest.TestCase):
newconf = self._LoadConfig()
self.assertEqual(oldconf, newconf)
def testDowngradeFrom_2_9(self):
cfg29_name = "cluster_config_2.9.json"
cfg29 = self._LoadTestDataConfig(cfg29_name)
self._CreateValidConfigDir()
utils.WriteFile(self.config_path, data=serializer.DumpJson(cfg29))
_RunUpgrade(self.tmpdir, False, True, downgrade=True)
cfg28 = self._LoadConfig()
hvparams = cfg28["cluster"]["hvparams"]
for xen_variant in [constants.HT_XEN_PVM, constants.HT_XEN_HVM]:
xen_params = hvparams[xen_variant]
self.assertTrue(constants.HV_XEN_CMD not in xen_params)
def testDowngradeFullConfigBackwardFrom_2_7(self):
"""Test for upgrade + downgrade + upgrade combination."""
self._TestUpgradeFromFile("cluster_config_2.7.json", False)
......
......@@ -417,6 +417,20 @@ def DowngradeInstanceIndices(config_data):
ChangeInstanceIndices(config_data, "uuid", "name")
def DowngradeHvparams(config_data):
"""Downgrade the cluster's hypervisor parameters."""
cluster = config_data["cluster"]
if "hvparams" in cluster:
hvparams = cluster["hvparams"]
xen_params = None
for xen_variant in [constants.HT_XEN_PVM, constants.HT_XEN_HVM]:
if xen_variant in hvparams:
xen_params = hvparams[xen_variant]
# 'xen_cmd' was introduced in 2.9
if constants.HV_XEN_CMD in xen_params:
del xen_params[constants.HV_XEN_CMD]
def DowngradeAll(config_data):
# Any code specific to a particular version should be labeled that way, so
# it can be removed when updating to the next version.
......@@ -425,6 +439,7 @@ def DowngradeAll(config_data):
DowngradeInstances(config_data)
DowngradeNodeIndices(config_data)
DowngradeInstanceIndices(config_data)
DowngradeHvparams(config_data)
def 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