Browse Source

Set vip_namespace when migrating vips from 6.x

Change-Id: I7d76f7984a1870c070126b0ccde160f320576cf3
changes/10/407910/8
Dmitry Nikishov 3 years ago
parent
commit
36f3d95a47
2 changed files with 28 additions and 12 deletions
  1. +15
    -12
      cluster_upgrade/tests/test_transformations.py
  2. +13
    -0
      cluster_upgrade/transformations/vip.py

+ 15
- 12
cluster_upgrade/tests/test_transformations.py View File

@@ -252,33 +252,36 @@ class TestClusterTransformers(nailgun_test_base.BaseUnitTest):

class TestVipTransformers(nailgun_test_base.BaseUnitTest):
def setUp(self):
ip = '0.0.0.0'
vip_dict = {'ip_addr': '0.0.0.0'}
self.data = {
1: {
'haproxy': ip,
'vrouter': ip,
'test': ip,
'haproxy': dict(vip_dict),
'vrouter': dict(vip_dict),
'test': dict(vip_dict),
},
2: {
'haproxy': ip,
'vrouter': ip,
'test': ip,
'haproxy': dict(vip_dict),
'vrouter': dict(vip_dict),
'test': dict(vip_dict),
}
}
self.mapping = {1: 'management', 2: 'public'}

def test_vip_transform(self):
ip = '0.0.0.0'
new_haproxy_vip_dict = {'ip_addr': '0.0.0.0',
'vip_namespace': 'haproxy'}
new_vrouter_vip_dict = {'ip_addr': '0.0.0.0',
'vip_namespace': 'vrouter'}

data = vip.transform_vips((self.data, self.mapping))
self.assertEqual(
data, ({
1: {
'management': ip,
'vrouter': ip,
'management': new_haproxy_vip_dict,
'vrouter': new_vrouter_vip_dict,
},
2: {
'public': ip,
'vrouter_pub': ip,
'public': new_haproxy_vip_dict,
'vrouter_pub': new_vrouter_vip_dict,
}}, {1: 'management', 2: 'public'})
)

+ 13
- 0
cluster_upgrade/transformations/vip.py View File

@@ -41,6 +41,12 @@ def transform_vips(data):
"vrouter": "vrouter_pub",
},
}
vip_ns_rules = {
"vrouter": "vrouter",
"vrouter_pub": "vrouter",
"public": "haproxy",
"management": "haproxy",
}
renamed_vips = collections.defaultdict(dict)
vips, id_name_mapping = data
for ng_id, vips_obj in vips.items():
@@ -50,6 +56,13 @@ def transform_vips(data):
continue

new_vip_name = ng_vip_rules[vip_name]
# When migrating from 6.x, vip_namespace key is not set for
# public/management vips
if not vip_addr.get('vip_namespace', None) and \
new_vip_name in vip_ns_rules:
vip_ns = vip_ns_rules[new_vip_name]
vip_addr['vip_namespace'] = vip_ns

renamed_vips[ng_id][new_vip_name] = vip_addr

return renamed_vips, id_name_mapping


Loading…
Cancel
Save