Skip to content

Commit 161d37b

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add "--force" option to "backup create" command in volumev2"
2 parents 21ad61d + fc719f9 commit 161d37b

4 files changed

Lines changed: 25 additions & 3 deletions

File tree

doc/source/command-objects/backup.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Create new backup
1616
[--container <container>]
1717
[--name <name>]
1818
[--description <description>]
19+
[--force]
1920
<volume>
2021
2122
.. option:: --container <container>
@@ -30,6 +31,10 @@ Create new backup
3031

3132
Description of the backup
3233

34+
.. option:: --force
35+
36+
Allow to back up an in-use volume
37+
3338
.. _backup_create-backup:
3439
.. describe:: <volume>
3540

openstackclient/tests/volume/v2/test_backup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ def test_backup_create(self):
7272
"--name", self.new_backup.name,
7373
"--description", self.new_backup.description,
7474
"--container", self.new_backup.container,
75+
"--force",
7576
self.new_backup.volume_id,
7677
]
7778
verifylist = [
7879
("name", self.new_backup.name),
7980
("description", self.new_backup.description),
8081
("container", self.new_backup.container),
82+
("force", True),
8183
("volume", self.new_backup.volume_id),
8284
]
8385
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -88,7 +90,8 @@ def test_backup_create(self):
8890
self.new_backup.volume_id,
8991
container=self.new_backup.container,
9092
name=self.new_backup.name,
91-
description=self.new_backup.description
93+
description=self.new_backup.description,
94+
force=True,
9295
)
9396
self.assertEqual(self.columns, columns)
9497
self.assertEqual(self.data, data)
@@ -112,7 +115,8 @@ def test_backup_create_without_name(self):
112115
self.new_backup.volume_id,
113116
container=self.new_backup.container,
114117
name=None,
115-
description=self.new_backup.description
118+
description=self.new_backup.description,
119+
force=False,
116120
)
117121
self.assertEqual(self.columns, columns)
118122
self.assertEqual(self.data, data)

openstackclient/volume/v2/backup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def get_parser(self, prog_name):
4848
metavar="<container>",
4949
help=_("Optional backup container name")
5050
)
51+
parser.add_argument(
52+
'--force',
53+
action='store_true',
54+
default=False,
55+
help=_("Allow to back up an in-use volume")
56+
)
5157
return parser
5258

5359
def take_action(self, parsed_args):
@@ -58,7 +64,8 @@ def take_action(self, parsed_args):
5864
volume_id,
5965
container=parsed_args.container,
6066
name=parsed_args.name,
61-
description=parsed_args.description
67+
description=parsed_args.description,
68+
force=parsed_args.force,
6269
)
6370
backup._info.pop("links", None)
6471
return zip(*sorted(six.iteritems(backup._info)))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
features:
3+
- |
4+
Add ``--force`` option to ``backup create`` command to allow users to
5+
back up an in-use volume.
6+
[Bug `1596443 <https://bugs.launchpad.net/bugs/1596443>`_]

0 commit comments

Comments
 (0)