summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Nikishov <dnikishov@mirantis.com>2016-12-07 11:45:57 +0400
committerDmitry Nikishov <dnikishov@mirantis.com>2016-12-09 12:58:04 +0400
commit36f3d95a471c231f2c1fafc9b2d74c7d24753899 (patch)
tree9dcb5135299b1200ec53c84ab1f3aa4b909828d6
parent89839b88c37c38ac59a3ecb9453a1f3253c28583 (diff)
Set vip_namespace when migrating vips from 6.x
Notes
Notes (review): Code-Review+2: Roman Sokolkov <rsokolkov@mirantis.com> Workflow+1: Roman Sokolkov <rsokolkov@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 28 Dec 2016 15:01:55 +0000 Reviewed-on: https://review.openstack.org/407910 Project: openstack/fuel-nailgun-extension-cluster-upgrade Branch: refs/heads/master
-rw-r--r--cluster_upgrade/tests/test_transformations.py27
-rw-r--r--cluster_upgrade/transformations/vip.py13
2 files changed, 28 insertions, 12 deletions
diff --git a/cluster_upgrade/tests/test_transformations.py b/cluster_upgrade/tests/test_transformations.py
index ef0844f..22c4b09 100644
--- a/cluster_upgrade/tests/test_transformations.py
+++ b/cluster_upgrade/tests/test_transformations.py
@@ -252,33 +252,36 @@ class TestClusterTransformers(nailgun_test_base.BaseUnitTest):
252 252
253class TestVipTransformers(nailgun_test_base.BaseUnitTest): 253class TestVipTransformers(nailgun_test_base.BaseUnitTest):
254 def setUp(self): 254 def setUp(self):
255 ip = '0.0.0.0' 255 vip_dict = {'ip_addr': '0.0.0.0'}
256 self.data = { 256 self.data = {
257 1: { 257 1: {
258 'haproxy': ip, 258 'haproxy': dict(vip_dict),
259 'vrouter': ip, 259 'vrouter': dict(vip_dict),
260 'test': ip, 260 'test': dict(vip_dict),
261 }, 261 },
262 2: { 262 2: {
263 'haproxy': ip, 263 'haproxy': dict(vip_dict),
264 'vrouter': ip, 264 'vrouter': dict(vip_dict),
265 'test': ip, 265 'test': dict(vip_dict),
266 } 266 }
267 } 267 }
268 self.mapping = {1: 'management', 2: 'public'} 268 self.mapping = {1: 'management', 2: 'public'}
269 269
270 def test_vip_transform(self): 270 def test_vip_transform(self):
271 ip = '0.0.0.0' 271 new_haproxy_vip_dict = {'ip_addr': '0.0.0.0',
272 'vip_namespace': 'haproxy'}
273 new_vrouter_vip_dict = {'ip_addr': '0.0.0.0',
274 'vip_namespace': 'vrouter'}
272 275
273 data = vip.transform_vips((self.data, self.mapping)) 276 data = vip.transform_vips((self.data, self.mapping))
274 self.assertEqual( 277 self.assertEqual(
275 data, ({ 278 data, ({
276 1: { 279 1: {
277 'management': ip, 280 'management': new_haproxy_vip_dict,
278 'vrouter': ip, 281 'vrouter': new_vrouter_vip_dict,
279 }, 282 },
280 2: { 283 2: {
281 'public': ip, 284 'public': new_haproxy_vip_dict,
282 'vrouter_pub': ip, 285 'vrouter_pub': new_vrouter_vip_dict,
283 }}, {1: 'management', 2: 'public'}) 286 }}, {1: 'management', 2: 'public'})
284 ) 287 )
diff --git a/cluster_upgrade/transformations/vip.py b/cluster_upgrade/transformations/vip.py
index 350cc0a..485e771 100644
--- a/cluster_upgrade/transformations/vip.py
+++ b/cluster_upgrade/transformations/vip.py
@@ -41,6 +41,12 @@ def transform_vips(data):
41 "vrouter": "vrouter_pub", 41 "vrouter": "vrouter_pub",
42 }, 42 },
43 } 43 }
44 vip_ns_rules = {
45 "vrouter": "vrouter",
46 "vrouter_pub": "vrouter",
47 "public": "haproxy",
48 "management": "haproxy",
49 }
44 renamed_vips = collections.defaultdict(dict) 50 renamed_vips = collections.defaultdict(dict)
45 vips, id_name_mapping = data 51 vips, id_name_mapping = data
46 for ng_id, vips_obj in vips.items(): 52 for ng_id, vips_obj in vips.items():
@@ -50,6 +56,13 @@ def transform_vips(data):
50 continue 56 continue
51 57
52 new_vip_name = ng_vip_rules[vip_name] 58 new_vip_name = ng_vip_rules[vip_name]
59 # When migrating from 6.x, vip_namespace key is not set for
60 # public/management vips
61 if not vip_addr.get('vip_namespace', None) and \
62 new_vip_name in vip_ns_rules:
63 vip_ns = vip_ns_rules[new_vip_name]
64 vip_addr['vip_namespace'] = vip_ns
65
53 renamed_vips[ng_id][new_vip_name] = vip_addr 66 renamed_vips[ng_id][new_vip_name] = vip_addr
54 67
55 return renamed_vips, id_name_mapping 68 return renamed_vips, id_name_mapping