Remove want_objects kwarg from nova.api.openstack.common.get_instance
Now that most extensions are getting instance objects from common.get_instance, we can cleanup the stragglers and remove the kwarg to verify we're using instance objects everywhere for the API extensions. While in the process, this also converts some extensions to use common.get_instance rather than directly going to compute_api.get. Part of blueprint kilo-objects Change-Id: Ia377c66f9e2f298e46d89f2e54d032b72fd7fa90
This commit is contained in:
parent
fe1a8fe67d
commit
cdeeb37edc
|
@ -532,12 +532,11 @@ class ViewBuilder(object):
|
|||
CONF.osapi_compute_link_prefix)
|
||||
|
||||
|
||||
def get_instance(compute_api, context, instance_id, want_objects=False,
|
||||
expected_attrs=None):
|
||||
def get_instance(compute_api, context, instance_id, expected_attrs=None):
|
||||
"""Fetch an instance from the compute API, handling error checking."""
|
||||
try:
|
||||
return compute_api.get(context, instance_id,
|
||||
want_objects=want_objects,
|
||||
want_objects=True,
|
||||
expected_attrs=expected_attrs)
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
|
|
|
@ -53,8 +53,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"""Permit Admins to pause the server."""
|
||||
ctxt = req.environ['nova.context']
|
||||
authorize(ctxt, 'pause')
|
||||
server = common.get_instance(self.compute_api, ctxt, id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, ctxt, id)
|
||||
try:
|
||||
self.compute_api.pause(ctxt, server)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
@ -76,8 +75,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"""Permit Admins to unpause the server."""
|
||||
ctxt = req.environ['nova.context']
|
||||
authorize(ctxt, 'unpause')
|
||||
server = common.get_instance(self.compute_api, ctxt, id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, ctxt, id)
|
||||
try:
|
||||
self.compute_api.unpause(ctxt, server)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
@ -99,8 +97,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"""Permit admins to suspend the server."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, 'suspend')
|
||||
server = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.suspend(context, server)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
@ -122,8 +119,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"""Permit admins to resume the server from suspend."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, 'resume')
|
||||
server = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.resume(context, server)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
@ -145,8 +141,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"""Permit admins to migrate a server to a new host."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, 'migrate')
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.resize(req.environ['nova.context'], instance)
|
||||
except exception.QuotaError as error:
|
||||
|
@ -170,8 +165,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"""Permit admins to reset networking on a server."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, 'resetNetwork')
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.reset_network(context, instance)
|
||||
except exception.InstanceNotFound:
|
||||
|
@ -190,8 +184,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"""Permit admins to inject network info into a server."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, 'injectNetworkInfo')
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.inject_network_info(context, instance)
|
||||
except exception.InstanceNotFound:
|
||||
|
@ -210,8 +203,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"""Lock a server instance."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, 'lock')
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.lock(context, instance)
|
||||
except exception.InstanceNotFound:
|
||||
|
@ -228,8 +220,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"""Unlock a server instance."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, 'unlock')
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.unlock(context, instance)
|
||||
except exception.PolicyNotAuthorized as e:
|
||||
|
@ -291,8 +282,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
msg = _("Invalid metadata")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
image = self.compute_api.backup(context, instance, image_name,
|
||||
backup_type, rotation, extra_properties=props)
|
||||
|
@ -333,8 +323,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
except ValueError as err:
|
||||
raise exc.HTTPBadRequest(explanation=six.text_type(err))
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.live_migrate(context, instance, block_migration,
|
||||
disk_over_commit, host)
|
||||
|
@ -384,8 +373,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
"are: %s") % ', '.join(sorted(state_map.keys()))
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
instance.vm_state = state
|
||||
instance.task_state = None
|
||||
|
|
|
@ -116,8 +116,7 @@ class InterfaceAttachmentController(object):
|
|||
|
||||
try:
|
||||
instance = common.get_instance(self.compute_api,
|
||||
context, server_id,
|
||||
want_objects=True)
|
||||
context, server_id)
|
||||
LOG.info(_LI("Attach interface"), instance=instance)
|
||||
vif = self.compute_api.attach_interface(context,
|
||||
instance, network_id, port_id, req_ip)
|
||||
|
@ -149,8 +148,7 @@ class InterfaceAttachmentController(object):
|
|||
authorize(context)
|
||||
port_id = id
|
||||
instance = common.get_instance(self.compute_api,
|
||||
context, server_id,
|
||||
want_objects=True)
|
||||
context, server_id)
|
||||
LOG.info(_LI("Detach interface %s"), port_id, instance=instance)
|
||||
try:
|
||||
self.compute_api.detach_interface(context,
|
||||
|
@ -172,8 +170,7 @@ class InterfaceAttachmentController(object):
|
|||
"""Returns a list of attachments, transformed through entity_maker."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
results = []
|
||||
search_opts = {'device_id': instance.uuid}
|
||||
|
||||
|
|
|
@ -40,8 +40,7 @@ class ConsoleOutputController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
length = body['os-getConsoleOutput'].get('length')
|
||||
except (TypeError, KeyError):
|
||||
|
|
|
@ -38,8 +38,7 @@ 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)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
|
||||
try:
|
||||
output = self.compute_api.get_vnc_console(context,
|
||||
|
@ -67,8 +66,7 @@ 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)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
|
||||
try:
|
||||
output = self.compute_api.get_spice_console(context,
|
||||
|
@ -96,8 +94,7 @@ 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)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
|
||||
try:
|
||||
output = self.compute_api.get_rdp_console(context,
|
||||
|
@ -124,8 +121,7 @@ class ConsolesController(wsgi.Controller):
|
|||
|
||||
# If type is not supplied or unknown get_serial_console below will cope
|
||||
console_type = body['os-getSerialConsole'].get('type')
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
output = self.compute_api.get_serial_console(context,
|
||||
instance,
|
||||
|
|
|
@ -37,8 +37,7 @@ class DeferredDeleteController(wsgi.Controller):
|
|||
"""Restore a previously deleted instance."""
|
||||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
|
||||
try:
|
||||
self.compute_api.restore(context, instance)
|
||||
|
@ -54,8 +53,7 @@ class DeferredDeleteController(wsgi.Controller):
|
|||
"""Force delete of instance before deferred cleanup."""
|
||||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
|
||||
try:
|
||||
self.compute_api.force_delete(context, instance)
|
||||
|
|
|
@ -80,8 +80,7 @@ class Controller(wsgi.Controller):
|
|||
msg = _("Compute host %s not found.") % host
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
if instance.host == host:
|
||||
msg = _("The target host can't be the same one.")
|
||||
|
|
|
@ -60,8 +60,7 @@ def get_instance_by_floating_ip_addr(self, context, address):
|
|||
snagiibfa = self.network_api.get_instance_id_by_floating_address
|
||||
instance_id = snagiibfa(context, address)
|
||||
if instance_id:
|
||||
return common.get_instance(self.compute_api, context, instance_id,
|
||||
want_objects=True)
|
||||
return common.get_instance(self.compute_api, context, instance_id)
|
||||
|
||||
|
||||
def disassociate_floating_ip(self, context, instance, address):
|
||||
|
@ -178,8 +177,7 @@ class FloatingIPActionController(wsgi.Controller):
|
|||
msg = _("Address not specified")
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
cached_nwinfo = compute_utils.get_nw_info_for_instance(instance)
|
||||
if not cached_nwinfo:
|
||||
msg = _('No nw_info cache associated with instance')
|
||||
|
|
|
@ -125,8 +125,7 @@ class FpingController(object):
|
|||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
self.check_fping()
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
ips = [str(ip) for ip in self._get_instance_ips(context, instance)]
|
||||
alive_ips = self.fping(ips)
|
||||
return {
|
||||
|
|
|
@ -52,8 +52,7 @@ class InstanceActionsController(wsgi.Controller):
|
|||
def index(self, req, server_id):
|
||||
"""Returns the list of actions recorded for a given instance."""
|
||||
context = req.environ["nova.context"]
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
authorize_actions(context, target=instance)
|
||||
actions_raw = self.action_api.actions_get(context, instance)
|
||||
actions = [self._format_action(action) for action in actions_raw]
|
||||
|
@ -62,8 +61,7 @@ class InstanceActionsController(wsgi.Controller):
|
|||
def show(self, req, server_id, id):
|
||||
"""Return data about the given instance action."""
|
||||
context = req.environ['nova.context']
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
authorize_actions(context, target=instance)
|
||||
action = self.action_api.action_get_by_request_id(context, instance,
|
||||
id)
|
||||
|
|
|
@ -48,8 +48,7 @@ class MultinicController(wsgi.Controller):
|
|||
msg = _("Missing 'networkId' argument for addFixedIp")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
network_id = body['addFixedIp']['networkId']
|
||||
try:
|
||||
self.compute_api.add_fixed_ip(context, instance, network_id)
|
||||
|
@ -69,8 +68,7 @@ class MultinicController(wsgi.Controller):
|
|||
msg = _("Missing 'address' argument for removeFixedIp")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
address = body['removeFixedIp']['address']
|
||||
|
||||
try:
|
||||
|
|
|
@ -47,8 +47,7 @@ class RescueController(wsgi.Controller):
|
|||
else:
|
||||
password = utils.generate_password()
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
rescue_image_ref = None
|
||||
if self.ext_mgr.is_loaded("os-extended-rescue-with-image"):
|
||||
|
@ -74,8 +73,7 @@ class RescueController(wsgi.Controller):
|
|||
"""Unrescue an instance."""
|
||||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.unrescue(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
|
|
@ -324,8 +324,8 @@ class ServerSecurityGroupController(SecurityGroupControllerBase):
|
|||
self.security_group_api.ensure_default(context)
|
||||
|
||||
with translate_exceptions():
|
||||
instance = self.compute_api.get(context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context,
|
||||
server_id)
|
||||
groups = self.security_group_api.get_instance_security_groups(
|
||||
context, instance.uuid, True)
|
||||
|
||||
|
@ -364,8 +364,7 @@ class SecurityGroupActionController(wsgi.Controller):
|
|||
|
||||
def _invoke(self, method, context, id, group_name):
|
||||
with translate_exceptions():
|
||||
instance = self.compute_api.get(context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
method(context, instance, group_name)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
|
|
@ -33,8 +33,7 @@ class ServerDiagnosticsController(object):
|
|||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
try:
|
||||
return self.compute_api.get_diagnostics(context, instance)
|
||||
|
|
|
@ -33,8 +33,7 @@ class ServerPasswordController(object):
|
|||
def index(self, req, server_id):
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
passw = password.extract_password(instance)
|
||||
return {'password': passw or ''}
|
||||
|
@ -43,8 +42,7 @@ class ServerPasswordController(object):
|
|||
def delete(self, req, server_id):
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
meta = password.convert_password(context, None)
|
||||
instance.system_metadata.update(meta)
|
||||
instance.save()
|
||||
|
|
|
@ -40,8 +40,7 @@ class ShelveController(wsgi.Controller):
|
|||
context = req.environ["nova.context"]
|
||||
auth_shelve(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.shelve(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
@ -58,8 +57,7 @@ class ShelveController(wsgi.Controller):
|
|||
context = req.environ["nova.context"]
|
||||
auth_shelve_offload(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.shelve_offload(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
@ -76,8 +74,7 @@ class ShelveController(wsgi.Controller):
|
|||
"""Restore an instance from shelved mode."""
|
||||
context = req.environ["nova.context"]
|
||||
auth_unshelve(context)
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.unshelve(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
|
|
@ -44,8 +44,7 @@ class ServerVirtualInterfaceController(object):
|
|||
def _items(self, req, server_id, entity_maker):
|
||||
"""Returns a list of VIFs, transformed through entity_maker."""
|
||||
context = req.environ['nova.context']
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
vifs = self.network_api.get_vifs_by_instance(context, instance)
|
||||
limited_list = common.limited(vifs, req)
|
||||
|
|
|
@ -244,8 +244,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
authorize_attach(context, action='show')
|
||||
|
||||
volume_id = id
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
|
||||
context, instance.uuid)
|
||||
|
||||
|
@ -300,8 +299,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
'server_id': server_id},
|
||||
context=context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
try:
|
||||
device = self.compute_api.attach_volume(context, instance,
|
||||
volume_id, device)
|
||||
|
@ -354,8 +352,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
self._validate_volume_id(new_volume_id)
|
||||
new_volume = self.volume_api.get(context, new_volume_id)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
|
||||
context, instance.uuid)
|
||||
|
@ -394,8 +391,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
volume_id = id
|
||||
LOG.info(_LI("Detach volume %s"), volume_id, context=context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
volume = self.volume_api.get(context, volume_id)
|
||||
|
||||
|
@ -438,8 +434,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
|
||||
context, instance.uuid)
|
||||
|
|
|
@ -33,15 +33,13 @@ class Controller(wsgi.Controller):
|
|||
|
||||
def index(self, req, server_id):
|
||||
context = req.environ["nova.context"]
|
||||
instance = common.get_instance(self._compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self._compute_api, context, server_id)
|
||||
networks = common.get_networks_for_instance(context, instance)
|
||||
return self._view_builder.index(networks)
|
||||
|
||||
def show(self, req, server_id, id):
|
||||
context = req.environ["nova.context"]
|
||||
instance = common.get_instance(self._compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self._compute_api, context, server_id)
|
||||
networks = common.get_networks_for_instance(context, instance)
|
||||
if id not in networks:
|
||||
msg = _("Instance is not a member of specified network")
|
||||
|
|
|
@ -46,8 +46,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context, action='reset_network')
|
||||
try:
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
self.compute_api.reset_network(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
|
@ -60,8 +59,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context, action='inject_network_info')
|
||||
try:
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
self.compute_api.inject_network_info(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
|
@ -78,8 +76,7 @@ class AdminActionsController(wsgi.Controller):
|
|||
# Identify the desired state from the body
|
||||
state = state_map[body["os-resetState"]["state"]]
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
instance.vm_state = state
|
||||
instance.task_state = None
|
||||
instance.save(admin_state_reset=True)
|
||||
|
|
|
@ -46,8 +46,7 @@ class AdminPasswordController(wsgi.Controller):
|
|||
authorize(context)
|
||||
|
||||
password = body['changePassword']['adminPass']
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.set_admin_password(context, instance, password)
|
||||
except exception.InstancePasswordSetFailed as e:
|
||||
|
|
|
@ -112,8 +112,7 @@ class InterfaceAttachmentController(wsgi.Controller):
|
|||
msg = _("Must input network_id when request IP address")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context,
|
||||
server_id, want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
try:
|
||||
vif = self.compute_api.attach_interface(context,
|
||||
instance, network_id, port_id, req_ip)
|
||||
|
@ -147,8 +146,7 @@ class InterfaceAttachmentController(wsgi.Controller):
|
|||
authorize(context)
|
||||
port_id = id
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
try:
|
||||
self.compute_api.detach_interface(context,
|
||||
instance, port_id=port_id)
|
||||
|
@ -167,8 +165,7 @@ class InterfaceAttachmentController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
results = []
|
||||
search_opts = {'device_id': instance.uuid}
|
||||
|
||||
|
|
|
@ -44,8 +44,7 @@ class ConsoleOutputController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
length = body['os-getConsoleOutput'].get('length')
|
||||
# TODO(cyeoh): In a future API update accept a length of -1
|
||||
# as meaning unlimited length (convert to None)
|
||||
|
|
|
@ -61,8 +61,7 @@ class CreateBackupController(wsgi.Controller):
|
|||
common.check_img_metadata_properties_quota(context, metadata)
|
||||
props.update(metadata)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
|
||||
try:
|
||||
image = self.compute_api.backup(context, instance, image_name,
|
||||
|
|
|
@ -39,8 +39,7 @@ class DeferredDeleteController(wsgi.Controller):
|
|||
"""Restore a previously deleted instance."""
|
||||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.restore(context, instance)
|
||||
except exception.QuotaError as error:
|
||||
|
@ -56,8 +55,7 @@ class DeferredDeleteController(wsgi.Controller):
|
|||
"""Force delete of instance before deferred cleanup."""
|
||||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.force_delete(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
|
|
@ -78,8 +78,7 @@ class EvacuateController(wsgi.Controller):
|
|||
msg = _("Compute host %s not found.") % host
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
if instance.host == host:
|
||||
msg = _("The target host can't be the same one.")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
|
|
@ -70,8 +70,7 @@ def get_instance_by_floating_ip_addr(self, context, address):
|
|||
raise webob.exc.HTTPConflict(explanation=ex.format_message())
|
||||
|
||||
if instance_id:
|
||||
return common.get_instance(self.compute_api, context, instance_id,
|
||||
want_objects=True)
|
||||
return common.get_instance(self.compute_api, context, instance_id)
|
||||
|
||||
|
||||
def disassociate_floating_ip(self, context, instance, address):
|
||||
|
@ -191,8 +190,7 @@ class FloatingIPActionController(wsgi.Controller):
|
|||
|
||||
address = body['addFloatingIp']['address']
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
cached_nwinfo = compute_utils.get_nw_info_for_instance(instance)
|
||||
if not cached_nwinfo:
|
||||
msg = _('No nw_info cache associated with instance')
|
||||
|
|
|
@ -123,8 +123,7 @@ class FpingController(wsgi.Controller):
|
|||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
self.check_fping()
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
ips = [str(ip) for ip in self._get_instance_ips(context, instance)]
|
||||
alive_ips = self.fping(ips)
|
||||
return {
|
||||
|
|
|
@ -55,8 +55,7 @@ class InstanceActionsController(wsgi.Controller):
|
|||
def index(self, req, server_id):
|
||||
"""Returns the list of actions recorded for a given instance."""
|
||||
context = req.environ["nova.context"]
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
authorize_actions(context, target=instance)
|
||||
actions_raw = self.action_api.actions_get(context, instance)
|
||||
actions = [self._format_action(action) for action in actions_raw]
|
||||
|
@ -66,8 +65,7 @@ class InstanceActionsController(wsgi.Controller):
|
|||
def show(self, req, server_id, id):
|
||||
"""Return data about the given instance action."""
|
||||
context = req.environ['nova.context']
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
authorize_actions(context, target=instance)
|
||||
action = self.action_api.action_get_by_request_id(context, instance,
|
||||
id)
|
||||
|
|
|
@ -42,8 +42,7 @@ class IPsController(wsgi.Controller):
|
|||
def index(self, req, server_id):
|
||||
context = req.environ["nova.context"]
|
||||
authorize(context, action='index')
|
||||
instance = common.get_instance(self._compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self._compute_api, context, server_id)
|
||||
networks = common.get_networks_for_instance(context, instance)
|
||||
return self._view_builder.index(networks)
|
||||
|
||||
|
@ -51,8 +50,7 @@ class IPsController(wsgi.Controller):
|
|||
def show(self, req, server_id, id):
|
||||
context = req.environ["nova.context"]
|
||||
authorize(context, action='show')
|
||||
instance = common.get_instance(self._compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self._compute_api, context, server_id)
|
||||
networks = common.get_networks_for_instance(context, instance)
|
||||
if id not in networks:
|
||||
msg = _("Instance is not a member of specified network")
|
||||
|
|
|
@ -35,8 +35,7 @@ class LockServerController(wsgi.Controller):
|
|||
"""Lock a server instance."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, action='lock')
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
self.compute_api.lock(context, instance)
|
||||
|
||||
@wsgi.response(202)
|
||||
|
@ -46,8 +45,7 @@ class LockServerController(wsgi.Controller):
|
|||
"""Unlock a server instance."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context, action='unlock')
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
self.compute_api.unlock(context, instance)
|
||||
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@ class MigrateServerController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context, action='migrate')
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.resize(req.environ['nova.context'], instance)
|
||||
except (exception.TooManyInstances, exception.QuotaError) as e:
|
||||
|
@ -78,8 +77,7 @@ class MigrateServerController(wsgi.Controller):
|
|||
strict=True)
|
||||
|
||||
try:
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
self.compute_api.live_migrate(context, instance, block_migration,
|
||||
disk_over_commit, host)
|
||||
except (exception.NoValidHost,
|
||||
|
|
|
@ -44,8 +44,7 @@ class MultinicController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
network_id = body['addFixedIp']['networkId']
|
||||
try:
|
||||
self.compute_api.add_fixed_ip(context, instance, network_id)
|
||||
|
@ -61,8 +60,7 @@ class MultinicController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
address = body['removeFixedIp']['address']
|
||||
|
||||
try:
|
||||
|
|
|
@ -39,8 +39,7 @@ class PauseServerController(wsgi.Controller):
|
|||
"""Permit Admins to pause the server."""
|
||||
ctxt = req.environ['nova.context']
|
||||
authorize(ctxt, action='pause')
|
||||
server = common.get_instance(self.compute_api, ctxt, id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, ctxt, id)
|
||||
try:
|
||||
self.compute_api.pause(ctxt, server)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
@ -61,8 +60,7 @@ class PauseServerController(wsgi.Controller):
|
|||
"""Permit Admins to unpause the server."""
|
||||
ctxt = req.environ['nova.context']
|
||||
authorize(ctxt, action='unpause')
|
||||
server = common.get_instance(self.compute_api, ctxt, id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, ctxt, id)
|
||||
try:
|
||||
self.compute_api.unpause(ctxt, server)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
|
|
@ -45,8 +45,7 @@ class RemoteConsolesController(wsgi.Controller):
|
|||
console_type = body['os-getVNCConsole'].get('type')
|
||||
|
||||
try:
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
output = self.compute_api.get_vnc_console(context,
|
||||
instance,
|
||||
console_type)
|
||||
|
@ -74,8 +73,7 @@ class RemoteConsolesController(wsgi.Controller):
|
|||
console_type = body['os-getSPICEConsole'].get('type')
|
||||
|
||||
try:
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
output = self.compute_api.get_spice_console(context,
|
||||
instance,
|
||||
console_type)
|
||||
|
@ -103,8 +101,7 @@ class RemoteConsolesController(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)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
# NOTE(mikal): get_rdp_console() can raise InstanceNotFound, so
|
||||
# we still need to catch it here.
|
||||
|
@ -134,7 +131,7 @@ class RemoteConsolesController(wsgi.Controller):
|
|||
# If type is not supplied or unknown get_serial_console below will cope
|
||||
console_type = body['os-getSerialConsole'].get('type')
|
||||
try:
|
||||
instance = self.compute_api.get(context, id, want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
output = self.compute_api.get_serial_console(context,
|
||||
instance,
|
||||
console_type)
|
||||
|
|
|
@ -56,8 +56,7 @@ class RescueController(wsgi.Controller):
|
|||
else:
|
||||
password = utils.generate_password()
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
rescue_image_ref = None
|
||||
if body['rescue'] and 'rescue_image_ref' in body['rescue']:
|
||||
rescue_image_ref = body['rescue']['rescue_image_ref']
|
||||
|
@ -89,8 +88,7 @@ class RescueController(wsgi.Controller):
|
|||
"""Unrescue an instance."""
|
||||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.unrescue(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
|
|
@ -335,8 +335,8 @@ class ServerSecurityGroupController(SecurityGroupControllerBase):
|
|||
self.security_group_api.ensure_default(context)
|
||||
|
||||
try:
|
||||
instance = self.compute_api.get(context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context,
|
||||
server_id)
|
||||
groups = self.security_group_api.get_instance_security_groups(
|
||||
context, instance.uuid, True)
|
||||
except (exception.SecurityGroupNotFound,
|
||||
|
@ -378,7 +378,7 @@ class SecurityGroupActionController(wsgi.Controller):
|
|||
return group_name
|
||||
|
||||
def _invoke(self, method, context, id, group_name):
|
||||
instance = self.compute_api.get(context, id, want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
method(context, instance, group_name)
|
||||
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
|
|
|
@ -36,8 +36,7 @@ class ServerDiagnosticsController(wsgi.Controller):
|
|||
context = req.environ["nova.context"]
|
||||
authorize(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
try:
|
||||
# NOTE(gmann): To make V21 same as V2 API, this method will call
|
||||
|
|
|
@ -36,8 +36,7 @@ class ServerMetadataController(wsgi.Controller):
|
|||
super(ServerMetadataController, self).__init__()
|
||||
|
||||
def _get_metadata(self, context, server_id):
|
||||
server = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, server_id)
|
||||
try:
|
||||
# NOTE(mikal): get_instanc_metadata sometimes returns
|
||||
# InstanceNotFound in unit tests, even though the instance is
|
||||
|
@ -106,8 +105,7 @@ class ServerMetadataController(wsgi.Controller):
|
|||
def _update_instance_metadata(self, context, server_id, metadata,
|
||||
delete=False):
|
||||
try:
|
||||
server = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, server_id)
|
||||
return self.compute_api.update_instance_metadata(context,
|
||||
server,
|
||||
metadata,
|
||||
|
@ -148,8 +146,7 @@ class ServerMetadataController(wsgi.Controller):
|
|||
msg = _("Metadata item was not found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
server = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, server_id)
|
||||
try:
|
||||
self.compute_api.delete_instance_metadata(context, server, id)
|
||||
|
||||
|
|
|
@ -51,8 +51,7 @@ class ServerPasswordController(wsgi.Controller):
|
|||
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
meta = password.convert_password(context, None)
|
||||
instance.system_metadata.update(meta)
|
||||
instance.save()
|
||||
|
|
|
@ -382,7 +382,7 @@ class ServersController(wsgi.Controller):
|
|||
def _get_server(self, context, req, instance_uuid):
|
||||
"""Utility function for looking up an instance by uuid."""
|
||||
instance = common.get_instance(self.compute_api, context,
|
||||
instance_uuid, want_objects=True,
|
||||
instance_uuid,
|
||||
expected_attrs=['pci_devices',
|
||||
'flavor'])
|
||||
req.cache_db_instance(instance)
|
||||
|
@ -474,7 +474,6 @@ class ServersController(wsgi.Controller):
|
|||
"""Returns server details by server id."""
|
||||
context = req.environ['nova.context']
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True,
|
||||
expected_attrs=['pci_devices',
|
||||
'flavor'])
|
||||
req.cache_db_instance(instance)
|
||||
|
@ -718,7 +717,6 @@ class ServersController(wsgi.Controller):
|
|||
body['server'], update_dict)
|
||||
|
||||
instance = common.get_instance(self.compute_api, ctxt, id,
|
||||
want_objects=True,
|
||||
expected_attrs=['pci_devices'])
|
||||
try:
|
||||
# NOTE(mikal): this try block needs to stay because save() still
|
||||
|
|
|
@ -40,8 +40,7 @@ class ShelveController(wsgi.Controller):
|
|||
context = req.environ["nova.context"]
|
||||
authorize(context, action='shelve')
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.shelve(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
@ -58,8 +57,7 @@ class ShelveController(wsgi.Controller):
|
|||
context = req.environ["nova.context"]
|
||||
authorize(context, action='shelve_offload')
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.shelve_offload(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
@ -76,8 +74,7 @@ class ShelveController(wsgi.Controller):
|
|||
"""Restore an instance from shelved mode."""
|
||||
context = req.environ["nova.context"]
|
||||
authorize(context, action='unshelve')
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
try:
|
||||
self.compute_api.unshelve(context, instance)
|
||||
except exception.InstanceIsLocked as e:
|
||||
|
|
|
@ -39,8 +39,7 @@ class SuspendServerController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context, action='suspend')
|
||||
try:
|
||||
server = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, id)
|
||||
self.compute_api.suspend(context, server)
|
||||
except exception.InstanceIsLocked as e:
|
||||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
|
@ -56,8 +55,7 @@ class SuspendServerController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context, action='resume')
|
||||
try:
|
||||
server = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, id)
|
||||
self.compute_api.resume(context, server)
|
||||
except exception.InstanceIsLocked as e:
|
||||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
|
|
|
@ -47,8 +47,7 @@ class ServerVirtualInterfaceController(wsgi.Controller):
|
|||
"""Returns a list of VIFs, transformed through entity_maker."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
vifs = self.network_api.get_vifs_by_instance(context, instance)
|
||||
limited_list = common.limited(vifs, req)
|
||||
|
|
|
@ -237,8 +237,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
authorize_attach(context, action='show')
|
||||
|
||||
volume_id = id
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
|
||||
context, instance.uuid)
|
||||
|
@ -274,8 +273,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
volume_id = body['volumeAttachment']['volumeId']
|
||||
device = body['volumeAttachment'].get('device')
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
try:
|
||||
device = self.compute_api.attach_volume(context, instance,
|
||||
volume_id, device)
|
||||
|
@ -325,8 +323,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
except exception.VolumeNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
|
||||
context, instance.uuid)
|
||||
|
@ -367,8 +364,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
|
||||
volume_id = id
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
try:
|
||||
volume = self.volume_api.get(context, volume_id)
|
||||
|
@ -415,8 +411,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
|||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
instance = common.get_instance(self.compute_api, context, server_id)
|
||||
|
||||
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
|
||||
context, instance.uuid)
|
||||
|
|
|
@ -31,8 +31,7 @@ class Controller(object):
|
|||
|
||||
def _get_metadata(self, context, server_id):
|
||||
try:
|
||||
server = self.compute_api.get(context, server_id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, server_id)
|
||||
meta = self.compute_api.get_instance_metadata(context, server)
|
||||
except exception.InstanceNotFound:
|
||||
msg = _('Server does not exist')
|
||||
|
@ -116,8 +115,7 @@ class Controller(object):
|
|||
def _update_instance_metadata(self, context, server_id, metadata,
|
||||
delete=False):
|
||||
try:
|
||||
server = self.compute_api.get(context, server_id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, server_id)
|
||||
return self.compute_api.update_instance_metadata(context,
|
||||
server,
|
||||
metadata,
|
||||
|
@ -170,8 +168,7 @@ class Controller(object):
|
|||
msg = _("Metadata item was not found")
|
||||
raise exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
server = common.get_instance(self.compute_api, context, server_id,
|
||||
want_objects=True)
|
||||
server = common.get_instance(self.compute_api, context, server_id)
|
||||
try:
|
||||
self.compute_api.delete_instance_metadata(context, server, id)
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ class Controller(wsgi.Controller):
|
|||
def _get_server(self, context, req, instance_uuid):
|
||||
"""Utility function for looking up an instance by uuid."""
|
||||
instance = common.get_instance(self.compute_api, context,
|
||||
instance_uuid, want_objects=True,
|
||||
instance_uuid,
|
||||
expected_attrs=['flavor'])
|
||||
req.cache_db_instance(instance)
|
||||
return instance
|
||||
|
|
Loading…
Reference in New Issue