Merge "Rename openstack volume delete --purge -> --cascade"
This commit is contained in:
@@ -655,7 +655,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
arglist = [self.volumes[0].id]
|
||||
verifylist = [
|
||||
("force", False),
|
||||
("purge", False),
|
||||
("cascade", False),
|
||||
("volumes", [self.volumes[0].id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -674,7 +674,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
arglist = [v.id for v in self.volumes]
|
||||
verifylist = [
|
||||
('force', False),
|
||||
('purge', False),
|
||||
('cascade', False),
|
||||
('volumes', arglist),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -701,7 +701,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
]
|
||||
verifylist = [
|
||||
('force', False),
|
||||
('purge', False),
|
||||
('cascade', False),
|
||||
('volumes', [self.volumes[0].id, 'unexist_volume']),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -732,7 +732,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
]
|
||||
verifylist = [
|
||||
('force', False),
|
||||
('purge', True),
|
||||
('cascade', True),
|
||||
('volumes', [self.volumes[0].id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -754,7 +754,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
]
|
||||
verifylist = [
|
||||
('force', True),
|
||||
('purge', False),
|
||||
('cascade', False),
|
||||
('volumes', [self.volumes[0].id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@@ -912,7 +912,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
arglist = [self.volumes[0].id]
|
||||
verifylist = [
|
||||
("force", False),
|
||||
("purge", False),
|
||||
("cascade", False),
|
||||
("volumes", [self.volumes[0].id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -931,7 +931,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
arglist = [v.id for v in self.volumes]
|
||||
verifylist = [
|
||||
('force', False),
|
||||
('purge', False),
|
||||
('cascade', False),
|
||||
('volumes', arglist),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -958,7 +958,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
]
|
||||
verifylist = [
|
||||
('force', False),
|
||||
('purge', False),
|
||||
('cascade', False),
|
||||
('volumes', [self.volumes[0].id, 'unexist_volume']),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -989,7 +989,29 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
]
|
||||
verifylist = [
|
||||
('force', False),
|
||||
('purge', True),
|
||||
('cascade', True),
|
||||
('volumes', [self.volumes[0].id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.assertIsNone(result)
|
||||
|
||||
self.volume_sdk_client.find_volume.assert_called_once_with(
|
||||
self.volumes[0].id, ignore_missing=False
|
||||
)
|
||||
self.volume_sdk_client.delete_volume.assert_called_once_with(
|
||||
self.volumes[0].id, cascade=True, force=False
|
||||
)
|
||||
|
||||
def test_volume_delete_with_cascade(self):
|
||||
arglist = [
|
||||
'--cascade',
|
||||
self.volumes[0].id,
|
||||
]
|
||||
verifylist = [
|
||||
('force', False),
|
||||
('cascade', True),
|
||||
('volumes', [self.volumes[0].id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -1011,7 +1033,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
]
|
||||
verifylist = [
|
||||
('force', True),
|
||||
('purge', False),
|
||||
('cascade', False),
|
||||
('volumes', [self.volumes[0].id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -1031,7 +1053,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
verifylist = [
|
||||
("remote", True),
|
||||
("force", False),
|
||||
("purge", False),
|
||||
("cascade", False),
|
||||
("volumes", [self.volumes[0].id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -1052,7 +1074,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
verifylist = [
|
||||
('remote', True),
|
||||
('force', False),
|
||||
('purge', False),
|
||||
('cascade', False),
|
||||
('volumes', arglist[1:]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -1077,7 +1099,6 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
verifylist = [
|
||||
('remote', True),
|
||||
('force', False),
|
||||
('purge', True),
|
||||
('volumes', [self.volumes[0].id]),
|
||||
]
|
||||
|
||||
@@ -1086,7 +1107,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
exceptions.CommandError, self.cmd.take_action, parsed_args
|
||||
)
|
||||
self.assertIn(
|
||||
"The --force and --purge options are not supported with the "
|
||||
"The --force and --cascade options are not supported with the "
|
||||
"--remote parameter.",
|
||||
str(exc),
|
||||
)
|
||||
@@ -1104,7 +1125,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
verifylist = [
|
||||
('remote', True),
|
||||
('force', True),
|
||||
('purge', False),
|
||||
('cascade', False),
|
||||
('volumes', [self.volumes[0].id]),
|
||||
]
|
||||
|
||||
@@ -1113,7 +1134,7 @@ class TestVolumeDelete(volume_fakes.TestVolume):
|
||||
exceptions.CommandError, self.cmd.take_action, parsed_args
|
||||
)
|
||||
self.assertIn(
|
||||
"The --force and --purge options are not supported with the "
|
||||
"The --force and --cascade options are not supported with the "
|
||||
"--remote parameter.",
|
||||
str(exc),
|
||||
)
|
||||
|
||||
@@ -390,12 +390,19 @@ class DeleteVolume(command.Command):
|
||||
),
|
||||
)
|
||||
group.add_argument(
|
||||
"--purge",
|
||||
"--cascade",
|
||||
action="store_true",
|
||||
help=_(
|
||||
"Remove any snapshots along with volume(s) (defaults to False)"
|
||||
),
|
||||
)
|
||||
group.add_argument(
|
||||
# now called "cascade", accept old arg for compatibility
|
||||
"--purge",
|
||||
action="store_true",
|
||||
help=argparse.SUPPRESS,
|
||||
dest='cascade',
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@@ -410,7 +417,7 @@ class DeleteVolume(command.Command):
|
||||
volume_client.delete_volume(
|
||||
volume_obj.id,
|
||||
force=parsed_args.force,
|
||||
cascade=parsed_args.purge,
|
||||
cascade=parsed_args.cascade,
|
||||
)
|
||||
except Exception as e:
|
||||
result += 1
|
||||
|
||||
@@ -515,12 +515,19 @@ class DeleteVolume(command.Command):
|
||||
),
|
||||
)
|
||||
group.add_argument(
|
||||
"--purge",
|
||||
"--cascade",
|
||||
action="store_true",
|
||||
help=_(
|
||||
"Remove any snapshots along with volume(s) (defaults to False)"
|
||||
),
|
||||
)
|
||||
group.add_argument(
|
||||
# now called "cascade", accept old arg for compatibility
|
||||
"--purge",
|
||||
action="store_true",
|
||||
help=argparse.SUPPRESS,
|
||||
dest='cascade',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--remote',
|
||||
action='store_true',
|
||||
@@ -532,9 +539,9 @@ class DeleteVolume(command.Command):
|
||||
volume_client = self.app.client_manager.sdk_connection.volume
|
||||
result = 0
|
||||
|
||||
if parsed_args.remote and (parsed_args.force or parsed_args.purge):
|
||||
if parsed_args.remote and (parsed_args.force or parsed_args.cascade):
|
||||
msg = _(
|
||||
"The --force and --purge options are not "
|
||||
"The --force and --cascade options are not "
|
||||
"supported with the --remote parameter."
|
||||
)
|
||||
raise exceptions.CommandError(msg)
|
||||
@@ -550,7 +557,7 @@ class DeleteVolume(command.Command):
|
||||
volume_client.delete_volume(
|
||||
volume_obj.id,
|
||||
force=parsed_args.force,
|
||||
cascade=parsed_args.purge,
|
||||
cascade=parsed_args.cascade,
|
||||
)
|
||||
except Exception as e:
|
||||
result += 1
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The ``--purge`` argument to the ``volume delete`` command has been renamed
|
||||
to ``--cascade`` to better match the Cinder API and the meaning of what
|
||||
this argument does. An alias is provided for backwards compatibility.
|
||||
Reference in New Issue
Block a user