Fix cluster attributes dns_list and ntp_list

Settings in release change. Cloned cluster should have values valid for
its release.

dns_list and net_list were text values but in version mitaka-9.0 it
changed to text_list

Change-Id: Iac0aa42b7c36333e6d9c40b8a27a19df9efe36f5
Closes-Bug: 1572179
(cherry picked from commit 5ae4c7ebdcdbf1621ce617de4ec019ae2b5670c4)
This commit is contained in:
Sergey Abramov 2016-05-13 17:53:43 +03:00 committed by Nikita Zubkov
parent 7cf79178e6
commit 030fda6fa4
2 changed files with 47 additions and 0 deletions

View File

@ -140,3 +140,43 @@ class TestUpgradeHelperCloneCluster(base_tests.BaseCloneClusterTest):
self.src_cluster.id)
self.assertEqual(relation.orig_cluster_id, self.src_cluster.id)
self.assertEqual(relation.seed_cluster_id, new_cluster.id)
def _check_dns_and_ntp_list_values(self, new_cluster, dns_list, ntp_list):
self.assertEqual(
new_cluster.editable_attrs["external_ntp"]["ntp_list"]["value"],
ntp_list)
self.assertEqual(
new_cluster.editable_attrs["external_dns"]["dns_list"]["value"],
dns_list)
self.assertEqual(
new_cluster.editable_attrs["external_ntp"]["ntp_list"]["type"],
"text_list")
self.assertEqual(
new_cluster.editable_attrs["external_dns"]["dns_list"]["type"],
"text_list")
def test_cluster_copy_attrs_with_different_types_dns_and_ntp_lists(self):
attrs = copy.deepcopy(self.src_cluster.editable_attrs)
attrs["external_ntp"]["ntp_list"]["type"] = "text"
attrs["external_ntp"]["ntp_list"]["value"] = "1,2,3"
attrs["external_dns"]["dns_list"]["type"] = "text"
attrs["external_dns"]["dns_list"]["value"] = "4,5,6"
self.src_cluster.editable_attrs = attrs
new_cluster = self.helper.create_cluster_clone(
self.src_cluster, self.data)
self.helper.copy_attributes(self.src_cluster, new_cluster)
self._check_dns_and_ntp_list_values(
new_cluster, ["4", "5", "6"], ["1", "2", "3"])
def test_cluster_copy_attrs_with_same_types_dns_and_ntp_lists(self):
attrs = copy.deepcopy(self.src_cluster.editable_attrs)
attrs["external_ntp"]["ntp_list"]["type"] = "text_list"
attrs["external_ntp"]["ntp_list"]["value"] = ["1", "2", "3"]
attrs["external_dns"]["dns_list"]["type"] = "text_list"
attrs["external_dns"]["dns_list"]["value"] = ["4", "5", "6"]
self.src_cluster.editable_attrs = attrs
new_cluster = self.helper.create_cluster_clone(
self.src_cluster, self.data)
self.helper.copy_attributes(self.src_cluster, new_cluster)
self._check_dns_and_ntp_list_values(
new_cluster, ["4", "5", "6"], ["1", "2", "3"])

View File

@ -41,6 +41,13 @@ def merge_attributes(a, b):
for key, values in six.iteritems(pairs):
if key != "metadata" and key in a_values:
values["value"] = a_values[key]["value"]
# NOTE: In the mitaka-9.0 release types of values dns_list and
# ntp_list were changed from 'text'
# (a string of comma-separated IP-addresses)
# to 'text_list' (a list of strings of IP-addresses).
if a_values[key]['type'] == 'text' and \
values['type'] == 'text_list':
values["value"] = values['value'].split(',')
return attrs