get_network in nvp plugin didn't return subnet information

Adds unit test for show network which checks for subnet.

Fixes bug 1061781

Change-Id: I459a1f11a9e4294c31d002c8dbcfde873e43c800
This commit is contained in:
Aaron Rosen 2012-10-04 16:18:58 -07:00 committed by Gary Kotton
parent 632e3c8d5a
commit 2504f62821
2 changed files with 11 additions and 1 deletions

View 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))

View File

@ -1683,6 +1683,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],