diff --git a/doc/source/command-objects/backup.rst b/doc/source/command-objects/backup.rst index 9d7fb95d68..abe1aa26f2 100644 --- a/doc/source/command-objects/backup.rst +++ b/doc/source/command-objects/backup.rst @@ -16,6 +16,7 @@ Create new backup [--container ] [--name ] [--description ] + [--force] .. option:: --container @@ -30,6 +31,10 @@ Create new backup Description of the backup +.. option:: --force + + Allow to back up an in-use volume + .. _backup_create-backup: .. describe:: diff --git a/openstackclient/tests/volume/v2/test_backup.py b/openstackclient/tests/volume/v2/test_backup.py index 8a151a9108..ba0f1c1811 100644 --- a/openstackclient/tests/volume/v2/test_backup.py +++ b/openstackclient/tests/volume/v2/test_backup.py @@ -72,12 +72,14 @@ class TestBackupCreate(TestBackup): "--name", self.new_backup.name, "--description", self.new_backup.description, "--container", self.new_backup.container, + "--force", self.new_backup.volume_id, ] verifylist = [ ("name", self.new_backup.name), ("description", self.new_backup.description), ("container", self.new_backup.container), + ("force", True), ("volume", self.new_backup.volume_id), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -88,7 +90,8 @@ class TestBackupCreate(TestBackup): self.new_backup.volume_id, container=self.new_backup.container, name=self.new_backup.name, - description=self.new_backup.description + description=self.new_backup.description, + force=True, ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, data) @@ -112,7 +115,8 @@ class TestBackupCreate(TestBackup): self.new_backup.volume_id, container=self.new_backup.container, name=None, - description=self.new_backup.description + description=self.new_backup.description, + force=False, ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, data) diff --git a/openstackclient/volume/v2/backup.py b/openstackclient/volume/v2/backup.py index 6a44e30c57..e83fb136f6 100644 --- a/openstackclient/volume/v2/backup.py +++ b/openstackclient/volume/v2/backup.py @@ -48,6 +48,12 @@ class CreateBackup(command.ShowOne): metavar="", help=_("Optional backup container name") ) + parser.add_argument( + '--force', + action='store_true', + default=False, + help=_("Allow to back up an in-use volume") + ) return parser def take_action(self, parsed_args): @@ -58,7 +64,8 @@ class CreateBackup(command.ShowOne): volume_id, container=parsed_args.container, name=parsed_args.name, - description=parsed_args.description + description=parsed_args.description, + force=parsed_args.force, ) backup._info.pop("links", None) return zip(*sorted(six.iteritems(backup._info))) diff --git a/releasenotes/notes/bug-1596443-9e2af267e91d1643.yaml b/releasenotes/notes/bug-1596443-9e2af267e91d1643.yaml new file mode 100644 index 0000000000..cf4e85c0ff --- /dev/null +++ b/releasenotes/notes/bug-1596443-9e2af267e91d1643.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Add ``--force`` option to ``backup create`` command to allow users to + back up an in-use volume. + [Bug `1596443 `_]