commit ac4bdb4bca02104d82553fc9220ec9ee311c7d8b Author: Mark Chappell Date: Thu Oct 8 09:34:56 2020 +0200 Add support for updating cinder (v3) volume types https://docs.openstack.org/api-ref/block-storage/v3/index.html?expanded=update-a-volume-type-detail#update-a-volume-type v3 volume types permit updates. Change-Id: I777687e8e3e310ad0f845799b595c12fbbf250c5 diff --git a/openstack/block_storage/v3/_proxy.py b/openstack/block_storage/v3/_proxy.py index d0f07f0..6314329 100644 --- a/openstack/block_storage/v3/_proxy.py +++ b/openstack/block_storage/v3/_proxy.py @@ -162,6 +162,19 @@ class Proxy(_base_proxy.BaseBlockStorageProxy): """ self._delete(_type.Type, type, ignore_missing=ignore_missing) + def update_type(self, type, **attrs): + """Update a type + + :param type: The value can be either the ID of a type or a + :class:`~openstack.volume.v3.type.Type` instance. + :param dict attrs: The attributes to update on the type + represented by ``value``. + + :returns: The updated type + :rtype: :class:`~openstack.volume.v3.type.Type` + """ + return self._update(_type.Type, type, **attrs) + def get_volume(self, volume): """Get a single volume diff --git a/openstack/block_storage/v3/type.py b/openstack/block_storage/v3/type.py index 7e3c81a..f68c9ea 100644 --- a/openstack/block_storage/v3/type.py +++ b/openstack/block_storage/v3/type.py @@ -23,6 +23,7 @@ class Type(resource.Resource): allow_create = True allow_delete = True allow_list = True + allow_commit = True _query_mapping = resource.QueryParameters("is_public") diff --git a/openstack/tests/unit/block_storage/v3/test_proxy.py b/openstack/tests/unit/block_storage/v3/test_proxy.py index 43b6c91..c3e9cbc 100644 --- a/openstack/tests/unit/block_storage/v3/test_proxy.py +++ b/openstack/tests/unit/block_storage/v3/test_proxy.py @@ -72,6 +72,9 @@ class TestVolumeProxy(test_proxy_base.TestProxyBase): def test_type_delete_ignore(self): self.verify_delete(self.proxy.delete_type, type.Type, True) + def test_type_update(self): + self.verify_update(self.proxy.update_type, type.Type) + def test_volume_get(self): self.verify_get(self.proxy.get_volume, volume.Volume) diff --git a/openstack/tests/unit/block_storage/v3/test_type.py b/openstack/tests/unit/block_storage/v3/test_type.py index 5bdcff1..01320a3 100644 --- a/openstack/tests/unit/block_storage/v3/test_type.py +++ b/openstack/tests/unit/block_storage/v3/test_type.py @@ -35,7 +35,7 @@ class TestType(base.TestCase): self.assertTrue(sot.allow_fetch) self.assertTrue(sot.allow_delete) self.assertTrue(sot.allow_list) - self.assertFalse(sot.allow_commit) + self.assertTrue(sot.allow_commit) def test_new(self): sot = type.Type.new(id=FAKE_ID)