Example #1
0
    def fake_deleted_instance_recover(self, req, tenant_id):
        LOG.debug(_("req : '%s'\n\n") % req)
        LOG.debug(_("fake_deleted_instance_recover for tenant_id '%s'") % tenant_id)

        context = req.environ[wsgi.CONTEXT_KEY]
        context.is_admin = True
        search_ops = {}
        search_ops.update(req.GET)
        instance_id = search_ops.get("instance_id", None)
        if instance_id is None:
            raise exception.BadRequest("fake_deleted_instance_recover instance_id is required.")

        LOG.debug("fake_deleted_instance_recover instance_id: %s" % instance_id)
        instance_vip = KSC_Instance.get_instance_vip(instance_id)
        if instance_vip is None:
            raise exception.NotFound("fake_deleted_instance_recover instance not found, %s" % instance_id)

        instance_id = instance_vip.instance_id
        if KSC_Instance.check_instance_fake_deleted(context, instance_id) is not True:
            raise exception.NotFound("fake_deleted_instance_recover instance not found, %s" % instance_id)

        KSC_Instance.fake_deleted_instance_recover(context, instance_id)
        return wsgi.Result(202)