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
This commit is contained in:
parent
7bf541cc90
commit
48b41e0b88
2
doc/api_samples/os-services/service-disable-put-req.xml
Normal file
2
doc/api_samples/os-services/service-disable-put-req.xml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<service host="host1" binary="nova-compute" />
|
2
doc/api_samples/os-services/service-disable-put-resp.xml
Normal file
2
doc/api_samples/os-services/service-disable-put-resp.xml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<service host="host1" binary="nova-compute" status="disabled" />
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"host": "host1",
|
"host": "host1",
|
||||||
"service": "nova-compute"
|
"service": "nova-compute"
|
||||||
}
|
}
|
||||||
|
2
doc/api_samples/os-services/service-enable-put-req.xml
Normal file
2
doc/api_samples/os-services/service-enable-put-req.xml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<service host="host1" binary="nova-compute" />
|
2
doc/api_samples/os-services/service-enable-put-resp.xml
Normal file
2
doc/api_samples/os-services/service-enable-put-resp.xml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<service host="host1" binary="nova-compute" status="enabled" />
|
6
doc/api_samples/os-services/services-list-get-resp.xml
Normal file
6
doc/api_samples/os-services/services-list-get-resp.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<services>
|
||||||
|
<service status="disabled" binary="nova-scheduler" zone="internal" state="up" host="host1" updated_at="2012-10-29T13:42:02.000000"/>
|
||||||
|
<service status="disabled" binary="nova-compute" zone="nova" state="up" host="host1" updated_at="2012-10-29T13:42:05.000000" />
|
||||||
|
<service status="enabled" binary="nova-scheduler" zone="internal" state="down" host="host2" updated_at="2012-09-19T06:55:34.000000"/>
|
||||||
|
<service status="disabled" binary="nova-compute" zone="nova" state="down" host="host2" updated_at="2012-09-18T08:03:38.000000"/>
|
||||||
|
</services>
|
@ -42,14 +42,14 @@ class ServicesIndexTemplate(xmlutil.TemplateBuilder):
|
|||||||
elem.set('zone')
|
elem.set('zone')
|
||||||
elem.set('status')
|
elem.set('status')
|
||||||
elem.set('state')
|
elem.set('state')
|
||||||
elem.set('update_at')
|
elem.set('updated_at')
|
||||||
|
|
||||||
return xmlutil.MasterTemplate(root, 1)
|
return xmlutil.MasterTemplate(root, 1)
|
||||||
|
|
||||||
|
|
||||||
class ServicesUpdateTemplate(xmlutil.TemplateBuilder):
|
class ServiceUpdateTemplate(xmlutil.TemplateBuilder):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
root = xmlutil.TemplateElement('host')
|
root = xmlutil.TemplateElement('service', selector='service')
|
||||||
root.set('host')
|
root.set('host')
|
||||||
root.set('binary')
|
root.set('binary')
|
||||||
root.set('status')
|
root.set('status')
|
||||||
@ -57,6 +57,19 @@ class ServicesUpdateTemplate(xmlutil.TemplateBuilder):
|
|||||||
return xmlutil.MasterTemplate(root, 1)
|
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):
|
class ServiceController(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -98,7 +111,8 @@ class ServiceController(object):
|
|||||||
'updated_at': svc['updated_at']})
|
'updated_at': svc['updated_at']})
|
||||||
return {'services': svcs}
|
return {'services': svcs}
|
||||||
|
|
||||||
@wsgi.serializers(xml=ServicesUpdateTemplate)
|
@wsgi.deserializers(xml=ServiceUpdateDeserializer)
|
||||||
|
@wsgi.serializers(xml=ServiceUpdateTemplate)
|
||||||
def update(self, req, id, body):
|
def update(self, req, id, body):
|
||||||
"""Enable/Disable scheduling for a service."""
|
"""Enable/Disable scheduling for a service."""
|
||||||
context = req.environ['nova.context']
|
context = req.environ['nova.context']
|
||||||
@ -110,7 +124,6 @@ class ServiceController(object):
|
|||||||
disabled = True
|
disabled = True
|
||||||
else:
|
else:
|
||||||
raise webob.exc.HTTPNotFound("Unknown action")
|
raise webob.exc.HTTPNotFound("Unknown action")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
host = body['host']
|
host = body['host']
|
||||||
binary = body['binary']
|
binary = body['binary']
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<service host="%(host)s" binary="%(binary)s" />
|
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<service host="%(host)s" binary="%(binary)s" status="disabled" />
|
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<service host="%(host)s" binary="%(binary)s" />
|
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<service host="%(host)s" binary="%(binary)s" status="enabled" />
|
@ -0,0 +1,6 @@
|
|||||||
|
<services>
|
||||||
|
<service status="disabled" binary="nova-scheduler" zone="internal" state="up" host="host1" updated_at="%(timestamp)s"/>
|
||||||
|
<service status="disabled" binary="nova-compute" zone="nova" state="up" host="host1" updated_at="%(timestamp)s" />
|
||||||
|
<service status="enabled" binary="nova-scheduler" zone="internal" state="down" host="host2" updated_at="%(timestamp)s"/>
|
||||||
|
<service status="disabled" binary="nova-compute" zone="nova" state="down" host="host2" updated_at="%(timestamp)s"/>
|
||||||
|
</services>
|
@ -2012,6 +2012,10 @@ class ServicesJsonTest(ApiSampleTestBase):
|
|||||||
subs, response)
|
subs, response)
|
||||||
|
|
||||||
|
|
||||||
|
class ServicesXmlTest(ServicesJsonTest):
|
||||||
|
ctype = 'xml'
|
||||||
|
|
||||||
|
|
||||||
class SimpleTenantUsageSampleJsonTest(ServersSampleBase):
|
class SimpleTenantUsageSampleJsonTest(ServersSampleBase):
|
||||||
extension_name = ("nova.api.openstack.compute.contrib.simple_tenant_usage."
|
extension_name = ("nova.api.openstack.compute.contrib.simple_tenant_usage."
|
||||||
"Simple_tenant_usage")
|
"Simple_tenant_usage")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user