summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/consoles.py25
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