summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnastasiya <atolochkova@mirantis.com>2016-08-01 14:39:35 +0300
committerIlya Kharin <akscram@gmail.com>2016-08-15 16:04:23 +0000
commita78f4348f84dd470ba1f3b99d2c751fa2dd12d7a (patch)
tree0f6345a419235390975e38fc3db6c86fa31d35e7
parentda0e1d2cca1f23c7910d02c72c1c5da902613633 (diff)
Move change_env_settings function from octane to cluster upgrade extension
* change_env_settings function was moved to cluster upgrade extention * merge generated attributes code was written Change-Id: I6d1e27b8b0c01f3251067bc88931cd2354feb5ce Partial-Bug: #1602587 (cherry picked from commit dc2e3f930957b2c8af2d6c6a60bfcc6c5e6bb061)
Notes
Notes (review): Code-Review+2: Ilya Kharin <akscram@gmail.com> Workflow+1: Ilya Kharin <akscram@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 15 Aug 2016 16:53:33 +0000 Reviewed-on: https://review.openstack.org/355555 Project: openstack/fuel-nailgun-extension-cluster-upgrade Branch: refs/heads/stable/mitaka
-rw-r--r--cluster_upgrade/tests/test_upgrade.py31
-rw-r--r--cluster_upgrade/upgrade.py15
2 files changed, 43 insertions, 3 deletions
diff --git a/cluster_upgrade/tests/test_upgrade.py b/cluster_upgrade/tests/test_upgrade.py
index 015fd48..296d819 100644
--- a/cluster_upgrade/tests/test_upgrade.py
+++ b/cluster_upgrade/tests/test_upgrade.py
@@ -97,8 +97,16 @@ class TestUpgradeHelperCloneCluster(base_tests.BaseCloneClusterTest):
97 97
98 self.helper.copy_attributes(self.src_cluster, new_cluster) 98 self.helper.copy_attributes(self.src_cluster, new_cluster)
99 99
100 self.assertEqual(self.src_cluster.generated_attrs, 100 self.assertNotEqual(new_cluster.generated_attrs.get('provision'),
101 new_cluster.generated_attrs) 101 self.src_cluster.generated_attrs.get('provision'))
102
103 # We make image_data in src_cluster and in new_cluster the same
104 # to validate that all other generated attributes are equal
105 generated_attrs = copy.deepcopy(self.src_cluster.generated_attrs)
106 generated_attrs['provision']['image_data'] = \
107 new_cluster.generated_attrs['provision']['image_data']
108
109 self.assertEqual(generated_attrs, new_cluster.generated_attrs)
102 editable_attrs = self.src_cluster.editable_attrs 110 editable_attrs = self.src_cluster.editable_attrs
103 for section, params in six.iteritems(new_cluster.editable_attrs): 111 for section, params in six.iteritems(new_cluster.editable_attrs):
104 if section == "repo_setup": 112 if section == "repo_setup":
@@ -211,3 +219,22 @@ class TestUpgradeHelperCloneCluster(base_tests.BaseCloneClusterTest):
211 self.helper.copy_attributes(self.src_cluster, new_cluster) 219 self.helper.copy_attributes(self.src_cluster, new_cluster)
212 self._check_dns_and_ntp_list_values( 220 self._check_dns_and_ntp_list_values(
213 new_cluster, ["4", "5", "6"], ["1", "2", "3"]) 221 new_cluster, ["4", "5", "6"], ["1", "2", "3"])
222
223 def test_change_env_settings(self):
224 new_cluster = self.helper.create_cluster_clone(self.src_cluster,
225 self.data)
226 self.helper.copy_attributes(self.src_cluster, new_cluster)
227 attrs = new_cluster.attributes
228 self.helper.change_env_settings(self.src_cluster, new_cluster)
229 self.assertEqual('image',
230 attrs['editable']['provision']['method']['value'])
231
232 def test_change_env_settings_no_editable_provision(self):
233 new_cluster = self.helper.create_cluster_clone(self.src_cluster,
234 self.data)
235 self.helper.copy_attributes(self.src_cluster, new_cluster)
236 attrs = new_cluster.attributes
237 attrs['editable']['provision']['method']['value'] = 'cobbler'
238 self.helper.change_env_settings(self.src_cluster, new_cluster)
239 self.assertEqual('image',
240 attrs['editable']['provision']['method']['value'])
diff --git a/cluster_upgrade/upgrade.py b/cluster_upgrade/upgrade.py
index e0792c0..939cc4a 100644
--- a/cluster_upgrade/upgrade.py
+++ b/cluster_upgrade/upgrade.py
@@ -53,6 +53,13 @@ def merge_attributes(a, b):
53 return attrs 53 return attrs
54 54
55 55
56def merge_generated_attrs(new_attrs, orig_attrs):
57 # skip attributes that should be generated for new cluster
58 attrs = copy.deepcopy(orig_attrs)
59 attrs.pop('provision', None)
60 return utils.dict_merge(new_attrs, attrs)
61
62
56def merge_nets(a, b): 63def merge_nets(a, b):
57 new_settings = copy.deepcopy(b) 64 new_settings = copy.deepcopy(b)
58 source_networks = dict((n["name"], n) for n in a["networks"]) 65 source_networks = dict((n["name"], n) for n in a["networks"])
@@ -90,6 +97,7 @@ class UpgradeHelper(object):
90 cls.copy_network_config(orig_cluster, new_cluster) 97 cls.copy_network_config(orig_cluster, new_cluster)
91 relations.UpgradeRelationObject.create_relation(orig_cluster.id, 98 relations.UpgradeRelationObject.create_relation(orig_cluster.id,
92 new_cluster.id) 99 new_cluster.id)
100 cls.change_env_settings(orig_cluster, new_cluster)
93 return new_cluster 101 return new_cluster
94 102
95 @classmethod 103 @classmethod
@@ -110,7 +118,7 @@ class UpgradeHelper(object):
110 # version to another. A set of this kind of steps 118 # version to another. A set of this kind of steps
111 # should define an upgrade path of a particular 119 # should define an upgrade path of a particular
112 # cluster. 120 # cluster.
113 new_cluster.generated_attrs = utils.dict_merge( 121 new_cluster.generated_attrs = merge_generated_attrs(
114 new_cluster.generated_attrs, 122 new_cluster.generated_attrs,
115 orig_cluster.generated_attrs) 123 orig_cluster.generated_attrs)
116 new_cluster.editable_attrs = merge_attributes( 124 new_cluster.editable_attrs = merge_attributes(
@@ -118,6 +126,11 @@ class UpgradeHelper(object):
118 new_cluster.editable_attrs) 126 new_cluster.editable_attrs)
119 127
120 @classmethod 128 @classmethod
129 def change_env_settings(cls, orig_cluster, new_cluster):
130 attrs = new_cluster.attributes
131 attrs['editable']['provision']['method']['value'] = 'image'
132
133 @classmethod
121 def transform_vips_for_net_groups_70(cls, vips): 134 def transform_vips_for_net_groups_70(cls, vips):
122 """Rename or remove types of VIPs for 7.0 network groups. 135 """Rename or remove types of VIPs for 7.0 network groups.
123 136