]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
get_network in nvp plugin didn't return subnet information
authorAaron Rosen <arosen@nicira.com>
Thu, 4 Oct 2012 23:18:58 +0000 (16:18 -0700)
committerAaron Rosen <arosen@nicira.com>
Thu, 4 Oct 2012 23:22:34 +0000 (16:22 -0700)
Adds unit test for show network which checks for subnet.

Fixes bug 1061781

Change-Id: I459a1f11a9e4294c31d002c8dbcfde873e43c800

quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py
quantum/tests/unit/test_db_plugin.py

index a753a479bd0c67fc09b4fe43d776933760422c0c..9c08dfd7a16593331458ff36714d4bb8f9481496 100644 (file)
@@ -453,13 +453,15 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
         if 'lswitch-display-name' not in result:
             raise exception.NetworkNotFound(net_id=id)
 
+        # Fetch network in quantum
+        quantum_db = super(NvpPluginV2, self).get_network(context, id, fields)
         d = {'id': id,
              'name': result['lswitch-display-name'],
              'tenant_id': network['tenant_id'],
              'admin_state_up': True,
              'status': constants.NET_STATUS_ACTIVE,
              'shared': network['shared'],
-             'subnets': []}
+             'subnets': quantum_db.get('subnets', [])}
 
         LOG.debug("get_network() completed for tenant %s: %s" % (
                   context.tenant_id, d))
index 87789ac4e5999a591474cc794bf463aabb9390ce..00cd0933175d0f83c01b57df9bf841304bef45bb 100644 (file)
@@ -1670,6 +1670,14 @@ class TestNetworksV2(QuantumDbPluginV2TestCase):
             self.assertEquals(res['network']['name'],
                               net['network']['name'])
 
+    def test_show_network_with_subnet(self):
+        with self.network(name='net1') as net:
+            with self.subnet(net) as subnet:
+                req = self.new_show_request('networks', net['network']['id'])
+                res = self.deserialize('json', req.get_response(self.api))
+                self.assertEquals(res['network']['subnets'][0],
+                                  subnet['subnet']['id'])
+
     def test_invalid_admin_status(self):
         fmt = 'json'
         value = [[7, False, 400], [True, True, 201], ["True", True, 201],