Browse Source

Set vip_namespace when migrating vips from 6.x

Change-Id: I7d76f7984a1870c070126b0ccde160f320576cf3
Dmitry Nikishov 2 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):
252 252
 
253 253
 class TestVipTransformers(nailgun_test_base.BaseUnitTest):
254 254
     def setUp(self):
255
-        ip = '0.0.0.0'
255
+        vip_dict = {'ip_addr': '0.0.0.0'}
256 256
         self.data = {
257 257
             1: {
258
-                'haproxy': ip,
259
-                'vrouter': ip,
260
-                'test': ip,
258
+                'haproxy': dict(vip_dict),
259
+                'vrouter': dict(vip_dict),
260
+                'test': dict(vip_dict),
261 261
             },
262 262
             2: {
263
-                'haproxy': ip,
264
-                'vrouter': ip,
265
-                'test': ip,
263
+                'haproxy': dict(vip_dict),
264
+                'vrouter': dict(vip_dict),
265
+                'test': dict(vip_dict),
266 266
             }
267 267
         }
268 268
         self.mapping = {1: 'management', 2: 'public'}
269 269
 
270 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 276
         data = vip.transform_vips((self.data, self.mapping))
274 277
         self.assertEqual(
275 278
             data, ({
276 279
                 1: {
277
-                    'management': ip,
278
-                    'vrouter': ip,
280
+                    'management': new_haproxy_vip_dict,
281
+                    'vrouter': new_vrouter_vip_dict,
279 282
                 },
280 283
                 2: {
281
-                    'public': ip,
282
-                    'vrouter_pub': ip,
284
+                    'public': new_haproxy_vip_dict,
285
+                    'vrouter_pub': new_vrouter_vip_dict,
283 286
                 }}, {1: 'management', 2: 'public'})
284 287
         )

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

@@ -41,6 +41,12 @@ def transform_vips(data):
41 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 50
     renamed_vips = collections.defaultdict(dict)
45 51
     vips, id_name_mapping = data
46 52
     for ng_id, vips_obj in vips.items():
@@ -50,6 +56,13 @@ def transform_vips(data):
50 56
                 continue
51 57
 
52 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 66
             renamed_vips[ng_id][new_vip_name] = vip_addr
54 67
 
55 68
     return renamed_vips, id_name_mapping

Loading…
Cancel
Save