Skip to content

Commit

Permalink
let metaplugin work with plugin which has not l3 extension support
Browse files Browse the repository at this point in the history
Fixes bug 1074183
Also Fixes bug 1074184 ( fix get_nework call with fields)

Change-Id: I3bfdb22dd3be8a58cd884629dc5e3385730bb1bc
  • Loading branch information
Nachi Ueno committed Nov 1, 2012
1 parent 6b9784a commit decb42d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions quantum/plugins/metaplugin/meta_quantum_plugin.py
Expand Up @@ -153,7 +153,9 @@ def _extend_network_dict(self, context, network):
network[FLAVOR_NETWORK] = flavor

def _is_l3_plugin(self, plugin):
return 'router' in plugin.supported_extension_aliases
if hasattr(plugin, 'supported_extension_aliases'):
return 'router' in plugin.supported_extension_aliases
return False

def create_network(self, context, network):
n = network['network']
Expand Down Expand Up @@ -204,7 +206,7 @@ def get_network(self, context, id, fields=None):
self._extend_network_dict_l3(context, net)
if not fields or FLAVOR_NETWORK in fields:
self._extend_network_dict(context, net)
if fields and not id in fields:
if fields and not 'id' in fields:
del net['id']
return net

Expand Down
11 changes: 11 additions & 0 deletions quantum/tests/unit/test_db_plugin.py
Expand Up @@ -1666,6 +1666,17 @@ def test_list_networks_with_parameters(self):
self.assertEquals(res['networks'][0]['name'],
net2['network']['name'])

def test_list_networks_with_fields(self):
with self.network(name='net1') as net1:
req = self.new_list_request('networks',
params='fields=name')
res = self.deserialize('json', req.get_response(self.api))
self.assertEquals(1, len(res['networks']))
self.assertEquals(res['networks'][0]['name'],
net1['network']['name'])
self.assertEquals(None,
res['networks'][0].get('id'))

def test_list_networks_with_parameters_invalid_values(self):
with self.network(name='net1', admin_status_up=False) as net1:
with self.network(name='net2') as net2:
Expand Down

0 comments on commit decb42d

Please sign in to comment.