Merge lp:~jtv/maas/validate-network-nodes-filter into lp:~maas-committers/maas/trunk
Proposed by
Jeroen T. Vermeulen
Status: | Merged |
---|---|
Approved by: | Jeroen T. Vermeulen |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1941 |
Proposed branch: | lp:~jtv/maas/validate-network-nodes-filter |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
129 lines (+68/-8) 3 files modified
src/maasserver/api.py (+6/-7) src/maasserver/forms.py (+41/-1) src/maasserver/tests/test_api_networks.py (+21/-0) |
To merge this branch: | bzr merge lp:~jtv/maas/validate-network-nodes-filter |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raphaël Badin (community) | Approve | ||
Review via email: mp+205972@code.launchpad.net |
Commit message
Handle the API GET request to list networks through a form. This fixes the lack of validation: passing multiple nodes means "networks connected to *all* of these nodes," so quietly ignoring unknown nodes could lead to unwanted results.
Description of the change
Raphaël suggested that more API calls ought to do this, so see it as a prototype for possible repeated use.
Jeroen
To post a comment you must log in.
Very nice!
[0]
24 + if nodes is not None: filter( node=node) order_by( 'name')
25 + for node in nodes:
26 networks = networks.
27 return networks.
Ideally, I think this logic (the filtering and the order_by) belongs to the form (same as the usual call to form.save() when the form is a modification/ creation form).