diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2012-12-05 23:05:59 +0000 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2012-12-05 23:05:59 +0000 |
| commit | 2a33f8d8cefdbde50f89e6d4084d513eadf3a97a (patch) | |
| tree | a3b9b4143da9e1e8768d8aab5fbb0c316beed599 /nova/api | |
| parent | 255692feea3eee12bfc763f75fc8f3dabdbe9ba5 (diff) | |
Fix positional arg swallow decorator
The update() method in the hosts extension is decorated with @check_host
but the function returned by decorator takes a kwarg which shadows the
'body' positional arg of the update() method.
i.e. if you call:
controller.update(req, id, body)
then the body arg gets passed to the wrapper as its service kwarg and
never passed through to update(). We can see how the tests are all
passing body as a kwarg to avoid this.
Remove the service arg from check_host() but also from _list_hosts()
since the only place it is used is in the tests.
Change-Id: I12aab582c15c25fd35ecda005341291450c7efdc
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/hosts.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/nova/api/openstack/compute/contrib/hosts.py b/nova/api/openstack/compute/contrib/hosts.py index 8982f5724..0d2b68f11 100644 --- a/nova/api/openstack/compute/contrib/hosts.py +++ b/nova/api/openstack/compute/contrib/hosts.py @@ -93,7 +93,7 @@ class HostUpdateDeserializer(wsgi.XMLDeserializer): return dict(body=updates) -def _list_hosts(req, service=None): +def _list_hosts(req): """Returns a summary list of hosts, optionally filtering by service type. """ @@ -108,16 +108,13 @@ def _list_hosts(req, service=None): for host in services: hosts.append({"host_name": host['host'], 'service': host['topic'], 'zone': host['availability_zone']}) - if service: - hosts = [host for host in hosts - if host["service"] == service] return hosts def check_host(fn): """Makes sure that the host exists.""" - def wrapped(self, req, id, service=None, *args, **kwargs): - listed_hosts = _list_hosts(req, service) + def wrapped(self, req, id, *args, **kwargs): + listed_hosts = _list_hosts(req) hosts = [h["host_name"] for h in listed_hosts] if id in hosts: return fn(self, req, id, *args, **kwargs) |
