2

I know it is possible to get a user by id but all I have available is the name. Anyone know how to get a user by name using the keystone client 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)

need something like the following ** keystone.users.getByName(USER_NAME)

ldeluca
  • 934
  • 3
  • 12
  • 25

1 Answers1

3

Figured out a way to do this from keystoneclient. Sort of.

Example:

#!/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')

Makes use of utils in addition to the client.users

There are some extra parsing functions in util you might want to check out.

Matt Joyce
  • 2,010
  • 2
  • 20
  • 31
  • this stuff needs better documentation. ping anne gentle on the openstack-dev list if you want to help fill that out. – Matt Joyce Mar 21 '13 at 06:11