Skip to content

Commit 365d839

Browse files
committed
Fix 'mapping set' return value
Without this patch, the command 'openstack mapping set <args>' will, upon success, print the rules for the updated mapping and exit with return code 1 (failure). This is a problem for scripts and config management tools that depend on the return code to validate whether the operation was successful, since even upon success the command returns a failing error code. Moreover, the behavior of printing the new value is completely unlike the behavior of any of the 'set' subcommands for other entities. This patch normalizes the 'mapping set' command by omitting any return value in the SetMapping take_action() method. This way the client will only exit with an error code if an exception is raised, and not upon normal operation. Change-Id: I610ec3b2fa7561072346d46e49cfc1ae82130e0d
1 parent b69b539 commit 365d839

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

openstackclient/identity/v3/mapping.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ def take_action(self, parsed_args):
183183
rules=rules)
184184

185185
mapping._info.pop('links', None)
186-
return zip(*sorted(six.iteritems(mapping._info)))
187186

188187

189188
class ShowMapping(command.ShowOne):

openstackclient/tests/unit/identity/v3/test_mappings.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,12 @@ def test_set_new_rules(self):
181181
mocker.return_value = identity_fakes.MAPPING_RULES_2
182182
with mock.patch("openstackclient.identity.v3.mapping."
183183
"SetMapping._read_rules", mocker):
184-
columns, data = self.cmd.take_action(parsed_args)
184+
result = self.cmd.take_action(parsed_args)
185185
self.mapping_mock.update.assert_called_with(
186186
mapping=identity_fakes.mapping_id,
187187
rules=identity_fakes.MAPPING_RULES_2)
188188

189-
collist = ('id', 'rules')
190-
self.assertEqual(collist, columns)
191-
datalist = (identity_fakes.mapping_id,
192-
identity_fakes.MAPPING_RULES_2)
193-
self.assertEqual(datalist, data)
189+
self.assertIsNone(result)
194190

195191
def test_set_rules_wrong_file_path(self):
196192
arglist = [

0 commit comments

Comments
 (0)