'Trigger crash dump in an instance'

@wsgi.Controller.api_version('2.17')
@wsgi.response(202)
@extensions.expected_errors((400, 404, 409))
@wsgi.action('trigger_crash_dump')
@validation.schema(schema_servers.trigger_crash_dump)
def _action_trigger_crash_dump(self, req, id, body):

    context = req.environ['nova.context']
    instance = self._get_instance(context, id)
    context.can((server_policies.SERVERS % 'trigger_crash_dump'), target={'user_id': instance.user_id, 'project_id': instance.project_id})
    try:
        self.compute_api.trigger_crash_dump(context, instance)
    except (exception.InstanceNotReady, exception.InstanceIsLocked) as e:
        raise webob.exc.HTTPConflict(explanation=e.format_message())
    except exception.InstanceInvalidState as state_error:
        common.raise_http_conflict_for_instance_invalid_state(state_error, 'trigger_crash_dump', id)
    except exception.TriggerCrashDumpNotSupported as e:
        raise webob.exc.HTTPBadRequest(explanation=e.format_message())
