summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2013-03-05 16:17:29 -0500
committerDan Prince <dprince@redhat.com>2013-03-14 15:34:49 -0400
commit37c618da7c565b13cf6779f40c41ce895ff0459f (patch)
tree54dcabba747598aad7f6be14a91a3c88d7d5be86 /nova/api
parent9df61c0b06dd81f34d97fbc02030f92928e21a78 (diff)
downloadnova-37c618da7c565b13cf6779f40c41ce895ff0459f.tar.gz
nova-37c618da7c565b13cf6779f40c41ce895ff0459f.tar.xz
nova-37c618da7c565b13cf6779f40c41ce895ff0459f.zip
Make os-services API extensions consistent.
Updates the os-services API extension so that it is consistent internally (index and update return similar formats), and so that it works with the recent novaclient code which sends the following request body format: {"binary": "nova-cert", "host": "nova1"} Also, updates the response body format of the update call so that it wraps things in an extra service dict which should make novaclient happier here as well (and is consistent with other extensions too). Fixes LP Bug #1147746. Change-Id: I932160d64fdd3aaeb2ed90a092ecc7a36dcc9665
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/services.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/nova/api/openstack/compute/contrib/services.py b/nova/api/openstack/compute/contrib/services.py
index fb7b9d591..558c31586 100644
--- a/nova/api/openstack/compute/contrib/services.py
+++ b/nova/api/openstack/compute/contrib/services.py
@@ -51,8 +51,8 @@ class ServicesUpdateTemplate(xmlutil.TemplateBuilder):
def construct(self):
root = xmlutil.TemplateElement('host')
root.set('host')
- root.set('service')
- root.set('disabled')
+ root.set('binary')
+ root.set('status')
return xmlutil.MasterTemplate(root, 1)
@@ -76,13 +76,13 @@ class ServiceController(object):
host = ''
if 'host' in req.GET:
host = req.GET['host']
- service = ''
- if 'service' in req.GET:
- service = req.GET['service']
+ binary = ''
+ if 'binary' in req.GET:
+ binary = req.GET['binary']
if host:
services = [s for s in services if s['host'] == host]
- if service:
- services = [s for s in services if s['binary'] == service]
+ if binary:
+ services = [s for s in services if s['binary'] == binary]
svcs = []
for svc in services:
@@ -113,12 +113,12 @@ class ServiceController(object):
try:
host = body['host']
- service = body['service']
+ binary = body['binary']
except (TypeError, KeyError):
raise webob.exc.HTTPUnprocessableEntity()
try:
- svc = db.service_get_by_args(context, host, service)
+ svc = db.service_get_by_args(context, host, binary)
if not svc:
raise webob.exc.HTTPNotFound('Unknown service')
@@ -126,7 +126,8 @@ class ServiceController(object):
except exception.ServiceNotFound:
raise webob.exc.HTTPNotFound("service not found")
- return {'host': host, 'service': service, 'disabled': disabled}
+ status = id + 'd'
+ return {'service': {'host': host, 'binary': binary, 'status': status}}
class Services(extensions.ExtensionDescriptor):