Merge lp:~jtv/maas/api-list-networks 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: | 1917 |
Proposed branch: | lp:~jtv/maas/api-list-networks |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
157 lines (+89/-6) 3 files modified
src/maasserver/api.py (+15/-5) src/maasserver/tests/test_api_networks.py (+70/-0) src/maasserver/urls_api.py (+4/-1) |
To merge this branch: | bzr merge lp:~jtv/maas/api-list-networks |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raphaël Badin (community) | Approve | ||
Review via email: mp+205525@code.launchpad.net |
Commit message
"List networks" API call.
Description of the change
In doing this I noticed a change in our API style: where we used to write "list" operations for the "plural" resources, unless we need to parameterise the listing, we now just implement GET on the resource. So to list all nodes, you call the nodes handler's list() method, but to list all zones, you just GET ".../zones/". I followed the new style here, but I'm not sure the CLI can deal with this. Maybe we ought to have both for all resources.
Jeroen
To post a comment you must log in.
[0]
50 === added file 'src/maasserver /tests/ test_api_ networks. py' returns_ network( self):
[...]
83 + def test_list_
The name of this test is strange. One would expect test_list_ returns_ network* s*
[1]
50 === added file 'src/maasserver /tests/ test_api_ networks. py' returns_ network( self):
[...]
83 + def test_list_
I put a break point in this test and look:
(Pdb) parsed_result db.models. base.ModelState object at 0x962acd0>', u'netmask': u'255.255.192.0', u'vlan_tag': None, u'id': 1, u'name': u'6THuCI'}]
[{u'description': u'tjBXqFQ7vK', u'ip': u'217.187.192.0', u'_state': u'<django.
Django adds clutter to the objects (I'm talking about the '_state' field) so we need to explicitly list the fields that we want to return.
[2]
50 === added file 'src/maasserver /tests/ test_api_ networks. py' network. name, network. ip, network. netmask, network. vlan_tag, network. description, network[ 'name'] , network[ 'ip'], network[ 'netmask' ], network[ 'vlan_tag' ], network[ 'description' ],
[...]
93 + (
94 + original_
95 + original_
96 + original_
97 + original_
98 + original_
99 + ),
100 + (
101 + returned_
102 + returned_
103 + returned_
104 + returned_
105 + returned_
106 + ))
Couldn't this benefit from self.assertAttr ibutes?
[3]
50 === added file 'src/maasserver /tests/ test_api_ networks. py' network. name, network. ip, network. netmask, network. vlan_tag, network. description, network[ 'name'] , network[ 'ip'], network[ 'netmask' ], network[ 'vlan_tag' ], network[ 'description' ],
[...]
93 + (
94 + original_
95 + original_
96 + original_
97 + original_
98 + original_
99 + ),
100 + (
101 + returned_
102 + returned_
103 + returned_
104 + returned_
105 + returned_
106 + ))
There is a bug: we should also have a 'resource_uri' field.