summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/identity/v3/policy.py63
1 files changed, 34 insertions, 29 deletions
diff --git a/openstackclient/identity/v3/policy.py b/openstackclient/identity/v3/policy.py
index 802880bf..82935423 100644
--- a/openstackclient/identity/v3/policy.py
+++ b/openstackclient/identity/v3/policy.py
@@ -27,7 +27,7 @@ from openstackclient.common import utils
class CreatePolicy(show.ShowOne):
- """Create policy command"""
+ """Create new policy"""
log = logging.getLogger(__name__ + '.CreatePolicy')
@@ -35,20 +35,21 @@ class CreatePolicy(show.ShowOne):
parser = super(CreatePolicy, self).get_parser(prog_name)
parser.add_argument(
'--type',
- metavar='<policy-type>',
+ metavar='<type>',
default="application/json",
- help='New MIME type of the policy blob - i.e.: application/json',
+ help='New MIME type of the policy rules file '
+ '(defaults to application/json)',
)
parser.add_argument(
- 'blob_file',
- metavar='<blob-file>',
- help='New policy rule set itself, as a serialized blob, in a file',
+ 'rules',
+ metavar='<filename>',
+ help='New serialized policy rules file',
)
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
- blob = utils.read_blob_file_contents(parsed_args.blob_file)
+ blob = utils.read_blob_file_contents(parsed_args.rules)
identity_client = self.app.client_manager.identity
policy = identity_client.policies.create(
@@ -56,11 +57,12 @@ class CreatePolicy(show.ShowOne):
)
policy._info.pop('links')
+ policy._info.update({'rules': policy._info.pop('blob')})
return zip(*sorted(six.iteritems(policy._info)))
class DeletePolicy(command.Command):
- """Delete policy command"""
+ """Delete policy"""
log = logging.getLogger(__name__ + '.DeletePolicy')
@@ -68,8 +70,8 @@ class DeletePolicy(command.Command):
parser = super(DeletePolicy, self).get_parser(prog_name)
parser.add_argument(
'policy',
- metavar='<policy-id>',
- help='ID of policy to delete',
+ metavar='<policy>',
+ help='Policy to delete',
)
return parser
@@ -81,28 +83,30 @@ class DeletePolicy(command.Command):
class ListPolicy(lister.Lister):
- """List policy command"""
+ """List policies"""
log = logging.getLogger(__name__ + '.ListPolicy')
def get_parser(self, prog_name):
parser = super(ListPolicy, self).get_parser(prog_name)
parser.add_argument(
- '--include-blob',
+ '--long',
action='store_true',
default=False,
- help='Additional fields are listed in output',
+ help='List additional fields in output',
)
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
- if parsed_args.include_blob:
+ if parsed_args.long:
columns = ('ID', 'Type', 'Blob')
+ column_headers = ('ID', 'Type', 'Rules')
else:
columns = ('ID', 'Type')
+ column_headers = columns
data = self.app.client_manager.identity.policies.list()
- return (columns,
+ return (column_headers,
(utils.get_item_properties(
s, columns,
formatters={},
@@ -110,7 +114,7 @@ class ListPolicy(lister.Lister):
class SetPolicy(command.Command):
- """Set policy command"""
+ """Set policy properties"""
log = logging.getLogger(__name__ + '.SetPolicy')
@@ -118,18 +122,18 @@ class SetPolicy(command.Command):
parser = super(SetPolicy, self).get_parser(prog_name)
parser.add_argument(
'policy',
- metavar='<policy-id>',
- help='ID of policy to change',
+ metavar='<policy>',
+ help='Policy to modify',
)
parser.add_argument(
'--type',
- metavar='<policy-type>',
- help='New MIME Type of the policy blob - i.e.: application/json',
+ metavar='<type>',
+ help='New MIME type of the policy rules file',
)
parser.add_argument(
- '--blob-file',
- metavar='<blob_file>',
- help='New policy rule set itself, as a serialized blob, in a file',
+ '--rules',
+ metavar='<filename>',
+ help='New serialized policy rules file',
)
return parser
@@ -138,8 +142,8 @@ class SetPolicy(command.Command):
identity_client = self.app.client_manager.identity
blob = None
- if parsed_args.blob_file:
- blob = utils.read_blob_file_contents(parsed_args.blob_file)
+ if parsed_args.rules:
+ blob = utils.read_blob_file_contents(parsed_args.rules)
kwargs = {}
if blob:
@@ -148,14 +152,14 @@ class SetPolicy(command.Command):
kwargs['type'] = parsed_args.type
if not kwargs:
- sys.stdout.write("Policy not updated, no arguments present \n")
+ sys.stdout.write('Policy not updated, no arguments present \n')
return
identity_client.policies.update(parsed_args.policy, **kwargs)
return
class ShowPolicy(show.ShowOne):
- """Show policy command"""
+ """Display policy details"""
log = logging.getLogger(__name__ + '.ShowPolicy')
@@ -163,8 +167,8 @@ class ShowPolicy(show.ShowOne):
parser = super(ShowPolicy, self).get_parser(prog_name)
parser.add_argument(
'policy',
- metavar='<policy-id>',
- help='ID of policy to display',
+ metavar='<policy>',
+ help='Policy to display',
)
return parser
@@ -175,4 +179,5 @@ class ShowPolicy(show.ShowOne):
parsed_args.policy)
policy._info.pop('links')
+ policy._info.update({'rules': policy._info.pop('blob')})
return zip(*sorted(six.iteritems(policy._info)))