summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRabi Mishra <ramishra@redhat.com>2015-07-07 13:35:02 +0530
committerRabi Mishra <ramishra@redhat.com>2015-07-23 15:39:11 +0530
commit997cbc63c987aceb346d48a26e07fc98fe0a4b33 (patch)
tree7f6cc52a0e7c49c4bf52e2d01b9faca8e92f94ed
parent5c78a6567b7b31b0545ca4ffe33479d553624473 (diff)
downloadpython-heatclient-997cbc63c987aceb346d48a26e07fc98fe0a4b33.tar.gz
Add missing `deployment-list` to cli
This patch adds `deployment-list` command to cli. $heat deployment-list $heat deployment-list -s <server_id> Change-Id: Id2a21d3f3bb5e88bacbe30dc184e4cff131ab2e0
-rw-r--r--heatclient/tests/unit/test_shell.py59
-rw-r--r--heatclient/v1/shell.py11
2 files changed, 70 insertions, 0 deletions
diff --git a/heatclient/tests/unit/test_shell.py b/heatclient/tests/unit/test_shell.py
index b435053..5922f1e 100644
--- a/heatclient/tests/unit/test_shell.py
+++ b/heatclient/tests/unit/test_shell.py
@@ -3814,6 +3814,65 @@ class ShellTestDeployment(ShellBase):
'deployment-create -c defgh -s inst01 yyy')
self.m.VerifyAll()
+ def test_deploy_list(self):
+ self.register_keystone_auth_fixture()
+
+ resp_dict = {
+ 'software_deployments':
+ [{'status': 'COMPLETE',
+ 'server_id': '123',
+ 'config_id': '18c4fc03-f897-4a1d-aaad-2b7622e60257',
+ 'output_values': {
+ 'deploy_stdout': '',
+ 'deploy_stderr': '',
+ 'deploy_status_code': 0,
+ 'result': 'The result value'
+ },
+ 'input_values': {},
+ 'action': 'CREATE',
+ 'status_reason': 'Outputs received',
+ 'id': 'defg'}, ]
+ }
+ resp_string = jsonutils.dumps(resp_dict)
+ headers = {'content-type': 'application/json'}
+ http_resp = fakes.FakeHTTPResponse(200, 'OK', headers, resp_string)
+ response = (http_resp, resp_dict)
+ if self.client == http.SessionClient:
+ self.client.request(
+ '/software_deployments?', 'GET').AndReturn(http_resp)
+ self.client.request(
+ '/software_deployments?server_id=123',
+ 'GET').AndReturn(http_resp)
+ else:
+ self.client.json_request(
+ 'GET', '/software_deployments?').AndReturn(response)
+ self.client.json_request(
+ 'GET',
+ '/software_deployments?server_id=123').AndReturn(response)
+
+ self.m.ReplayAll()
+
+ list_text = self.shell('deployment-list')
+
+ required = [
+ 'id',
+ 'config_id',
+ 'server_id',
+ 'action',
+ 'status',
+ 'creation_time',
+ 'status_reason',
+ ]
+ for r in required:
+ self.assertRegexpMatches(list_text, r)
+ self.assertNotRegexpMatches(list_text, 'parent')
+
+ list_text = self.shell('deployment-list -s 123')
+
+ for r in required:
+ self.assertRegexpMatches(list_text, r)
+ self.assertNotRegexpMatches(list_text, 'parent')
+
def test_deploy_show(self):
self.register_keystone_auth_fixture()
resp_dict = {'software_deployment': {
diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py
index a4d7af9..cdf7ec0 100644
--- a/heatclient/v1/shell.py
+++ b/heatclient/v1/shell.py
@@ -1226,6 +1226,17 @@ def do_deployment_create(hc, args):
print(jsonutils.dumps(sd.to_dict(), indent=2))
+@utils.arg('-s', '--server', metavar='<SERVER>',
+ help=_('ID of the server to fetch deployments for.'))
+def do_deployment_list(hc, args):
+ '''List software deployments.'''
+ kwargs = {'server_id': args.server} if args.server else {}
+ deployments = hc.software_deployments.list(**kwargs)
+ fields = ['id', 'config_id', 'server_id', 'action', 'status',
+ 'creation_time', 'status_reason']
+ utils.print_list(deployments, fields, sortby_index=5)
+
+
@utils.arg('id', metavar='<ID>',
help=_('ID of the deployment.'))
def do_deployment_show(hc, args):