summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/tests/volume/v2/test_snapshot.py9
-rw-r--r--openstackclient/volume/v2/snapshot.py10
2 files changed, 16 insertions, 3 deletions
diff --git a/openstackclient/tests/volume/v2/test_snapshot.py b/openstackclient/tests/volume/v2/test_snapshot.py
index ef199cbc..2e9bcc82 100644
--- a/openstackclient/tests/volume/v2/test_snapshot.py
+++ b/openstackclient/tests/volume/v2/test_snapshot.py
@@ -70,12 +70,15 @@ class TestSnapshotCreate(TestSnapshot):
"--name", self.new_snapshot.name,
"--description", self.new_snapshot.description,
"--force",
+ '--property', 'Alpha=a',
+ '--property', 'Beta=b',
self.new_snapshot.volume_id,
]
verifylist = [
("name", self.new_snapshot.name),
("description", self.new_snapshot.description),
("force", True),
+ ('property', {'Alpha': 'a', 'Beta': 'b'}),
("volume", self.new_snapshot.volume_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -86,7 +89,8 @@ class TestSnapshotCreate(TestSnapshot):
self.new_snapshot.volume_id,
force=True,
name=self.new_snapshot.name,
- description=self.new_snapshot.description
+ description=self.new_snapshot.description,
+ metadata={'Alpha': 'a', 'Beta': 'b'},
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
@@ -110,7 +114,8 @@ class TestSnapshotCreate(TestSnapshot):
self.new_snapshot.volume_id,
force=True,
name=None,
- description=self.new_snapshot.description
+ description=self.new_snapshot.description,
+ metadata=None,
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
diff --git a/openstackclient/volume/v2/snapshot.py b/openstackclient/volume/v2/snapshot.py
index 5aba04ae..5e6949d4 100644
--- a/openstackclient/volume/v2/snapshot.py
+++ b/openstackclient/volume/v2/snapshot.py
@@ -51,6 +51,13 @@ class CreateSnapshot(command.ShowOne):
help=_("Create a snapshot attached to an instance. "
"Default is False")
)
+ parser.add_argument(
+ "--property",
+ metavar="<key=value>",
+ action=parseractions.KeyValueAction,
+ help=_("Set a property to this snapshot "
+ "(repeat option to set multiple properties)"),
+ )
return parser
def take_action(self, parsed_args):
@@ -61,7 +68,8 @@ class CreateSnapshot(command.ShowOne):
volume_id,
force=parsed_args.force,
name=parsed_args.name,
- description=parsed_args.description
+ description=parsed_args.description,
+ metadata=parsed_args.property,
)
snapshot._info.update(
{'properties': utils.format_dict(snapshot._info.pop('metadata'))}