问答详情
源自:-

如何查询用户在租户中的角色?

 通过命令行。

提问者:刻骨铭心_ 2016-06-21 10:43

个回答

  • XhstormR
    2016-06-21 10:44:23
    已采纳

    [root@hh-yun-puppet-129021 ~(keystone_admin)]# keystone --os-username terry.zeng --os-password 123123 --os-tenant-name QA user-role-list
    +----------------------------------+----------+----------------------------------+----------------------------------+
    |                id                |   name   |             user_id              |            tenant_id             |
    +----------------------------------+----------+----------------------------------+----------------------------------+
    | 9fe2ff9ee4384b1894a90878d3e92bab | _member_ | 62b3813eb92e415b85816722e9479636 | 98e5fdd9e50f423881f49c845e1d26ad |
    | 301acc99e28c457f9b27087a1eb1ab0b |  admin   | 62b3813eb92e415b85816722e9479636 | 98e5fdd9e50f423881f49c845e1d26ad |
    +----------------------------------+----------+----------------------------------+----------------------------------+

    第二种:查询数据库

    mysql> select a.name username, b.name tenant, c.name role  from keystone.user a, keystone.project b, keystone.role c, keystone.assignment d  where a.id = d.actor_id  and b.id = d.target_id  and c.id = d.role_id and a.name='terry.zeng' order by tenant;
    +------------+--------+----------+
    | username   | tenant | role     |
    +------------+--------+----------+
    | terry.zeng | DEV    | _member_ |
    | terry.zeng | DEV    | admin    |
    | terry.zeng | DMZ1   | _member_ |
    | terry.zeng | DMZ1   | admin    |
    | terry.zeng | DMZ2   | admin    |
    | terry.zeng | DMZ2   | _member_ |
    | terry.zeng | MGMT   | _member_ |
    | terry.zeng | MGMT   | admin    |
    | terry.zeng | MOBILE | _member_ |
    | terry.zeng | MOBILE | admin    |
    | terry.zeng | OPS    | _member_ |
    | terry.zeng | QA     | admin    |
    | terry.zeng | QA     | _member_ |
    | terry.zeng | QATOOL | admin    |
    | terry.zeng | QATOOL | _member_ |
    +------------+--------+----------+
    15 rows in set (0.01 sec)
    望采纳。