diff options
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/image/v1/image.py | 6 | ||||
| -rw-r--r-- | openstackclient/image/v2/image.py | 6 | ||||
| -rw-r--r-- | openstackclient/tests/unit/image/v2/test_image.py | 3 |
3 files changed, 12 insertions, 3 deletions
diff --git a/openstackclient/image/v1/image.py b/openstackclient/image/v1/image.py index cf1d6817..64aa3fcd 100644 --- a/openstackclient/image/v1/image.py +++ b/openstackclient/image/v1/image.py @@ -478,7 +478,11 @@ class SaveImage(command.Command): image_client = self.app.client_manager.image image = image_client.find_image(parsed_args.image) - image_client.download_image(image.id, output=parsed_args.file) + output_file = parsed_args.file + if output_file is None: + output_file = getattr(sys.stdout, "buffer", sys.stdout) + + image_client.download_image(image.id, stream=True, output=output_file) class SetImage(command.Command): diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py index 4f3e9d0b..58d92f51 100644 --- a/openstackclient/image/v2/image.py +++ b/openstackclient/image/v2/image.py @@ -803,7 +803,11 @@ class SaveImage(command.Command): image_client = self.app.client_manager.image image = image_client.find_image(parsed_args.image) - image_client.download_image(image.id, output=parsed_args.file) + output_file = parsed_args.file + if output_file is None: + output_file = getattr(sys.stdout, "buffer", sys.stdout) + + image_client.download_image(image.id, stream=True, output=output_file) class SetImage(command.Command): diff --git a/openstackclient/tests/unit/image/v2/test_image.py b/openstackclient/tests/unit/image/v2/test_image.py index b094817e..80e60ee8 100644 --- a/openstackclient/tests/unit/image/v2/test_image.py +++ b/openstackclient/tests/unit/image/v2/test_image.py @@ -1618,7 +1618,7 @@ class TestImageSave(TestImage): verifylist = [ ('file', '/path/to/file'), - ('image', self.image.id) + ('image', self.image.id), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -1626,6 +1626,7 @@ class TestImageSave(TestImage): self.client.download_image.assert_called_once_with( self.image.id, + stream=True, output='/path/to/file') |
