Add support for setting Image-property
OSC does not support to set volume's image property. This patch will provide support for adding image property to existing volume. Closes-Bug:#1554877 Implements: bp cinder-command-support Change-Id: I4ff5532c228f010789b81c7587dd4a2838a90f20
This commit is contained in:
parent
d88284c86d
commit
4d5c5d9dcb
@ -164,6 +164,7 @@ Set volume properties
|
||||
[--description <description>]
|
||||
[--size <size>]
|
||||
[--property <key=value> [...] ]
|
||||
[--image-property <key=value> [...] ]
|
||||
<volume>
|
||||
|
||||
.. option:: --name <name>
|
||||
@ -182,6 +183,13 @@ Set volume properties
|
||||
|
||||
Property to add or modify for this volume (repeat option to set multiple properties)
|
||||
|
||||
.. option:: --image-property <key=value>
|
||||
|
||||
To add or modify image properties for this volume.
|
||||
(repeat option to set multiple image properties)
|
||||
|
||||
*Volume version 2 only*
|
||||
|
||||
.. describe:: <volume>
|
||||
|
||||
Volume to modify (name or ID)
|
||||
|
@ -753,3 +753,33 @@ class TestVolumeShow(TestVolume):
|
||||
|
||||
self.assertEqual(volume_fakes.VOLUME_columns, columns)
|
||||
self.assertEqual(volume_fakes.VOLUME_data, data)
|
||||
|
||||
|
||||
class TestVolumeSet(TestVolume):
|
||||
|
||||
def setUp(self):
|
||||
super(TestVolumeSet, self).setUp()
|
||||
|
||||
self.new_volume = volume_fakes.FakeVolume.create_one_volume()
|
||||
self.volumes_mock.create.return_value = self.new_volume
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = volume.SetVolume(self.app, None)
|
||||
|
||||
def test_volume_set_image_property(self):
|
||||
arglist = [
|
||||
'--image-property', 'Alpha=a',
|
||||
'--image-property', 'Beta=b',
|
||||
self.new_volume.id,
|
||||
]
|
||||
verifylist = [
|
||||
('image_property', {'Alpha': 'a', 'Beta': 'b'}),
|
||||
('volume', self.new_volume.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# In base command class ShowOne in cliff, abstract method take_action()
|
||||
# returns nothing
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.volumes_mock.set_image_metadata.assert_called_with(
|
||||
self.volumes_mock.get().id, parsed_args.image_property)
|
||||
|
@ -345,6 +345,13 @@ class SetVolume(command.Command):
|
||||
help='Property to add or modify for this volume '
|
||||
'(repeat option to set multiple properties)',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--image-property',
|
||||
metavar='<key=value>',
|
||||
action=parseractions.KeyValueAction,
|
||||
help='To add or modify image properties for this volume '
|
||||
'(repeat option to set multiple image properties)',
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -365,6 +372,9 @@ class SetVolume(command.Command):
|
||||
|
||||
if parsed_args.property:
|
||||
volume_client.volumes.set_metadata(volume.id, parsed_args.property)
|
||||
if parsed_args.image_property:
|
||||
volume_client.volumes.set_image_metadata(
|
||||
volume.id, parsed_args.image_property)
|
||||
|
||||
kwargs = {}
|
||||
if parsed_args.name:
|
||||
@ -374,7 +384,8 @@ class SetVolume(command.Command):
|
||||
if kwargs:
|
||||
volume_client.volumes.update(volume.id, **kwargs)
|
||||
|
||||
if not kwargs and not parsed_args.property and not parsed_args.size:
|
||||
if (not kwargs and not parsed_args.property
|
||||
and not parsed_args.image_property and not parsed_args.size):
|
||||
self.app.log.error("No changes requested\n")
|
||||
|
||||
|
||||
|
14
releasenotes/notes/image-property_add-7f8479791eab45b7.yaml
Normal file
14
releasenotes/notes/image-property_add-7f8479791eab45b7.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Added support for setting volume image property.
|
||||
|
||||
Image properties are copied from image when volume is created.
|
||||
But since a volume is mutable, user sometime wants to update
|
||||
image properties for volume.
|
||||
|
||||
So, this fix enables user to update image properties of volume
|
||||
using below command:
|
||||
``volume set --image-property <key=value> <volume>``.
|
||||
|
||||
[Bug 'https://bugs.launchpad.net/python-openstackclient/+bug/1554877'_]
|
Loading…
Reference in New Issue
Block a user