diff --git a/novaclient/tests/v1_1/fakes.py b/novaclient/tests/v1_1/fakes.py index 387ba1979..6ed88a11d 100644 --- a/novaclient/tests/v1_1/fakes.py +++ b/novaclient/tests/v1_1/fakes.py @@ -945,6 +945,9 @@ class FakeHTTPClient(base_client.HTTPClient): def get_images_2(self, **kw): return (200, {}, {'image': self.get_images_detail()[2]['images'][1]}) + def get_images_456(self, **kw): + return (200, {}, {'image': self.get_images_detail()[2]['images'][1]}) + def post_images(self, body, **kw): assert list(body) == ['image'] fakes.assert_has_keys(body['image'], required=['serverId', 'name']) diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index 73cce29b0..c8758cff3 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -661,6 +661,16 @@ class ShellTest(utils.TestCase): {'createImage': {'name': 'mysnapshot', 'metadata': {}}}, ) + def test_create_image_show(self): + output = self.run_command('image-create ' + 'sample-server mysnapshot --show') + self.assert_called_anytime( + 'POST', '/servers/1234/action', + {'createImage': {'name': 'mysnapshot', 'metadata': {}}}, + ) + self.assertIn('My Server Backup', output) + self.assertIn('SAVING', output) + def test_image_delete(self): self.run_command('image-delete 1') self.assert_called('DELETE', '/images/1') diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index 99efac424..9efc81a1c 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -1379,6 +1379,11 @@ def do_root_password(cs, args): @utils.arg('server', metavar='<server>', help='Name or ID of server.') @utils.arg('name', metavar='<name>', help='Name of snapshot.') +@utils.arg('--show', + dest='show', + action="store_true", + default=False, + help='Print image info.') @utils.arg('--poll', dest='poll', action="store_true", @@ -1408,6 +1413,9 @@ def do_image_create(cs, args): [None], status_field=task_state_field, show_progress=False, silent=True) + if args.show: + _print_image(cs.images.get(image_uuid)) + @utils.arg('server', metavar='<server>', help='Name or ID of server.') @utils.arg('name', metavar='<name>', help='Name of the backup image.') diff --git a/novaclient/v3/shell.py b/novaclient/v3/shell.py index a84cc039a..bfd81b1db 100644 --- a/novaclient/v3/shell.py +++ b/novaclient/v3/shell.py @@ -1241,6 +1241,11 @@ def do_root_password(cs, args): @utils.arg('server', metavar='<server>', help='Name or ID of server.') @utils.arg('name', metavar='<name>', help='Name of snapshot.') +@utils.arg('--show', + dest='show', + action="store_true", + default=False, + help='Print image info.') @utils.arg('--poll', dest='poll', action="store_true", @@ -1270,6 +1275,9 @@ def do_image_create(cs, args): [None], status_field=task_state_field, show_progress=False, silent=True) + if args.show: + _print_image(cs.images.get(image_uuid)) + @utils.arg('server', metavar='<server>', help='Name or ID of server.') @utils.arg('name', metavar='<name>', help='Name of the backup image.')