Exemplo n.º 1
0
    def list_users(self, limit=None, marker=None, include_marker=False):
        """List users that have access to the database"""
        LOG.debug(_("---Listing Users---"))
        users = []
        client = LocalSqlClient(get_engine())
        with client:
            mysql_user = models.MySQLUser()
            q = Query()
            q.columns = ['User']
            q.tables = ['mysql.user']
            q.where = ["host != 'localhost'"]
            q.order = ['User']
            if marker:
                q.where.append("User %s '%s'" %
                               (INCLUDE_MARKER_OPERATORS[include_marker],
                                marker))
            if limit:
                q.limit = limit + 1
            t = text(str(q))
            result = client.execute(t)
            next_marker = None
            LOG.debug("result = " + str(result))
            for count, row in enumerate(result):
                if count >= limit:
                    break
                LOG.debug("user = "******"^'(.+)'@", db['grantee'])
                    if (matches is not None and
                            matches.group(1) == mysql_user.name):
                        mysql_db = models.MySQLDatabase()
                        mysql_db.name = db['table_schema']
                        mysql_user.databases.append(mysql_db.serialize())
                users.append(mysql_user.serialize())
        if result.rowcount <= limit:
            next_marker = None
        LOG.debug("users = " + str(users))

        return users, next_marker
Exemplo n.º 2
0
    def list_users(self, limit=None, marker=None, include_marker=False):
        """List users that have access to the database"""
        LOG.debug(_("---Listing Users---"))
        users = []
        client = LocalSqlClient(get_engine())
        with client:
            mysql_user = models.MySQLUser()
            q = Query()
            q.columns = ['User']
            q.tables = ['mysql.user']
            q.where = ["host != 'localhost'"]
            q.order = ['User']
            if marker:
                q.where.append(
                    "User %s '%s'" %
                    (INCLUDE_MARKER_OPERATORS[include_marker], marker))
            if limit:
                q.limit = limit + 1
            t = text(str(q))
            result = client.execute(t)
            next_marker = None
            LOG.debug("result = " + str(result))
            for count, row in enumerate(result):
                if count >= limit:
                    break
                LOG.debug("user = "******"^'(.+)'@", db['grantee'])
                    if (matches is not None
                            and matches.group(1) == mysql_user.name):
                        mysql_db = models.MySQLDatabase()
                        mysql_db.name = db['table_schema']
                        mysql_user.databases.append(mysql_db.serialize())
                users.append(mysql_user.serialize())
        if result.rowcount <= limit:
            next_marker = None
        LOG.debug("users = " + str(users))

        return users, next_marker