OpenStack KeyoneClient按名称获取用户
我知道可以通过id获得用户,但我所能得到的只是名称。有人知道如何使用keystone客户端V2.0按名称获取用户吗OpenStack KeyoneClient按名称获取用户,openstack,keystone,openstack-horizon,Openstack,Keystone,Openstack Horizon,我知道可以通过id获得用户,但我所能得到的只是名称。有人知道如何使用keystone客户端V2.0按名称获取用户吗 from keystoneclient.v2_0 import client keystone = client.Client(username=USER, password=PASS, tenant_name=TENANT_NAME,
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\u NAME)从keysteneclient中找到了一种实现这一点的方法。有点 例如:
#!/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开发列表上ping anne。