summaryrefslogtreecommitdiff
path: root/openstackclient/identity
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2013-08-27 16:57:30 -0500
committerGerrit Code Review <review@openstack.org>2013-09-04 21:37:45 +0000
commit44c97cc099a35af2d3d999f9799238fc72be071d (patch)
treecceb16e89655044e3ec122cb1c002397a411ffac /openstackclient/identity
parenteb405a88c47e91633ecb110122410aa24c24f9cd (diff)
downloadpython-openstackclient-44c97cc099a35af2d3d999f9799238fc72be071d.tar.gz
Add Identity v2 role and service tests
* Add current auth info (auth_ref) to ClientManager * Fix identity.v2_0.role.ListUserRole to get default user/project from ClientManager.auth_ref * Fix identity.v2_0.role.AddRole call to roles.add_user_role() Change-Id: Ie8bf41c491d97b0292a2b86bdc9b7580989a7f97
Diffstat (limited to 'openstackclient/identity')
-rw-r--r--openstackclient/identity/client.py3
-rw-r--r--openstackclient/identity/v2_0/role.py27
2 files changed, 21 insertions, 9 deletions
diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py
index 8e2bda40..8c9437ba 100644
--- a/openstackclient/identity/client.py
+++ b/openstackclient/identity/client.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2013 OpenStack, LLC.
+# Copyright 2012-2013 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -48,6 +48,7 @@ def make_client(instance):
tenant_id=instance._project_id,
auth_url=instance._auth_url,
region_name=instance._region_name)
+ instance.auth_ref = client.auth_ref
return client
diff --git a/openstackclient/identity/v2_0/role.py b/openstackclient/identity/v2_0/role.py
index 58052536..60a1f947 100644
--- a/openstackclient/identity/v2_0/role.py
+++ b/openstackclient/identity/v2_0/role.py
@@ -22,6 +22,7 @@ from cliff import command
from cliff import lister
from cliff import show
+from openstackclient.common import exceptions
from openstackclient.common import utils
@@ -59,9 +60,10 @@ class AddRole(show.ShowOne):
)
user = utils.find_resource(identity_client.users, parsed_args.user)
role = identity_client.roles.add_user_role(
- user,
- role,
- project)
+ user.id,
+ role.id,
+ project.id,
+ )
info = {}
info.update(role._info)
@@ -150,14 +152,23 @@ class ListUserRole(lister.Lister):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
+ auth_ref = self.app.client_manager.auth_ref
- # user-only roles are not supported in KSL so we are
- # required to have a user and project; default to the
- # values used for authentication if not specified
+ # Project and user are required, if not included in command args
+ # default to the values used for authentication. For token-flow
+ # authentication they must be included on the command line.
if not parsed_args.project:
- parsed_args.project = identity_client.auth_tenant_id
+ if self.app.client_manager.auth_ref:
+ parsed_args.project = auth_ref.project_id
+ else:
+ msg = "Project must be specified"
+ raise exceptions.CommandError(msg)
if not parsed_args.user:
- parsed_args.user = identity_client.auth_user_id
+ if self.app.client_manager.auth_ref:
+ parsed_args.user = auth_ref.user_id
+ else:
+ msg = "User must be specified"
+ raise exceptions.CommandError(msg)
project = utils.find_resource(
identity_client.tenants,