Merge lp:~salvatore-orlando/neutron/bug834012 into lp:neutron/diablo

Proposed by Salvatore Orlando
Status: Work in progress
Proposed branch: lp:~salvatore-orlando/neutron/bug834012
Merge into: lp:neutron/diablo
Diff against target: 78 lines (+19/-16)
3 files modified
quantum/api/networks.py (+10/-7)
quantum/api/views/networks.py (+3/-3)
quantum/plugins/SamplePlugin.py (+6/-6)
To merge this branch: bzr merge lp:~salvatore-orlando/neutron/bug834012
Reviewer Review Type Date Requested Status
dan wendlandt Needs Fixing
Review via email: mp+73687@code.launchpad.net

Description of the change

This branch targets two bugs:

Bug #834012: API: GET networks/{net_id}/detail is inefficient
Bug #837535: plugins do not comply with quantum_plugin_interface

They are both addressed by this branch as they are strictly related.
For Bug #834012 - changed the _item method code in the network API controller in order to avoid unnecessary calls to the plugin. The view builder was also adapted for taking into account this change.
For Bug #837535 - simply updated the documentation of quantum plugin base to state that get_network_details should return an attribute called net-ports with a sequence of ports. This seems a reasonable thing to do, as this is the way in which the currently available plugins work. Morever, and this is just my personal opinion, net-ports makes more sense than net-iface (which return the interface list only).

I realize a change in the plugin interface will probably require a deeper discussion. Please feel free to disapprove this branch if you don't agree with the proposed change.

Also, you'll see a small change in SamplePlugin. This is because it was not 100% compliant with the plugin interface.

To post a comment you must log in.
Revision history for this message
dan wendlandt (danwent) wrote :

Hi Salvatore, thanks for taking care of this. I definitely agree with the goal of the patch, my only concern about timing. In general, since it seems like none of these bugs impair the correct operation of quantum, my bias would be to avoid making this change unless we have high confidence that we're not breaking plugins.

I downloaded the branch and ran unit tests with the OVS plugin and they seemed to pass. Is your feeling that the same would be true for other plugins?

Given that not all plugins have to be part of the Quantum repo, I'm still a bit wary of making a change so late, so at the very least we'd need to send an email to the list describing how plugins would have to change (assuming they were written to spec) and see if anyone raises a concern.

review: Needs Information
Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

> Hi Salvatore, thanks for taking care of this. I definitely agree with the
> goal of the patch, my only concern about timing. In general, since it seems
> like none of these bugs impair the correct operation of quantum, my bias would
> be to avoid making this change unless we have high confidence that we're not
> breaking plugins.

I don't see any urgent reason for merging this bug fix before rbp.

>
> I downloaded the branch and ran unit tests with the OVS plugin and they seemed
> to pass. Is your feeling that the same would be true for other plugins?

I don't think so, as the change in the plugin interface is just in the documentation. Basically, what I've done is making sure the documentation of get_network_details is aligned with what the plugins actually do.

>
> Given that not all plugins have to be part of the Quantum repo, I'm still a
> bit wary of making a change so late, so at the very least we'd need to send an
> email to the list describing how plugins would have to change (assuming they
> were written to spec) and see if anyone raises a concern.

Agreed. I will try and provide a different fix that does not change the plugin interface.
I thinj the blukprint Somik recently submitted is aimed at making sure plugins fully comply with the plugin interface.

Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

Reverting to WIP for fixing the API behaviour without affecting the plugin interface.

Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

Updated the code for addressing bug #834012 only

64. By Salvatore Orlando

Fuxing bug #834012 only

Revision history for this message
dan wendlandt (danwent) wrote :

In general I'm hesitant make changes at this in the release cycle that do not improve test coverage or fix a real correctness problem, as they can have unintended consequences. We can make this change if you like, but the fewer the better in my opinion.

I don't think this branch does quite what you're looking to do. I believe you want it to be OK for a plugin to return a network diction that does not contain "net-ports", but it actually will cause an exception in that case.

You probably want to replace:

if not network['net-ports']:

with

if not 'net-ports' in network:

The former will throw a KeyError if 'net-ports' is not in the networks dictionary.

Otherwise it looks good, though we'll want to make sure that we get around to updating the plugins to take advantage of the more efficient approach in essex. I can file a bug against the OVS plugin.

review: Needs Fixing
65. By Salvatore Orlando

Addressing Dan's comment

Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

> In general I'm hesitant make changes at this in the release cycle that do not
> improve test coverage or fix a real correctness problem, as they can have
> unintended consequences. We can make this change if you like, but the fewer
> the better in my opinion.

I'm not either a big fan of this change anymore. This change does not fix anything, it is more a "quick and dirty" patch for making the detail operation more efficient.

>
> I don't think this branch does quite what you're looking to do. I believe you
> want it to be OK for a plugin to return a network diction that does not
> contain "net-ports", but it actually will cause an exception in that case.
>
> You probably want to replace:
>
> if not network['net-ports']:
>
> with
>
> if not 'net-ports' in network:
>

Thanks for pointing this out. The branch has been updated.

> The former will throw a KeyError if 'net-ports' is not in the networks
> dictionary.
>
> Otherwise it looks good, though we'll want to make sure that we get around to
> updating the plugins to take advantage of the more efficient approach in
> essex. I can file a bug against the OVS plugin.

I'd say we should fix this bug in Essex as well.
I'll revert the MP to WIP, and then discuss this bug fix at today's meeting.

Unmerged revisions

65. By Salvatore Orlando

Addressing Dan's comment

64. By Salvatore Orlando

Fuxing bug #834012 only

63. By Salvatore Orlando

Now properly doing the commit.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'quantum/api/networks.py'
2--- quantum/api/networks.py 2011-08-17 21:48:56 +0000
3+++ quantum/api/networks.py 2011-09-06 09:13:02 +0000
4@@ -52,14 +52,17 @@
5 # concerning logical ports as well.
6 network = self._plugin.get_network_details(
7 tenant_id, network_id)
8- port_list = self._plugin.get_all_ports(
9- tenant_id, network_id)
10- ports_data = [self._plugin.get_port_details(
11- tenant_id, network_id, port['port-id'])
12- for port in port_list]
13+ # We try to leverage the fact that current plugin
14+ # return a net-ports structure. However, do not bet
15+ # on it, as it is not sanctioned by the plugin interface
16+ if not 'net-ports' in network:
17+ port_list = self._plugin.get_all_ports(tenant_id, network_id)
18+ ports_data = [self._plugin.get_port_details(
19+ tenant_id, network_id, port['port-id'])
20+ for port in port_list]
21+ network['net-ports'] = ports_data
22 builder = networks_view.get_view_builder(req)
23- result = builder.build(network, net_details,
24- ports_data, port_details)['network']
25+ result = builder.build(network, net_details, port_details)['network']
26 return dict(network=result)
27
28 def _items(self, req, tenant_id, net_details=False):
29
30=== modified file 'quantum/api/views/networks.py'
31--- quantum/api/views/networks.py 2011-08-25 17:50:05 +0000
32+++ quantum/api/views/networks.py 2011-09-06 09:13:02 +0000
33@@ -29,15 +29,15 @@
34 """
35 self.base_url = base_url
36
37- def build(self, network_data, net_detail=False,
38- ports_data=None, port_detail=False):
39+ def build(self, network_data, net_detail=False, port_detail=False):
40 """Generic method used to generate a network entity."""
41 if net_detail:
42 network = self._build_detail(network_data)
43 else:
44 network = self._build_simple(network_data)
45 if port_detail:
46- ports = [self._build_port(port_data) for port_data in ports_data]
47+ ports = [self._build_port(port_data)
48+ for port_data in network_data['net-ports']]
49 network['network']['ports'] = ports
50 return network
51
52
53=== modified file 'quantum/plugins/SamplePlugin.py'
54--- quantum/plugins/SamplePlugin.py 2011-09-01 16:17:36 +0000
55+++ quantum/plugins/SamplePlugin.py 2011-09-06 09:13:02 +0000
56@@ -234,16 +234,16 @@
57
58 def get_all_ports(self, tenant_id, net_id):
59 """
60- Retrieves all port identifiers belonging to the
61+ Retrieves all ports belonging to the
62 specified Virtual Network.
63 """
64 LOG.debug("FakePlugin.get_all_ports() called")
65- port_ids = []
66+ port_data = []
67 ports = db.port_list(net_id)
68- for x in ports:
69- d = {'port-id': str(x.uuid)}
70- port_ids.append(d)
71- return port_ids
72+ for port in ports:
73+ port_data.append(self.get_port_details(tenant_id,
74+ net_id, port.uuid))
75+ return port_data
76
77 def get_port_details(self, tenant_id, net_id, port_id):
78 """

Subscribers

People subscribed via source and target branches