From 52b86348a1dd76fbd6db051f2fcdde73acdfdf49 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 8 Apr 2024 12:36:25 +0100 Subject: [PATCH] volume: Allow passing a volume type object to retype_volume Small quality of life improvement. Change-Id: Ief3256cee7110a1e1920cd5e033586c1166f280e Signed-off-by: Stephen Finucane --- openstack/block_storage/v2/_proxy.py | 7 +++++-- openstack/block_storage/v3/_proxy.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/openstack/block_storage/v2/_proxy.py b/openstack/block_storage/v2/_proxy.py index 4557df44f..6ac642480 100644 --- a/openstack/block_storage/v2/_proxy.py +++ b/openstack/block_storage/v2/_proxy.py @@ -361,7 +361,9 @@ class Proxy(_base_proxy.BaseBlockStorageProxy): :param volume: The value can be either the ID of a volume or a :class:`~openstack.block_storage.v2.volume.Volume` instance. - :param str new_type: The new volume type that volume is changed with. + :param new_type: The new volume type that volume is changed with. + The value can be either the ID of the volume type or a + :class:`~openstack.block_storage.v2.type.Type` instance. :param str migration_policy: Specify if the volume should be migrated when it is re-typed. Possible values are on-demand or never. Default: never. @@ -369,7 +371,8 @@ class Proxy(_base_proxy.BaseBlockStorageProxy): :returns: None """ volume = self._get_resource(_volume.Volume, volume) - volume.retype(self, new_type, migration_policy) + type_id = resource.Resource._get_id(new_type) + volume.retype(self, type_id, migration_policy) def set_volume_bootable_status(self, volume, bootable): """Set bootable status of the volume. diff --git a/openstack/block_storage/v3/_proxy.py b/openstack/block_storage/v3/_proxy.py index d127651bb..cf17a8f60 100644 --- a/openstack/block_storage/v3/_proxy.py +++ b/openstack/block_storage/v3/_proxy.py @@ -747,7 +747,9 @@ class Proxy(_base_proxy.BaseBlockStorageProxy): :param volume: The value can be either the ID of a volume or a :class:`~openstack.block_storage.v3.volume.Volume` instance. - :param str new_type: The new volume type that volume is changed with. + :param new_type: The new volume type that volume is changed with. + The value can be either the ID of the volume type or a + :class:`~openstack.block_storage.v3.type.Type` instance. :param str migration_policy: Specify if the volume should be migrated when it is re-typed. Possible values are on-demand or never. Default: never. @@ -755,7 +757,8 @@ class Proxy(_base_proxy.BaseBlockStorageProxy): :returns: None """ volume = self._get_resource(_volume.Volume, volume) - volume.retype(self, new_type, migration_policy) + type_id = resource.Resource._get_id(new_type) + volume.retype(self, type_id, migration_policy) def set_volume_bootable_status(self, volume, bootable): """Set bootable status of the volume.