diff options
| author | Zuul <zuul@review.opendev.org> | 2020-07-08 17:01:22 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2020-07-08 17:01:22 +0000 |
| commit | 9fb68eca44612847a2eba4f1063579b2f921b0bb (patch) | |
| tree | 59a4daf06b2eda999f5732af5b4860df868c5dae | |
| parent | 4b5053ac8948782141fb3b2fb56977caef93c884 (diff) | |
| parent | c04ec16cf7ad2dbe7bf8edf5f6e7840c54b0efa3 (diff) | |
| download | python-openstackclient-9fb68eca44612847a2eba4f1063579b2f921b0bb.tar.gz | |
Merge "Expose flag for forcing use of import for images"
| -rw-r--r-- | lower-constraints.txt | 2 | ||||
| -rw-r--r-- | openstackclient/image/v2/image.py | 11 | ||||
| -rw-r--r-- | openstackclient/tests/unit/image/v2/test_image.py | 22 | ||||
| -rw-r--r-- | releasenotes/notes/add-image-import-flag-899869dc5a92aea7.yaml | 5 | ||||
| -rw-r--r-- | requirements.txt | 2 |
5 files changed, 40 insertions, 2 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt index fac497a3..0a453dae 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -49,7 +49,7 @@ msgpack-python==0.4.0 munch==2.1.0 netaddr==0.7.18 netifaces==0.10.4 -openstacksdk==0.44.0 +openstacksdk==0.48.0 os-service-types==1.7.0 os-testr==1.0.0 osc-lib==2.0.0 diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py index 53ce560d..b068ddaf 100644 --- a/openstackclient/image/v2/image.py +++ b/openstackclient/image/v2/image.py @@ -324,6 +324,14 @@ class CreateImage(command.ShowOne): metavar="<project>", help=_("Set an alternate project on this image (name or ID)"), ) + parser.add_argument( + "--import", + dest="use_import", + action="store_true", + help=_( + "Force the use of glance image import instead of" + " direct upload") + ) common.add_project_domain_option_to_parser(parser) for deadopt in self.deadopts: parser.add_argument( @@ -388,6 +396,9 @@ class CreateImage(command.ShowOne): parsed_args.project_domain, ).id + if parsed_args.use_import: + kwargs['use_import'] = True + # open the file first to ensure any failures are handled before the # image is created. Get the file name (if it is file, and not stdin) # for easier further handling. diff --git a/openstackclient/tests/unit/image/v2/test_image.py b/openstackclient/tests/unit/image/v2/test_image.py index a021cfc7..310f6b76 100644 --- a/openstackclient/tests/unit/image/v2/test_image.py +++ b/openstackclient/tests/unit/image/v2/test_image.py @@ -271,6 +271,28 @@ class TestImageCreate(TestImage): exceptions.CommandError, self.cmd.take_action, parsed_args) + @mock.patch('sys.stdin', side_effect=[None]) + def test_image_create_import(self, raw_input): + + arglist = [ + '--import', + self.new_image.name, + ] + verifylist = [ + ('name', self.new_image.name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + # ImageManager.create(name=, **) + self.client.create_image.assert_called_with( + name=self.new_image.name, + container_format=image.DEFAULT_CONTAINER_FORMAT, + disk_format=image.DEFAULT_DISK_FORMAT, + use_import=True + ) + class TestAddProjectToImage(TestImage): diff --git a/releasenotes/notes/add-image-import-flag-899869dc5a92aea7.yaml b/releasenotes/notes/add-image-import-flag-899869dc5a92aea7.yaml new file mode 100644 index 00000000..fbd29bcd --- /dev/null +++ b/releasenotes/notes/add-image-import-flag-899869dc5a92aea7.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added ``--import`` flag to ``openstack image create`` to allow + the user to force use of the image import codepath. diff --git a/requirements.txt b/requirements.txt index b1421a83..2b7976e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 six>=1.10.0 # MIT cliff!=2.9.0,>=2.8.0 # Apache-2.0 -openstacksdk>=0.44.0 # Apache-2.0 +openstacksdk>=0.48.0 # Apache-2.0 osc-lib>=2.0.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 |
