Skip to content

Commit e8be3b6

Browse files
author
Steve Martinelli
committed
Command doc: mapping
Also tweaked the code for `mapping set` as it was previously using cliff Show instead of cliff Command. Change-Id: I0ea1383a9f2dddf4b2f717b2aa16bbd60ab1720c
1 parent 6b196d1 commit e8be3b6

3 files changed

Lines changed: 113 additions & 18 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
=======
2+
mapping
3+
=======
4+
5+
Identity v3
6+
7+
`Requires: OS-FEDERATION extension`
8+
9+
mapping create
10+
--------------
11+
12+
Create new mapping
13+
14+
.. program:: mapping create
15+
.. code:: bash
16+
17+
os mapping create
18+
--rules <filename>
19+
<name>
20+
21+
.. option:: --rules <filename>
22+
23+
Filename that contains a set of mapping rules (required)
24+
25+
.. _mapping_create-mapping:
26+
.. describe:: <name>
27+
28+
New mapping name (must be unique)
29+
30+
mapping delete
31+
--------------
32+
33+
Delete a mapping
34+
35+
.. program:: mapping delete
36+
.. code:: bash
37+
38+
os mapping delete
39+
<mapping>
40+
41+
.. _mapping_delete-mapping:
42+
.. describe:: <mapping>
43+
44+
Mapping to delete
45+
46+
mapping list
47+
------------
48+
49+
List mappings
50+
51+
.. program:: mapping list
52+
.. code:: bash
53+
54+
os mapping list
55+
56+
mapping set
57+
-----------
58+
59+
Set mapping properties
60+
61+
.. program:: mapping set
62+
.. code:: bash
63+
64+
os mapping set
65+
[--rules <filename>]
66+
<mapping>
67+
68+
.. option:: --rules <filename>
69+
70+
Filename that contains a new set of mapping rules
71+
72+
.. _mapping_set-mapping:
73+
.. describe:: <mapping>
74+
75+
Mapping to modify
76+
77+
mapping show
78+
------------
79+
80+
Display mapping details
81+
82+
.. program:: mapping show
83+
.. code:: bash
84+
85+
os mapping show
86+
<mapping>
87+
88+
.. _mapping_show-mapping:
89+
.. describe:: <mapping>
90+
91+
Mapping to display

‎doc/source/commands.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ referring to both Compute and Volume quotas.
9393
* ``ip floating``: Compute, Network - a public IP address that can be mapped to a server
9494
* ``keypair``: (**Compute**) an SSH public key
9595
* ``limits``: (**Compute**, **Volume**) resource usage limits
96+
* ``mapping``: (**Identity**) a definition to translate identity provider attributes to Identity concepts
9697
* ``module``: internal - installed Python modules in the OSC process
9798
* ``network``: Network - a virtual network for connecting servers and other resources
9899
* ``object``: (**Object Store**) a single file in the Object Store

‎openstackclient/identity/v3/mapping.py‎

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _read_rules(self, path):
8080

8181

8282
class CreateMapping(show.ShowOne, _RulesReader):
83-
"""Create new federation mapping"""
83+
"""Create new mapping"""
8484

8585
log = logging.getLogger(__name__ + '.CreateMapping')
8686

@@ -89,12 +89,12 @@ def get_parser(self, prog_name):
8989
parser.add_argument(
9090
'mapping',
9191
metavar='<name>',
92-
help='New mapping (must be unique)',
92+
help='New mapping name (must be unique)',
9393
)
9494
parser.add_argument(
9595
'--rules',
96-
metavar='<rules>', required=True,
97-
help='Filename with rules',
96+
metavar='<filename>', required=True,
97+
help='Filename that contains a set of mapping rules (required)',
9898
)
9999
return parser
100100

@@ -112,15 +112,15 @@ def take_action(self, parsed_args):
112112

113113

114114
class DeleteMapping(command.Command):
115-
"""Delete federation mapping"""
115+
"""Delete a mapping"""
116116

117117
log = logging.getLogger(__name__ + '.DeleteMapping')
118118

119119
def get_parser(self, prog_name):
120120
parser = super(DeleteMapping, self).get_parser(prog_name)
121121
parser.add_argument(
122122
'mapping',
123-
metavar='<name>',
123+
metavar='<mapping>',
124124
help='Mapping to delete',
125125
)
126126
return parser
@@ -134,7 +134,7 @@ def take_action(self, parsed_args):
134134

135135

136136
class ListMapping(lister.Lister):
137-
"""List federation mappings"""
137+
"""List mappings"""
138138
log = logging.getLogger(__name__ + '.ListMapping')
139139

140140
def take_action(self, parsed_args):
@@ -149,8 +149,8 @@ def take_action(self, parsed_args):
149149
return (columns, items)
150150

151151

152-
class SetMapping(show.ShowOne, _RulesReader):
153-
"""Update federation mapping"""
152+
class SetMapping(command.Command, _RulesReader):
153+
"""Set mapping properties"""
154154

155155
log = logging.getLogger(__name__ + '.SetMapping')
156156

@@ -159,41 +159,44 @@ def get_parser(self, prog_name):
159159
parser.add_argument(
160160
'mapping',
161161
metavar='<name>',
162-
help='Mapping to update.',
162+
help='Mapping to modify',
163163
)
164164
parser.add_argument(
165165
'--rules',
166-
metavar='<rules>', required=True,
167-
help='Filename with rules',
166+
metavar='<filename>',
167+
help='Filename that contains a new set of mapping rules',
168168
)
169169
return parser
170170

171171
def take_action(self, parsed_args):
172172
self.log.debug('take_action(%s)' % parsed_args)
173173
identity_client = self.app.client_manager.identity
174174

175+
if not parsed_args.rules:
176+
self.app.log.error("No changes requested")
177+
return
178+
175179
rules = self._read_rules(parsed_args.rules)
176180

177181
mapping = identity_client.federation.mappings.update(
178182
mapping=parsed_args.mapping,
179183
rules=rules)
180184

181-
info = {}
182-
info.update(mapping._info)
183-
return zip(*sorted(six.iteritems(info)))
185+
mapping._info.pop('links', None)
186+
return zip(*sorted(six.iteritems(mapping._info)))
184187

185188

186189
class ShowMapping(show.ShowOne):
187-
"""Show federation mapping details"""
190+
"""Display mapping details"""
188191

189192
log = logging.getLogger(__name__ + '.ShowMapping')
190193

191194
def get_parser(self, prog_name):
192195
parser = super(ShowMapping, self).get_parser(prog_name)
193196
parser.add_argument(
194197
'mapping',
195-
metavar='<name>',
196-
help='Mapping to show',
198+
metavar='<mapping>',
199+
help='Mapping to display',
197200
)
198201
return parser
199202

0 commit comments

Comments
 (0)