Add support for deleting Image-property
OSC does not support to delete volume's image property. This patch will provide support for deleting image property to existing volume. Closes-Bug:#1554879 Change-Id: I9256913948fae9e9a03fed173b826dfa918f78e9 Implements: bp cinder-command-support
This commit is contained in:
parent
4d5c5d9dcb
commit
9bafea555d
doc/source/command-objects
openstackclient
releasenotes/notes
@ -219,12 +219,18 @@ Unset volume properties
|
|||||||
|
|
||||||
os volume unset
|
os volume unset
|
||||||
[--property <key>]
|
[--property <key>]
|
||||||
|
[--image-property <key>]
|
||||||
<volume>
|
<volume>
|
||||||
|
|
||||||
.. option:: --property <key>
|
.. option:: --property <key>
|
||||||
|
|
||||||
Property to remove from volume (repeat option to remove multiple properties)
|
Property to remove from volume (repeat option to remove multiple properties)
|
||||||
|
|
||||||
|
.. option:: --image-property <key>
|
||||||
|
|
||||||
|
To remove image properties from volume
|
||||||
|
(repeat option to remove multiple image properties)
|
||||||
|
|
||||||
.. describe:: <volume>
|
.. describe:: <volume>
|
||||||
|
|
||||||
Volume to modify (name or ID)
|
Volume to modify (name or ID)
|
||||||
|
@ -783,3 +783,56 @@ class TestVolumeSet(TestVolume):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.volumes_mock.set_image_metadata.assert_called_with(
|
self.volumes_mock.set_image_metadata.assert_called_with(
|
||||||
self.volumes_mock.get().id, parsed_args.image_property)
|
self.volumes_mock.get().id, parsed_args.image_property)
|
||||||
|
|
||||||
|
|
||||||
|
class TestVolumeUnset(TestVolume):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestVolumeUnset, 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 set property
|
||||||
|
self.cmd_set = volume.SetVolume(self.app, None)
|
||||||
|
|
||||||
|
# Get the command object to unset property
|
||||||
|
self.cmd_unset = volume.UnsetVolume(self.app, None)
|
||||||
|
|
||||||
|
def test_volume_unset_image_property(self):
|
||||||
|
|
||||||
|
# Arguments for setting image properties
|
||||||
|
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_set, arglist, verifylist)
|
||||||
|
|
||||||
|
# In base command class ShowOne in cliff, abstract method take_action()
|
||||||
|
# returns nothing
|
||||||
|
self.cmd_set.take_action(parsed_args)
|
||||||
|
|
||||||
|
# Arguments for unsetting image properties
|
||||||
|
arglist_unset = [
|
||||||
|
'--image-property', 'Alpha',
|
||||||
|
self.new_volume.id,
|
||||||
|
]
|
||||||
|
verifylist_unset = [
|
||||||
|
('image_property', ['Alpha']),
|
||||||
|
('volume', self.new_volume.id),
|
||||||
|
]
|
||||||
|
parsed_args_unset = self.check_parser(self.cmd_unset,
|
||||||
|
arglist_unset,
|
||||||
|
verifylist_unset)
|
||||||
|
|
||||||
|
# In base command class ShowOne in cliff, abstract method take_action()
|
||||||
|
# returns nothing
|
||||||
|
self.cmd_unset.take_action(parsed_args_unset)
|
||||||
|
|
||||||
|
self.volumes_mock.delete_image_metadata.assert_called_with(
|
||||||
|
self.volumes_mock.get().id, parsed_args_unset.image_property)
|
||||||
|
@ -433,12 +433,17 @@ class UnsetVolume(command.Command):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--property',
|
'--property',
|
||||||
metavar='<key>',
|
metavar='<key>',
|
||||||
required=True,
|
|
||||||
action='append',
|
action='append',
|
||||||
default=[],
|
|
||||||
help='Property to remove from volume '
|
help='Property to remove from volume '
|
||||||
'(repeat option to remove multiple properties)',
|
'(repeat option to remove multiple properties)',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--image-property',
|
||||||
|
metavar='<key>',
|
||||||
|
action='append',
|
||||||
|
help='To remove image properties from volume '
|
||||||
|
'(repeat option to remove multiple image properties)',
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -446,5 +451,12 @@ class UnsetVolume(command.Command):
|
|||||||
volume = utils.find_resource(
|
volume = utils.find_resource(
|
||||||
volume_client.volumes, parsed_args.volume)
|
volume_client.volumes, parsed_args.volume)
|
||||||
|
|
||||||
volume_client.volumes.delete_metadata(
|
if parsed_args.property:
|
||||||
volume.id, parsed_args.property)
|
volume_client.volumes.delete_metadata(
|
||||||
|
volume.id, parsed_args.property)
|
||||||
|
if parsed_args.image_property:
|
||||||
|
volume_client.volumes.delete_image_metadata(
|
||||||
|
volume.id, parsed_args.image_property)
|
||||||
|
|
||||||
|
if (not parsed_args.image_property and not parsed_args.property):
|
||||||
|
self.app.log.error("No changes requested\n")
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Added support for deleting volume image property.
|
||||||
|
|
||||||
|
Image properties are copied from image when volume is created.
|
||||||
|
But since a volume is mutable, user sometime wants to delete
|
||||||
|
image properties for volume.
|
||||||
|
|
||||||
|
So, this fix enables user to delete image properties of volume
|
||||||
|
using below command:
|
||||||
|
``volume unset [--image-property <key>] <volume>``.
|
||||||
|
|
||||||
|
[Bug 'https://bugs.launchpad.net/python-openstackclient/+bug/1554879'_]
|
Loading…
x
Reference in New Issue
Block a user