From 365d839a5b4e685d9a12f81386ddfaab07c56d83 Mon Sep 17 00:00:00 2001
From: Colleen Murphy <colleen@gazlene.net>
Date: Wed, 25 Jan 2017 18:07:17 +0100
Subject: [PATCH] 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
---
 openstackclient/identity/v3/mapping.py                  | 1 -
 openstackclient/tests/unit/identity/v3/test_mappings.py | 8 ++------
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/openstackclient/identity/v3/mapping.py b/openstackclient/identity/v3/mapping.py
index dbb1b06870..28080f8957 100644
--- a/openstackclient/identity/v3/mapping.py
+++ b/openstackclient/identity/v3/mapping.py
@@ -183,7 +183,6 @@ class SetMapping(command.Command, _RulesReader):
             rules=rules)
 
         mapping._info.pop('links', None)
-        return zip(*sorted(six.iteritems(mapping._info)))
 
 
 class ShowMapping(command.ShowOne):
diff --git a/openstackclient/tests/unit/identity/v3/test_mappings.py b/openstackclient/tests/unit/identity/v3/test_mappings.py
index 5086724c24..93fe1196c9 100644
--- a/openstackclient/tests/unit/identity/v3/test_mappings.py
+++ b/openstackclient/tests/unit/identity/v3/test_mappings.py
@@ -181,16 +181,12 @@ class TestMappingSet(TestMapping):
         mocker.return_value = identity_fakes.MAPPING_RULES_2
         with mock.patch("openstackclient.identity.v3.mapping."
                         "SetMapping._read_rules", mocker):
-            columns, data = self.cmd.take_action(parsed_args)
+            result = self.cmd.take_action(parsed_args)
         self.mapping_mock.update.assert_called_with(
             mapping=identity_fakes.mapping_id,
             rules=identity_fakes.MAPPING_RULES_2)
 
-        collist = ('id', 'rules')
-        self.assertEqual(collist, columns)
-        datalist = (identity_fakes.mapping_id,
-                    identity_fakes.MAPPING_RULES_2)
-        self.assertEqual(datalist, data)
+        self.assertIsNone(result)
 
     def test_set_rules_wrong_file_path(self):
         arglist = [