diff options
| author | Daniel P. Berrange <berrange@redhat.com> | 2013-01-02 18:57:25 +0000 |
|---|---|---|
| committer | Daniel P. Berrange <berrange@redhat.com> | 2013-01-16 10:19:37 +0000 |
| commit | 518bdb5abaab6ae11e18bebaf4d279197f21522f (patch) | |
| tree | 20d2157aa37c71642906c1a59bfca48384e52edb /nova/api | |
| parent | d597993a07eff1b8b88b11e7dc44edaf177067b8 (diff) | |
Expose a get_spice_console RPC API method
To mirror the existing get_vnc_console RPC API method, expose a
new get_spice_console RPC API method. The only console type
supported currently is 'spice-html5' which is equivalent to
'novnc'
Blueprint: libvirt-spice
Change-Id: Iab9d3dfc3564a122a8cd2b53d34fdcc725bfa29b
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/consoles.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/contrib/consoles.py b/nova/api/openstack/compute/contrib/consoles.py index 4f88d033c..4895a9e7b 100644 --- a/nova/api/openstack/compute/contrib/consoles.py +++ b/nova/api/openstack/compute/contrib/consoles.py @@ -53,10 +53,33 @@ class ConsolesController(wsgi.Controller): return {'console': {'type': console_type, 'url': output['url']}} + @wsgi.action('os-getSPICEConsole') + def get_spice_console(self, req, id, body): + """Get text console output.""" + context = req.environ['nova.context'] + authorize(context) + + # If type is not supplied or unknown, get_spice_console below will cope + console_type = body['os-getSPICEConsole'].get('type') + + try: + instance = self.compute_api.get(context, id) + output = self.compute_api.get_spice_console(context, + instance, + console_type) + except exception.InstanceNotFound as e: + raise webob.exc.HTTPNotFound(explanation=unicode(e)) + except exception.InstanceNotReady as e: + raise webob.exc.HTTPConflict(explanation=unicode(e)) + + return {'console': {'type': console_type, 'url': output['url']}} + def get_actions(self): """Return the actions the extension adds, as required by contract.""" actions = [extensions.ActionExtension("servers", "os-getVNCConsole", - self.get_vnc_console)] + self.get_vnc_console), + extensions.ActionExtension("servers", "os-getSPICEConsole", + self.get_spice_console)] return actions |
