From 2a33f8d8cefdbde50f89e6d4084d513eadf3a97a Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 5 Dec 2012 23:05:59 +0000 Subject: 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 --- nova/api/openstack/compute/contrib/hosts.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'nova/api') 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) -- cgit