Merge "Fix image import --disallow-failure flag"

This commit is contained in:
Zuul 2025-03-19 13:06:38 +00:00 committed by Gerrit Code Review
commit 1763c11963
2 changed files with 36 additions and 3 deletions
openstackclient
image/v2
tests/unit/image/v2

@ -1689,7 +1689,8 @@ class ImportImage(command.ShowOne):
"'copy-image' import method)"
),
)
parser.add_argument(
allow_failure_group = parser.add_mutually_exclusive_group()
allow_failure_group.add_argument(
'--allow-failure',
action='store_true',
dest='allow_failure',
@ -1700,9 +1701,9 @@ class ImportImage(command.ShowOne):
'Only usable with --stores or --all-stores'
),
)
parser.add_argument(
allow_failure_group.add_argument(
'--disallow-failure',
action='store_true',
action='store_false',
dest='allow_failure',
default=True,
help=_(

@ -2092,6 +2092,38 @@ class TestImageImport(TestImage):
all_stores_must_succeed=False,
)
def test_import_image__copy_image_disallow_failure(self):
self.image.status = 'active'
arglist = [
self.image.name,
'--method',
'copy-image',
'--store',
'fast',
'--disallow-failure',
]
verifylist = [
('image', self.image.name),
('import_method', 'copy-image'),
('stores', ['fast']),
('allow_failure', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.image_client.import_image.assert_called_once_with(
self.image,
method='copy-image',
uri=None,
remote_region=None,
remote_image_id=None,
remote_service_interface=None,
stores=['fast'],
all_stores=None,
all_stores_must_succeed=True,
)
def test_import_image__glance_download(self):
arglist = [
self.image.name,