]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Send network name and uuid to subnet create
authorSteven Hillman <sthillma@cisco.com>
Tue, 8 Jul 2014 22:35:10 +0000 (15:35 -0700)
committerSteven Hillman <sthillma@cisco.com>
Mon, 14 Jul 2014 23:16:58 +0000 (16:16 -0700)
Added the network segment name and uuid parameters to the infomation sent to
Cisco N1kV during subnet creation to allow for proper association of the
subnet and network segment.

Change-Id: I375d49ec43f79360189ecf5de0583873b8039db9
Closes-Bug: 1332713

neutron/plugins/cisco/n1kv/n1kv_client.py
neutron/tests/unit/cisco/n1kv/fake_client.py
neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py

index b98d76ba1a48996b91df41f90c0badd8a1aa0e0b..5a400dec48fa50a9d27aca714fcef0e0cd46e559 100644 (file)
@@ -313,6 +313,8 @@ class Client(object):
                 'dhcp': subnet['enable_dhcp'],
                 'dnsServersList': subnet['dns_nameservers'],
                 'networkAddress': network_address,
+                'netSegmentName': subnet['network_id'],
+                'id': subnet['id'],
                 'tenantId': subnet['tenant_id']}
         return self._post(self.ip_pool_path % subnet['id'],
                           body=body)
index 7de5e1f08a51e4127c06a75cbbfcb7aa6cf2ec0b..b35d331197bfd79e426440dc042ca802bb14a703 100755 (executable)
@@ -26,7 +26,11 @@ _resource_metadata = {'port': ['id', 'macAddress', 'ipAddress', 'subnetId'],
                                     'networkSegment', 'portProfile',
                                     'portProfileId', 'tenantId',
                                     'portId', 'macAddress',
-                                    'ipAddress', 'subnetId']}
+                                    'ipAddress', 'subnetId'],
+                      'subnet': ['addressRangeStart', 'addressRangeEnd',
+                                 'ipAddressSubnet', 'description', 'gateway',
+                                 'dhcp', 'dnsServersList', 'networkAddress',
+                                 'netSegmentName', 'id', 'tenantId']}
 
 
 class TestClient(n1kv_client.Client):
@@ -75,6 +79,10 @@ def _validate_resource(action, body=None):
         port_set = set(_resource_metadata['port'])
         if body_set - port_set:
             raise c_exc.VSMError(reason='Invalid Request')
+    elif 'subnet' in action:
+        subnet_set = set(_resource_metadata['subnet'])
+        if body_set - subnet_set:
+            raise c_exc.VSMError(reason='Invalid Request')
     else:
         return
 
index 591d1309f32db9a899ab2cc27a81ece3d7f69702..1d1092b6a879a06653d6a5cafa9000ba6fa686ee 100644 (file)
@@ -696,6 +696,19 @@ class TestN1kvSubnets(test_plugin.TestSubnetsV2,
     def setUp(self):
         super(TestN1kvSubnets, self).setUp()
 
+    def test_create_subnet_with_invalid_parameters(self):
+        """Test subnet creation with invalid parameters sent to the VSM"""
+        with self.network() as network:
+            client_patch = mock.patch(n1kv_client.__name__ + ".Client",
+                                      new=fake_client.TestClientInvalidRequest)
+            client_patch.start()
+            data = {'subnet': {'network_id': network['network']['id'],
+                               'cidr': "10.0.0.0/24"}}
+            subnet_req = self.new_create_request('subnets', data)
+            subnet_resp = subnet_req.get_response(self.api)
+            # Subnet creation should fail due to invalid network name
+            self.assertEqual(subnet_resp.status_int, 400)
+
 
 class TestN1kvL3Test(test_l3_plugin.L3NatExtensionTestCase):