]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
fix nvp version validation for distributed router creation
authorarmando-migliaccio <amigliaccio@nicira.com>
Wed, 23 Oct 2013 18:20:01 +0000 (11:20 -0700)
committerarmando-migliaccio <amigliaccio@nicira.com>
Wed, 23 Oct 2013 19:11:29 +0000 (12:11 -0700)
Fix typo on major version. This was not caught during unit tests
so adds a few to ensure this does not regress.

Fix bug #1243862

Change-Id: Ie136aaa504939d8ac77dda07e3f955aed8c233f9

neutron/plugins/nicira/nvplib.py
neutron/tests/unit/nicira/fake_nvpapiclient.py
neutron/tests/unit/nicira/test_nicira_plugin.py

index 37802f1d5b8a8b1108bf33eb3e66ca94300c3969..181d35fb2ea854af2753f81c62edac896a89ff75 100644 (file)
@@ -383,7 +383,7 @@ def create_explicit_routing_lrouter(cluster, tenant_id,
 def create_lrouter(cluster, *args, **kwargs):
     if kwargs.get('distributed', None):
         v = cluster.api_client.get_nvp_version()
-        if (v.major < 3) or (v.major >= 3 and v.minor < 1):
+        if (v.major < 3) or (v.major == 3 and v.minor < 1):
             raise nvp_exc.NvpInvalidVersion(version=v)
         return v
 
index b1eb31bfd1c55490f511fa9d87389e70c64e2db6..577be6c51fd71237547ef05af46c045a75063409 100644 (file)
@@ -175,8 +175,11 @@ class FakeClient:
         fake_lrouter['tenant_id'] = self._get_tag(fake_lrouter, 'os_tid')
         default_nexthop = fake_lrouter['routing_config'].get(
             'default_route_next_hop')
-        fake_lrouter['default_next_hop'] = default_nexthop.get(
-            'gateway_ip_address', '0.0.0.0')
+        if default_nexthop:
+            fake_lrouter['default_next_hop'] = default_nexthop.get(
+                'gateway_ip_address', '0.0.0.0')
+        else:
+            fake_lrouter['default_next_hop'] = '0.0.0.0'
         # NOTE(salv-orlando): We won't make the Fake NVP API client
         # aware of NVP version. The long term plan is to replace it
         # with behavioral mocking of NVP API requests
index dbbbf8f1d12eeaad189e052d8cbc48c1771b6d93..5bb369b438db6261f972f8bd06eb569affaad287 100644 (file)
@@ -593,9 +593,15 @@ class TestNiciraL3NatTestCase(NiciraL3NatTest,
             if res.status_int == 201:
                 self._delete('routers', router['router']['id'])
 
-    def test_router_create_distributed(self):
+    def test_router_create_distributed_with_3_1(self):
         self._test_router_create_with_distributed(True, True)
 
+    def test_router_create_distributed_with_new_nvp_versions(self):
+        with mock.patch.object(nvplib, 'create_explicit_route_lrouter'):
+            self._test_router_create_with_distributed(True, True, '3.2')
+            self._test_router_create_with_distributed(True, True, '4.0')
+            self._test_router_create_with_distributed(True, True, '4.1')
+
     def test_router_create_not_distributed(self):
         self._test_router_create_with_distributed(False, False)