Finish up v3 role commands

* Add remove role
* Add --role to group list
* Add --role to user list
* Fix groups in AddRole()
* Remove the tweaks to utils.find_resource for domains; will address
  that across domains, projects, users and groups in another patch.
  I want to nail down the structure of these commands and get that into place

Change-Id: I8673dd8221ef88978dada5a2833c187026bdb31a
This commit is contained in:
Steve Martinelli 2013-04-18 17:49:42 -05:00 committed by Dean Troyer
parent 3a0f8c4857
commit 5c8eabd06d
3 changed files with 24 additions and 3 deletions
openstackclient
setup.cfg

@ -24,20 +24,27 @@ from openstackclient.common import exceptions
def find_resource(manager, name_or_id):
"""Helper for the _find_* methods."""
# first try to get entity as integer id
# Try to get entity as integer id
try:
if isinstance(name_or_id, int) or name_or_id.isdigit():
return manager.get(int(name_or_id))
except exceptions.NotFound:
pass
# now try to get entity as uuid
# Try to get entity as uuid
try:
uuid.UUID(str(name_or_id))
return manager.get(name_or_id)
except (ValueError, exceptions.NotFound):
pass
# Try directly using the passed value
try:
return manager.get(name_or_id)
except Exception:
pass
kwargs = {}
if 'NAME_ATTR' in manager.resource_class.__dict__:
# novaclient does this for oddball resources

@ -37,6 +37,7 @@ DEFAULT_COMPUTE_API_VERSION = '2'
DEFAULT_IDENTITY_API_VERSION = '2.0'
DEFAULT_IMAGE_API_VERSION = '2'
DEFAULT_VOLUME_API_VERSION = '1'
DEFAULT_DOMAIN = 'default'
def env(*vars, **kwargs):
@ -134,6 +135,15 @@ class OpenStackShell(app.App):
metavar='<auth-region-name>',
default=env('OS_REGION_NAME'),
help='Authentication region name (Env: OS_REGION_NAME)')
parser.add_argument(
'--os-default-domain',
metavar='<auth-domain>',
default=env(
'OS_DEFAULT_DOMAIN',
default=DEFAULT_DOMAIN),
help='Default domain ID, default=' +
DEFAULT_DOMAIN +
' (Env: OS_DEFAULT_DOMAIN)')
parser.add_argument(
'--os-identity-api-version',
metavar='<identity-api-version>',
@ -304,7 +314,10 @@ class OpenStackShell(app.App):
else:
requests_log.setLevel(logging.WARNING)
# stash selected API versions for later
# Save default domain
self.default_domain = self.options.os_default_domain
# Stash selected API versions for later
self.api_version = {
'compute': self.options.os_compute_api_version,
'identity': self.options.os_identity_api_version,

@ -104,6 +104,7 @@ openstack.identity.v3 =
role_create = openstackclient.identity.v3.role:CreateRole
role_delete = openstackclient.identity.v3.role:DeleteRole
role_list = openstackclient.identity.v3.role:ListRole
role_remove = openstackclient.identity.v3.role:RemoveRole
role_show = openstackclient.identity.v3.role:ShowRole
role_set = openstackclient.identity.v3.role:SetRole