UPDATE 03/18/16
See http://www.ibm.com/developerworks/clo...
Listing 5. credentials.py
Listing 6. Successfully authenticating against a keystone endpoint in an interactive Python session
Listing 7. Creating a user, tenant, and role
Listing 8. Creating a service and endpoint
Listing 9. Querying for the glance endpoint in an interactive Python session
END UPDATE
UPDATE
Admin token is in the top of /etc/keystone/keystone.conf
END UPDATE
Using the V2 client API
[root@ServerCenttOS01 ~]# python
Python 2.7.5 (default, Nov 20 2015, 02:00:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from keystoneclient.v2_0 import client
>>> token = '3ad2de159f9649afb0c342ba57e637d9'
>>> endpoint = 'http://192.169.142.127:35357/v2.0'
>>> keystone = client.Client(token=token, endpoint=endpoint)
>>> keystone.tenants.create(tenant_name="openstackDemo",
... description="Default Tenant", enabled=True)
<Tenant {u'enabled': True, u'description': u'Default Tenant', u'name': u'openstackDemo', u'id': u'e463fca1ca154a11a400499c494ca328'}>
>>> keystone.tenants.list()
[<Tenant {u'enabled': True, u'description': u'default tenant', u'name': u'demo', u'id': u'06f56a00961e4c3ea10b537df8c86e1b'}>, <Tenant {u'enabled': True, u'description': u'Tenant for the openstack services', u'name': u'services', u'id': u'45f21a5d2563415cb8f9eb6e3a775c18'}>, <Tenant {u'enabled': True, u'description': u'Default Tenant', u'name': u'openstackDemo', u'id': u'e463fca1ca154a11a400499c494ca328'}>, <Tenant {u'enabled': True, u'description': u'admin tenant', u'name': u'admin', u'id': u'ec18a949efd8430b9a2b0b908501562b'}>]
>>>
Regarding Using the V3 Client API see http://docs.openstack.org/developer/p...