【问题标题】:OpenStack keystoneclient get user by nameOpenStack keystoneclient 按名称获取用户
【发布时间】:2013-03-09 15:37:03
【问题描述】:

我知道可以通过 id 获取用户,但我只有名称。有人知道如何使用 keystone 客户端 v 2.0 按名称获取用户吗?

from keystoneclient.v2_0 import client
keystone = client.Client(username=USER,
                         password=PASS,
                         tenant_name=TENANT_NAME,
                         auth_url=KEYSTONE_URL)
user = keystone.users.get(USER_ID)

需要类似下面的东西 ** keystone.users.getByName(USER_NAME)

【问题讨论】:

    标签: openstack keystone openstack-horizon


    【解决方案1】:

    从 keystoneclient 想出了一个方法来做到这一点。有点像。

    例子:

    #!/usr/bin/env python
    
    from keystoneclient.v2_0 import client
    from keystoneclient import utils
    
    keystone = client.Client(username='admin',
                             password='stack',
                             tenant_name='demo',
                             auth_url='http://192.168.122.236:5000/v2.0/')
    
    
    def do_user_get(kc, args):
        """Display user details."""
        user = utils.find_resource(kc.users, args)
        utils.print_dict(user._info)
    
    do_user_get (keystone, 'demo')
    

    除了 client.users 之外还使用 utils

    在 util 中有一些额外的解析函数你可能想看看。

    【讨论】:

    • 这东西需要更好的文档。如果您想帮助填写,请在 openstack-dev 列表上 ping annegent。
    猜你喜欢
    • 1970-01-01
    • 2013-01-08
    • 2022-10-16
    • 1970-01-01
    • 2013-02-04
    • 1970-01-01
    • 2023-02-08
    • 2012-05-30
    相关资源
    最近更新 更多