Skip to content

Commit e0b63e6

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add "--property" option to "snapshot create" command in volumev2"
2 parents f1a27a7 + 3222ffc commit e0b63e6

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

doc/source/command-objects/snapshot.rst

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

3132
Create a snapshot attached to an instance. Default is False
3233

34+
.. option:: --property <key=value>
35+
36+
Set a property to this snapshot (repeat option to set multiple properties)
37+
38+
*Volume version 2 only*
39+
3340
.. _snapshot_create-snapshot:
3441
.. describe:: <volume>
3542

openstackclient/tests/volume/v2/test_snapshot.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ def test_snapshot_create(self):
7070
"--name", self.new_snapshot.name,
7171
"--description", self.new_snapshot.description,
7272
"--force",
73+
'--property', 'Alpha=a',
74+
'--property', 'Beta=b',
7375
self.new_snapshot.volume_id,
7476
]
7577
verifylist = [
7678
("name", self.new_snapshot.name),
7779
("description", self.new_snapshot.description),
7880
("force", True),
81+
('property', {'Alpha': 'a', 'Beta': 'b'}),
7982
("volume", self.new_snapshot.volume_id),
8083
]
8184
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -86,7 +89,8 @@ def test_snapshot_create(self):
8689
self.new_snapshot.volume_id,
8790
force=True,
8891
name=self.new_snapshot.name,
89-
description=self.new_snapshot.description
92+
description=self.new_snapshot.description,
93+
metadata={'Alpha': 'a', 'Beta': 'b'},
9094
)
9195
self.assertEqual(self.columns, columns)
9296
self.assertEqual(self.data, data)
@@ -110,7 +114,8 @@ def test_snapshot_create_without_name(self):
110114
self.new_snapshot.volume_id,
111115
force=True,
112116
name=None,
113-
description=self.new_snapshot.description
117+
description=self.new_snapshot.description,
118+
metadata=None,
114119
)
115120
self.assertEqual(self.columns, columns)
116121
self.assertEqual(self.data, data)

openstackclient/volume/v2/snapshot.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ def get_parser(self, prog_name):
5151
help=_("Create a snapshot attached to an instance. "
5252
"Default is False")
5353
)
54+
parser.add_argument(
55+
"--property",
56+
metavar="<key=value>",
57+
action=parseractions.KeyValueAction,
58+
help=_("Set a property to this snapshot "
59+
"(repeat option to set multiple properties)"),
60+
)
5461
return parser
5562

5663
def take_action(self, parsed_args):
@@ -61,7 +68,8 @@ def take_action(self, parsed_args):
6168
volume_id,
6269
force=parsed_args.force,
6370
name=parsed_args.name,
64-
description=parsed_args.description
71+
description=parsed_args.description,
72+
metadata=parsed_args.property,
6573
)
6674
snapshot._info.update(
6775
{'properties': utils.format_dict(snapshot._info.pop('metadata'))}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- Add ``--property`` option to ``snapshot create`` command.
4+
[Bug `1597192 <https://bugs.launchpad.net/bugs/1597192>`_]

0 commit comments

Comments
 (0)