@@ -38,16 +38,20 @@ class Client(client.HTTPClient):
|
|||||||
:param string auth_url: Keystone service endpoint for authorization.
|
:param string auth_url: Keystone service endpoint for authorization.
|
||||||
:param string region_name: Name of a region to select when choosing an
|
:param string region_name: Name of a region to select when choosing an
|
||||||
endpoint from the service catalog.
|
endpoint from the service catalog.
|
||||||
:param string endpoint: A user-supplied endpoint URL for the keystone service.
|
:param string endpoint: A user-supplied endpoint URL for the keystone
|
||||||
Lazy-authentication is possible for API service calls
|
service. Lazy-authentication is possible for API
|
||||||
if endpoint is set at instantiation.(optional)
|
service calls if endpoint is set at
|
||||||
|
instantiation.(optional)
|
||||||
:param integer timeout: Allows customization of the timeout for client
|
:param integer timeout: Allows customization of the timeout for client
|
||||||
http requests. (optional)
|
http requests. (optional)
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
>>> from keystoneclient.v2_0 import client
|
>>> from keystoneclient.v2_0 import client
|
||||||
>>> keystone = client.Client(username=USER, password=PASS, project_id=TENANT, auth_url=KEYSTONE_URL)
|
>>> keystone = client.Client(username=USER,
|
||||||
|
password=PASS,
|
||||||
|
project_id=TENANT,
|
||||||
|
auth_url=KEYSTONE_URL)
|
||||||
>>> keystone.tenants.list()
|
>>> keystone.tenants.list()
|
||||||
...
|
...
|
||||||
>>> user = keystone.users.get(USER_ID)
|
>>> user = keystone.users.get(USER_ID)
|
||||||
@@ -94,7 +98,8 @@ class Client(client.HTTPClient):
|
|||||||
raise
|
raise
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
_logger.exception("Authorization Failed.")
|
_logger.exception("Authorization Failed.")
|
||||||
raise exceptions.AuthorizationFailure("Authorization Failed: %s" % e)
|
raise exceptions.AuthorizationFailure("Authorization Failed: "
|
||||||
|
"%s" % e)
|
||||||
|
|
||||||
def _extract_service_catalog(self, url, body):
|
def _extract_service_catalog(self, url, body):
|
||||||
""" Set the client's service catalog from the response data. """
|
""" Set the client's service catalog from the response data. """
|
||||||
|
@@ -57,7 +57,8 @@ class UserManager(base.ManagerWithFind):
|
|||||||
params = {"user": {"id": base.getid(user),
|
params = {"user": {"id": base.getid(user),
|
||||||
"password": password}}
|
"password": password}}
|
||||||
|
|
||||||
return self._update("/users/%s/password" % base.getid(user), params, "user")
|
return self._update("/users/%s/password" % base.getid(user),
|
||||||
|
params, "user")
|
||||||
|
|
||||||
def update_tenant(self, user, tenant):
|
def update_tenant(self, user, tenant):
|
||||||
"""
|
"""
|
||||||
@@ -68,13 +69,14 @@ class UserManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
# FIXME(ja): seems like a bad url - default tenant is an attribute
|
# FIXME(ja): seems like a bad url - default tenant is an attribute
|
||||||
# not a subresource!???
|
# not a subresource!???
|
||||||
return self._update("/users/%s/tenant" % base.getid(user), params, "user")
|
return self._update("/users/%s/tenant" % base.getid(user),
|
||||||
|
params, "user")
|
||||||
|
|
||||||
def create(self, name, password, email, tenant_id=None, enabled=True):
|
def create(self, name, password, email, tenant_id=None, enabled=True):
|
||||||
"""
|
"""
|
||||||
Create a user.
|
Create a user.
|
||||||
"""
|
"""
|
||||||
# FIXME(ja): email should be optional but keystone currently requires it
|
# FIXME(ja): email should be optional, keystone currently requires it
|
||||||
params = {"user": {"name": name,
|
params = {"user": {"name": name,
|
||||||
"password": password,
|
"password": password,
|
||||||
"tenantId": tenant_id,
|
"tenantId": tenant_id,
|
||||||
|
Reference in New Issue
Block a user