Ejemplo n.º 1
0
 def delete(self, req, tenant_id, instance_id, id):
     LOG.info("Delete instance '%(id)s'\n"
              "req : '%(req)s'\n\n",
              {"id": instance_id, "req": req})
     context = req.environ[wsgi.CONTEXT_KEY]
     self.authorize_target_action(context, 'user:delete', instance_id)
     id = correct_id_with_req(id, req)
     username, host = unquote_user_host(id)
     user = None
     context.notification = notification.DBaaSUserDelete(context,
                                                         request=req)
     with StartNotification(context, instance_id=instance_id,
                            username=username):
         try:
             user = guest_models.MySQLUser(name=username,
                                           host=host)
             found_user = models.User.load(context, instance_id, username,
                                           host)
             if not found_user:
                 user = None
         except (ValueError, AttributeError) as e:
             raise exception.BadRequest(_("User delete error: %(e)s")
                                        % {'e': e})
         if not user:
             raise exception.UserNotFound(uuid=id)
         models.User.delete(context, instance_id, user.serialize())
     return wsgi.Result(None, 202)
Ejemplo n.º 2
0
 def delete(self, req, tenant_id, instance_id, id):
     LOG.info(_("Deleting user for instance '%s'") % instance_id)
     LOG.info(_("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     id = correct_id_with_req(id, req)
     username, host = unquote_user_host(id)
     context.notification = notification.DBaaSUserDelete(context,
                                                         request=req)
     with StartNotification(context,
                            instance_id=instance_id,
                            username=username):
         user = None
         try:
             user = guest_models.MySQLUser()
             user.name = username
             user.host = host
             found_user = models.User.load(context, instance_id, username,
                                           host)
             if not found_user:
                 user = None
         except (ValueError, AttributeError) as e:
             raise exception.BadRequest(msg=str(e))
         if not user:
             raise exception.UserNotFound(uuid=id)
         models.User.delete(context, instance_id, user.serialize())
     return wsgi.Result(None, 202)