Ejemplo n.º 1
0
 def delete(self, req, tenant_id, instance_id, user_id, id):
     """Revoke access for a user."""
     context = req.environ[wsgi.CONTEXT_KEY]
     user = self._get_user(context, instance_id, user_id)
     username, hostname = unquote_user_host(user_id)
     access = models.User.access(context, instance_id, username, hostname)
     databases = [db.name for db in access.databases]
     if not id in databases:
         raise exception.DatabaseNotFound(uuid=id)
     models.User.revoke(context, instance_id, username, hostname, id)
     return wsgi.Result(None, 202)
Ejemplo n.º 2
0
 def revoke_access(self, username, hostname, database):
     """Remove a database from a users's grant list."""
     if (username, hostname) not in self.users:
         raise rd_exception.UserNotFound(
             "User %s cannot be found on the instance." % username)
     g = self.grants.get((username, hostname), set())
     if database not in self.grants.get((username, hostname), set()):
         raise rd_exception.DatabaseNotFound(
             "Database %s cannot be found on the instance." % database)
     current_grants = self.grants.get((username, hostname), set())
     if database in current_grants:
         current_grants.remove(database)
     self.grants[(username, hostname)] = current_grants