Merge "Use common get_instance function in v2 consoles extension"

This commit is contained in:
Jenkins
2014-09-01 05:44:14 +00:00
committed by Gerrit Code Review
2 changed files with 11 additions and 11 deletions
@@ -14,6 +14,7 @@
import webob
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova import compute
@@ -37,14 +38,13 @@ class ConsolesController(wsgi.Controller):
# If type is not supplied or unknown, get_vnc_console below will cope
console_type = body['os-getVNCConsole'].get('type')
instance = common.get_instance(self.compute_api, context, id,
want_objects=True)
try:
instance = self.compute_api.get(context, id, want_objects=True)
output = self.compute_api.get_vnc_console(context,
instance,
console_type)
except exception.InstanceNotFound as e:
raise webob.exc.HTTPNotFound(explanation=e.format_message())
except exception.InstanceNotReady as e:
raise webob.exc.HTTPConflict(
explanation=_('Instance not yet ready'))
@@ -64,16 +64,15 @@ class ConsolesController(wsgi.Controller):
# If type is not supplied or unknown, get_spice_console below will cope
console_type = body['os-getSPICEConsole'].get('type')
instance = common.get_instance(self.compute_api, context, id,
want_objects=True)
try:
instance = self.compute_api.get(context, id, want_objects=True)
output = self.compute_api.get_spice_console(context,
instance,
console_type)
except exception.ConsoleTypeUnavailable as e:
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
except exception.InstanceNotFound as e:
raise webob.exc.HTTPNotFound(explanation=e.format_message())
except exception.InstanceNotReady as e:
raise webob.exc.HTTPConflict(explanation=e.format_message())
except NotImplementedError:
@@ -91,16 +90,15 @@ class ConsolesController(wsgi.Controller):
# If type is not supplied or unknown, get_rdp_console below will cope
console_type = body['os-getRDPConsole'].get('type')
instance = common.get_instance(self.compute_api, context, id,
want_objects=True)
try:
instance = self.compute_api.get(context, id, want_objects=True)
output = self.compute_api.get_rdp_console(context,
instance,
console_type)
except exception.ConsoleTypeUnavailable as e:
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
except exception.InstanceNotFound as e:
raise webob.exc.HTTPNotFound(explanation=e.format_message())
except exception.InstanceNotReady as e:
raise webob.exc.HTTPConflict(explanation=e.format_message())
except NotImplementedError:
@@ -88,11 +88,13 @@ def fake_get_rdp_console_not_found(self, _context, instance, _console_type):
raise exception.InstanceNotFound(instance_id=instance["uuid"])
def fake_get(self, context, instance_uuid, want_objects=False):
def fake_get(self, context, instance_uuid, want_objects=False,
expected_attrs=None):
return {'uuid': instance_uuid}
def fake_get_not_found(self, context, instance_uuid, want_objects=False):
def fake_get_not_found(self, context, instance_uuid, want_objects=False,
expected_attrs=None):
raise exception.InstanceNotFound(instance_id=instance_uuid)