~ubuntu-branches/ubuntu/raring/nova/raring-updates

« back to all changes in this revision

Viewing changes to nova/api/openstack/compute/contrib/services.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, James Page, Chuck Short
  • Date: 2013-04-02 08:44:39 UTC
  • mfrom: (1.1.70)
  • Revision ID: package-import@ubuntu.com-20130402084439-e6veyayncnqpxxct
Tags: 1:2013.1~rc2-0ubuntu1
[ James Page ]
* d/control: Promote novnc and websockify to Depends for
  nova-novncproxy (LP: #1066845). 

[ Chuck Short ]
*  New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
        elem.set('zone')
43
43
        elem.set('status')
44
44
        elem.set('state')
45
 
        elem.set('update_at')
 
45
        elem.set('updated_at')
46
46
 
47
47
        return xmlutil.MasterTemplate(root, 1)
48
48
 
49
49
 
50
 
class ServicesUpdateTemplate(xmlutil.TemplateBuilder):
 
50
class ServiceUpdateTemplate(xmlutil.TemplateBuilder):
51
51
    def construct(self):
52
 
        root = xmlutil.TemplateElement('host')
 
52
        root = xmlutil.TemplateElement('service', selector='service')
53
53
        root.set('host')
54
54
        root.set('binary')
55
55
        root.set('status')
57
57
        return xmlutil.MasterTemplate(root, 1)
58
58
 
59
59
 
 
60
class ServiceUpdateDeserializer(wsgi.XMLDeserializer):
 
61
    def default(self, string):
 
62
        node = xmlutil.safe_minidom_parse_string(string)
 
63
        service = {}
 
64
        service_node = self.find_first_child_named(node, 'service')
 
65
        if service_node is None:
 
66
            return service
 
67
        service['host'] = service_node.getAttribute('host')
 
68
        service['binary'] = service_node.getAttribute('binary')
 
69
 
 
70
        return dict(body=service)
 
71
 
 
72
 
60
73
class ServiceController(object):
61
74
 
62
75
    def __init__(self):
98
111
                         'updated_at': svc['updated_at']})
99
112
        return {'services': svcs}
100
113
 
101
 
    @wsgi.serializers(xml=ServicesUpdateTemplate)
 
114
    @wsgi.deserializers(xml=ServiceUpdateDeserializer)
 
115
    @wsgi.serializers(xml=ServiceUpdateTemplate)
102
116
    def update(self, req, id, body):
103
117
        """Enable/Disable scheduling for a service."""
104
118
        context = req.environ['nova.context']
110
124
            disabled = True
111
125
        else:
112
126
            raise webob.exc.HTTPNotFound("Unknown action")
113
 
 
114
127
        try:
115
128
            host = body['host']
116
129
            binary = body['binary']