summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Martinelli <stevemar@ca.ibm.com>2015-01-06 01:43:49 -0500
committerSteve Martinelli <stevemar@ca.ibm.com>2015-01-08 16:39:06 -0500
commite8be3b64c1956b58fa0a5b6d460c8bf07085951c (patch)
treeb1adffe0b23d4a7b4926ee207d02cb0abe62b5a1
parent6b196d1a17531b56d0a19b95a81a21c6a2ccc625 (diff)
downloadpython-openstackclient-e8be3b64c1956b58fa0a5b6d460c8bf07085951c.tar.gz
Command doc: mapping
Also tweaked the code for `mapping set` as it was previously using cliff Show instead of cliff Command. Change-Id: I0ea1383a9f2dddf4b2f717b2aa16bbd60ab1720c
-rw-r--r--doc/source/command-objects/mapping.rst91
-rw-r--r--doc/source/commands.rst1
-rw-r--r--openstackclient/identity/v3/mapping.py39
3 files changed, 113 insertions, 18 deletions
diff --git a/doc/source/command-objects/mapping.rst b/doc/source/command-objects/mapping.rst
new file mode 100644
index 00000000..5c7535bd
--- /dev/null
+++ b/doc/source/command-objects/mapping.rst
@@ -0,0 +1,91 @@
+=======
+mapping
+=======
+
+Identity v3
+
+`Requires: OS-FEDERATION extension`
+
+mapping create
+--------------
+
+Create new mapping
+
+.. program:: mapping create
+.. code:: bash
+
+ os mapping create
+ --rules <filename>
+ <name>
+
+.. option:: --rules <filename>
+
+ Filename that contains a set of mapping rules (required)
+
+.. _mapping_create-mapping:
+.. describe:: <name>
+
+ New mapping name (must be unique)
+
+mapping delete
+--------------
+
+Delete a mapping
+
+.. program:: mapping delete
+.. code:: bash
+
+ os mapping delete
+ <mapping>
+
+.. _mapping_delete-mapping:
+.. describe:: <mapping>
+
+ Mapping to delete
+
+mapping list
+------------
+
+List mappings
+
+.. program:: mapping list
+.. code:: bash
+
+ os mapping list
+
+mapping set
+-----------
+
+Set mapping properties
+
+.. program:: mapping set
+.. code:: bash
+
+ os mapping set
+ [--rules <filename>]
+ <mapping>
+
+.. option:: --rules <filename>
+
+ Filename that contains a new set of mapping rules
+
+.. _mapping_set-mapping:
+.. describe:: <mapping>
+
+ Mapping to modify
+
+mapping show
+------------
+
+Display mapping details
+
+.. program:: mapping show
+.. code:: bash
+
+ os mapping show
+ <mapping>
+
+.. _mapping_show-mapping:
+.. describe:: <mapping>
+
+ Mapping to display
diff --git a/doc/source/commands.rst b/doc/source/commands.rst
index bb3db187..8976fc02 100644
--- a/doc/source/commands.rst
+++ b/doc/source/commands.rst
@@ -93,6 +93,7 @@ referring to both Compute and Volume quotas.
* ``ip floating``: Compute, Network - a public IP address that can be mapped to a server
* ``keypair``: (**Compute**) an SSH public key
* ``limits``: (**Compute**, **Volume**) resource usage limits
+* ``mapping``: (**Identity**) a definition to translate identity provider attributes to Identity concepts
* ``module``: internal - installed Python modules in the OSC process
* ``network``: Network - a virtual network for connecting servers and other resources
* ``object``: (**Object Store**) a single file in the Object Store
diff --git a/openstackclient/identity/v3/mapping.py b/openstackclient/identity/v3/mapping.py
index c530a404..a1f60438 100644
--- a/openstackclient/identity/v3/mapping.py
+++ b/openstackclient/identity/v3/mapping.py
@@ -80,7 +80,7 @@ class _RulesReader(object):
class CreateMapping(show.ShowOne, _RulesReader):
- """Create new federation mapping"""
+ """Create new mapping"""
log = logging.getLogger(__name__ + '.CreateMapping')
@@ -89,12 +89,12 @@ class CreateMapping(show.ShowOne, _RulesReader):
parser.add_argument(
'mapping',
metavar='<name>',
- help='New mapping (must be unique)',
+ help='New mapping name (must be unique)',
)
parser.add_argument(
'--rules',
- metavar='<rules>', required=True,
- help='Filename with rules',
+ metavar='<filename>', required=True,
+ help='Filename that contains a set of mapping rules (required)',
)
return parser
@@ -112,7 +112,7 @@ class CreateMapping(show.ShowOne, _RulesReader):
class DeleteMapping(command.Command):
- """Delete federation mapping"""
+ """Delete a mapping"""
log = logging.getLogger(__name__ + '.DeleteMapping')
@@ -120,7 +120,7 @@ class DeleteMapping(command.Command):
parser = super(DeleteMapping, self).get_parser(prog_name)
parser.add_argument(
'mapping',
- metavar='<name>',
+ metavar='<mapping>',
help='Mapping to delete',
)
return parser
@@ -134,7 +134,7 @@ class DeleteMapping(command.Command):
class ListMapping(lister.Lister):
- """List federation mappings"""
+ """List mappings"""
log = logging.getLogger(__name__ + '.ListMapping')
def take_action(self, parsed_args):
@@ -149,8 +149,8 @@ class ListMapping(lister.Lister):
return (columns, items)
-class SetMapping(show.ShowOne, _RulesReader):
- """Update federation mapping"""
+class SetMapping(command.Command, _RulesReader):
+ """Set mapping properties"""
log = logging.getLogger(__name__ + '.SetMapping')
@@ -159,12 +159,12 @@ class SetMapping(show.ShowOne, _RulesReader):
parser.add_argument(
'mapping',
metavar='<name>',
- help='Mapping to update.',
+ help='Mapping to modify',
)
parser.add_argument(
'--rules',
- metavar='<rules>', required=True,
- help='Filename with rules',
+ metavar='<filename>',
+ help='Filename that contains a new set of mapping rules',
)
return parser
@@ -172,19 +172,22 @@ class SetMapping(show.ShowOne, _RulesReader):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
+ if not parsed_args.rules:
+ self.app.log.error("No changes requested")
+ return
+
rules = self._read_rules(parsed_args.rules)
mapping = identity_client.federation.mappings.update(
mapping=parsed_args.mapping,
rules=rules)
- info = {}
- info.update(mapping._info)
- return zip(*sorted(six.iteritems(info)))
+ mapping._info.pop('links', None)
+ return zip(*sorted(six.iteritems(mapping._info)))
class ShowMapping(show.ShowOne):
- """Show federation mapping details"""
+ """Display mapping details"""
log = logging.getLogger(__name__ + '.ShowMapping')
@@ -192,8 +195,8 @@ class ShowMapping(show.ShowOne):
parser = super(ShowMapping, self).get_parser(prog_name)
parser.add_argument(
'mapping',
- metavar='<name>',
- help='Mapping to show',
+ metavar='<mapping>',
+ help='Mapping to display',
)
return parser