Expose flag for forcing use of import for images
openstacksdk added support for using image import as a fallback which is transparently supported here, but also provides an override flag to allow a user to force use of import. Expose that here. Depends-On: https://review.opendev.org/737608 Change-Id: Ied938a8f63f305305a20ace42e9f4c84b0a5c00e
This commit is contained in:
parent
8b7a2c8d59
commit
c04ec16cf7
@ -50,7 +50,7 @@ msgpack-python==0.4.0
|
|||||||
munch==2.1.0
|
munch==2.1.0
|
||||||
netaddr==0.7.18
|
netaddr==0.7.18
|
||||||
netifaces==0.10.4
|
netifaces==0.10.4
|
||||||
openstacksdk==0.44.0
|
openstacksdk==0.48.0
|
||||||
os-service-types==1.7.0
|
os-service-types==1.7.0
|
||||||
os-testr==1.0.0
|
os-testr==1.0.0
|
||||||
osc-lib==2.0.0
|
osc-lib==2.0.0
|
||||||
|
@ -324,6 +324,14 @@ class CreateImage(command.ShowOne):
|
|||||||
metavar="<project>",
|
metavar="<project>",
|
||||||
help=_("Set an alternate project on this image (name or ID)"),
|
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)
|
common.add_project_domain_option_to_parser(parser)
|
||||||
for deadopt in self.deadopts:
|
for deadopt in self.deadopts:
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -388,6 +396,9 @@ class CreateImage(command.ShowOne):
|
|||||||
parsed_args.project_domain,
|
parsed_args.project_domain,
|
||||||
).id
|
).id
|
||||||
|
|
||||||
|
if parsed_args.use_import:
|
||||||
|
kwargs['use_import'] = True
|
||||||
|
|
||||||
# open the file first to ensure any failures are handled before the
|
# 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)
|
# image is created. Get the file name (if it is file, and not stdin)
|
||||||
# for easier further handling.
|
# for easier further handling.
|
||||||
|
@ -271,6 +271,28 @@ class TestImageCreate(TestImage):
|
|||||||
exceptions.CommandError,
|
exceptions.CommandError,
|
||||||
self.cmd.take_action, parsed_args)
|
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):
|
class TestAddProjectToImage(TestImage):
|
||||||
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Added ``--import`` flag to ``openstack image create`` to allow
|
||||||
|
the user to force use of the image import codepath.
|
@ -5,7 +5,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
|||||||
six>=1.10.0 # MIT
|
six>=1.10.0 # MIT
|
||||||
|
|
||||||
cliff!=2.9.0,>=2.8.0 # Apache-2.0
|
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
|
osc-lib>=2.0.0 # Apache-2.0
|
||||||
oslo.i18n>=3.15.3 # Apache-2.0
|
oslo.i18n>=3.15.3 # Apache-2.0
|
||||||
oslo.utils>=3.33.0 # Apache-2.0
|
oslo.utils>=3.33.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user