From 72d62218ca2df4fea3431b647374f1d74042c8f6 Mon Sep 17 00:00:00 2001 From: Tim Schnell Date: Mon, 4 Nov 2013 16:22:36 -0600 Subject: [PATCH] Returning the json body after a stack-create or stack-update This allows the downstream service access to the data coming back from the REST API, primarily the stack id. implements blueprint return-id-on-stack-create Change-Id: I24db9c28fca1f50f5ef1452679f444095d22d103 --- heatclient/tests/test_stacks.py | 7 ++++++- heatclient/v1/stacks.py | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/heatclient/tests/test_stacks.py b/heatclient/tests/test_stacks.py index 20299a9f..d1920742 100644 --- a/heatclient/tests/test_stacks.py +++ b/heatclient/tests/test_stacks.py @@ -12,7 +12,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - from heatclient.v1.stacks import Stack from heatclient.v1.stacks import StackManager @@ -90,6 +89,12 @@ class StackOperationsTest(testtools.TestCase): stack.update() manager.update.assert_called_once_with('the_stack/abcd1234') + def test_create_stack(self): + manager = MagicMock() + stack = mock_stack(manager, 'the_stack', 'abcd1234') + stack = stack.create() + manager.create.assert_called_once_with('the_stack/abcd1234') + class StackManagerNoPaginationTest(testtools.TestCase): diff --git a/heatclient/v1/stacks.py b/heatclient/v1/stacks.py index 06874bcf..90a78de0 100644 --- a/heatclient/v1/stacks.py +++ b/heatclient/v1/stacks.py @@ -22,6 +22,9 @@ class Stack(base.Resource): def __repr__(self): return "" % self._info + def create(self, **fields): + return self.manager.create(self.identifier, **fields) + def update(self, **fields): self.manager.update(self.identifier, **fields) @@ -109,6 +112,7 @@ class StackManager(base.Manager): headers = self.api.credentials_headers() resp, body = self.api.json_request('POST', '/stacks', body=kwargs, headers=headers) + return body def update(self, stack_id, **kwargs): """Update a stack."""