summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorAndrea Rosa <andrea.rosa@hp.com>2013-02-20 11:52:10 +0000
committerAndrea Rosa <andrea.rosa@hp.com>2013-03-28 10:38:36 +0000
commit48b41e0b880adf80e3be6d128cd392af57b8477e (patch)
treea2603e045204d1f26dc57c16359f060888746405 /nova/api
parent7bf541cc907bd0e4c881a1bdbd6a14fd7146a5f9 (diff)
Fix typo in the XML serialization os-services API.
Partially implements blueprint nova-api-samples fixes bug 1130609 The XML serializer for the update method in the os-services API extensions was not serializing the "updated_at" field because of a typo in the code. In this change we added api_samples for the XML output. Change-Id: I9fff0677e9bad650b19e559b3ed6e9bc0ffe8c3c
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/services.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/nova/api/openstack/compute/contrib/services.py b/nova/api/openstack/compute/contrib/services.py
index 558c31586..5b382f892 100644
--- a/nova/api/openstack/compute/contrib/services.py
+++ b/nova/api/openstack/compute/contrib/services.py
@@ -42,14 +42,14 @@ class ServicesIndexTemplate(xmlutil.TemplateBuilder):
elem.set('zone')
elem.set('status')
elem.set('state')
- elem.set('update_at')
+ elem.set('updated_at')
return xmlutil.MasterTemplate(root, 1)
-class ServicesUpdateTemplate(xmlutil.TemplateBuilder):
+class ServiceUpdateTemplate(xmlutil.TemplateBuilder):
def construct(self):
- root = xmlutil.TemplateElement('host')
+ root = xmlutil.TemplateElement('service', selector='service')
root.set('host')
root.set('binary')
root.set('status')
@@ -57,6 +57,19 @@ class ServicesUpdateTemplate(xmlutil.TemplateBuilder):
return xmlutil.MasterTemplate(root, 1)
+class ServiceUpdateDeserializer(wsgi.XMLDeserializer):
+ def default(self, string):
+ node = xmlutil.safe_minidom_parse_string(string)
+ service = {}
+ service_node = self.find_first_child_named(node, 'service')
+ if service_node is None:
+ return service
+ service['host'] = service_node.getAttribute('host')
+ service['binary'] = service_node.getAttribute('binary')
+
+ return dict(body=service)
+
+
class ServiceController(object):
def __init__(self):
@@ -98,7 +111,8 @@ class ServiceController(object):
'updated_at': svc['updated_at']})
return {'services': svcs}
- @wsgi.serializers(xml=ServicesUpdateTemplate)
+ @wsgi.deserializers(xml=ServiceUpdateDeserializer)
+ @wsgi.serializers(xml=ServiceUpdateTemplate)
def update(self, req, id, body):
"""Enable/Disable scheduling for a service."""
context = req.environ['nova.context']
@@ -110,7 +124,6 @@ class ServiceController(object):
disabled = True
else:
raise webob.exc.HTTPNotFound("Unknown action")
-
try:
host = body['host']
binary = body['binary']