diff --git a/doc/source/user/proxies/shared_file_system.rst b/doc/source/user/proxies/shared_file_system.rst index 1b28ad124..df02c4b74 100644 --- a/doc/source/user/proxies/shared_file_system.rst +++ b/doc/source/user/proxies/shared_file_system.rst @@ -55,3 +55,14 @@ File Systems service. .. autoclass:: openstack.shared_file_system.v2._proxy.Proxy :noindex: :members: user_messages, get_user_message, delete_user_message + + +Shared File System Limits +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Get absolute limits of resources supported by the Shared File Systems +service. + +.. autoclass:: openstack.shared_file_system.v2._proxy.Proxy + :noindex: + :members: limits diff --git a/doc/source/user/resources/shared_file_system/index.rst b/doc/source/user/resources/shared_file_system/index.rst index 37f31da0b..459eb403a 100644 --- a/doc/source/user/resources/shared_file_system/index.rst +++ b/doc/source/user/resources/shared_file_system/index.rst @@ -6,5 +6,6 @@ Shared File System service resources v2/availability_zone v2/storage_pool + v2/limit v2/share v2/user_message diff --git a/doc/source/user/resources/shared_file_system/v2/limit.rst b/doc/source/user/resources/shared_file_system/v2/limit.rst new file mode 100644 index 000000000..33342c125 --- /dev/null +++ b/doc/source/user/resources/shared_file_system/v2/limit.rst @@ -0,0 +1,13 @@ +openstack.shared_file_system.v2.limit +===================================== + +.. automodule:: openstack.shared_file_system.v2.limit + +The Limit Class +--------------- + +The ``Limit`` class inherits from +:class:`~openstack.resource.Resource`. + +.. autoclass:: openstack.shared_file_system.v2.limit.Limit + :members: diff --git a/openstack/shared_file_system/v2/_proxy.py b/openstack/shared_file_system/v2/_proxy.py index 5b88e7516..2d4c32f60 100644 --- a/openstack/shared_file_system/v2/_proxy.py +++ b/openstack/shared_file_system/v2/_proxy.py @@ -20,6 +20,7 @@ from openstack.shared_file_system.v2 import ( from openstack.shared_file_system.v2 import ( user_message as _user_message ) +from openstack.shared_file_system.v2 import limit as _limit from openstack.shared_file_system.v2 import share as _share @@ -224,3 +225,16 @@ class Proxy(proxy.Proxy): return self._delete( _user_message.UserMessage, message_id, ignore_missing=ignore_missing) + + def limits(self, **query): + """Lists all share limits. + + :param kwargs query: Optional query parameters to be sent to limit + the share limits being returned. + + :returns: A generator of manila share limits resources + :rtype: :class:`~openstack.shared_file_system.v2. + limit.Limit` + """ + return self._list( + _limit.Limit, **query) diff --git a/openstack/shared_file_system/v2/limit.py b/openstack/shared_file_system/v2/limit.py new file mode 100644 index 000000000..ef95ad1b2 --- /dev/null +++ b/openstack/shared_file_system/v2/limit.py @@ -0,0 +1,75 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from openstack import resource + + +class Limit(resource.Resource): + resources_key = "limits" + base_path = "/limits" + + # capabilities + allow_create = False + allow_fetch = False + allow_commit = False + allow_delete = False + allow_list = True + allow_head = False + + #: Properties + #: The maximum number of replica gigabytes that are allowed + #: in a project. + maxTotalReplicaGigabytes = resource.Body( + "maxTotalReplicaGigabytes", type=int) + #: The total maximum number of shares that are allowed in a project. + maxTotalShares = resource.Body("maxTotalShares", type=int) + #: The total maximum number of share gigabytes that are allowed in a + #: project. + maxTotalShareGigabytes = resource.Body( + "maxTotalShareGigabytes", type=int) + #: The total maximum number of share-networks that are allowed in a + #: project. + maxTotalShareNetworks = resource.Body( + "maxTotalShareNetworks", type=int) + #: The total maximum number of share snapshots that are allowed in a + #: project. + maxTotalShareSnapshots = resource.Body( + "maxTotalShareSnapshots", type=int) + #: The maximum number of share replicas that is allowed. + maxTotalShareReplicas = resource.Body( + "maxTotalShareReplicas", type=int) + #: The total maximum number of snapshot gigabytes that are allowed + #: in a project. + maxTotalSnapshotGigabytes = resource.Body( + "maxTotalSnapshotGigabytes", type=int) + #: The total number of replica gigabytes used in a project by + #: share replicas. + totalReplicaGigabytesUsed = resource.Body( + "totalReplicaGigabytesUsed", type=int) + #: The total number of gigabytes used in a project by shares. + totalShareGigabytesUsed = resource.Body( + "totalShareGigabytesUsed", type=int) + #: The total number of created shares in a project. + totalSharesUsed = resource.Body( + "totalSharesUsed", type=int) + #: The total number of created share-networks in a project. + totalShareNetworksUsed = resource.Body( + "totalShareNetworksUsed", type=int) + #: The total number of created share snapshots in a project. + totalShareSnapshotsUsed = resource.Body( + "totalShareSnapshotsUsed", type=int) + #: The total number of gigabytes used in a project by snapshots. + totalSnapshotGigabytesUsed = resource.Body( + "totalSnapshotGigabytesUsed", type=int) + #: The total number of created share replicas in a project. + totalShareReplicasUsed = resource.Body( + "totalShareReplicasUsed", type=int) diff --git a/openstack/tests/functional/shared_file_system/test_limit.py b/openstack/tests/functional/shared_file_system/test_limit.py new file mode 100644 index 000000000..47cee5257 --- /dev/null +++ b/openstack/tests/functional/shared_file_system/test_limit.py @@ -0,0 +1,36 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from openstack.tests.functional.shared_file_system import base + + +class LimitTest(base.BaseSharedFileSystemTest): + + def test_limits(self): + limits = self.user_cloud.shared_file_system.limits() + self.assertGreater(len(list(limits)), 0) + for limit in limits: + for attribute in ("maxTotalReplicaGigabytes", + "maxTotalShares", + "maxTotalShareGigabytes", + "maxTotalShareNetworks", + "maxTotalShareSnapshots", + "maxTotalShareReplicas", + "maxTotalSnapshotGigabytes", + "totalReplicaGigabytesUsed", + "totalShareGigabytesUsed", + "totalSharesUsed", + "totalShareNetworksUsed", + "totalShareSnapshotsUsed", + "totalSnapshotGigabytesUsed", + "totalShareReplicasUsed"): + self.assertTrue(hasattr(limit, attribute)) diff --git a/openstack/tests/unit/identity/v3/test_limit.py b/openstack/tests/unit/identity/v3/test_limit.py index 9eac13ce2..6d2bcf413 100644 --- a/openstack/tests/unit/identity/v3/test_limit.py +++ b/openstack/tests/unit/identity/v3/test_limit.py @@ -29,7 +29,6 @@ class TestLimit(base.TestCase): def test_basic(self): sot = limit.Limit() - self.assertEqual('limit', sot.resource_key) self.assertEqual('limits', sot.resources_key) self.assertEqual('/limits', sot.base_path) self.assertTrue(sot.allow_create) diff --git a/openstack/tests/unit/shared_file_system/v2/test_limit.py b/openstack/tests/unit/shared_file_system/v2/test_limit.py new file mode 100644 index 000000000..e0d2c0b75 --- /dev/null +++ b/openstack/tests/unit/shared_file_system/v2/test_limit.py @@ -0,0 +1,76 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from openstack.shared_file_system.v2 import limit +from openstack.tests.unit import base + +EXAMPLE = { + "totalShareNetworksUsed": 0, + "maxTotalShareGigabytes": 1000, + "maxTotalShareNetworks": 10, + "totalSharesUsed": 0, + "totalShareGigabytesUsed": 0, + "totalShareSnapshotsUsed": 0, + "maxTotalShares": 50, + "totalSnapshotGigabytesUsed": 0, + "maxTotalSnapshotGigabytes": 1000, + "maxTotalShareSnapshots": 50, + "maxTotalShareReplicas": 100, + "maxTotalReplicaGigabytes": 1000, + "totalShareReplicasUsed": 0, + "totalReplicaGigabytesUsed": 0 +} + + +class TestLimit(base.TestCase): + + def test_basic(self): + limits = limit.Limit() + self.assertEqual('limits', limits.resources_key) + self.assertEqual('/limits', limits.base_path) + self.assertTrue(limits.allow_list) + self.assertFalse(limits.allow_fetch) + self.assertFalse(limits.allow_create) + self.assertFalse(limits.allow_commit) + self.assertFalse(limits.allow_delete) + self.assertFalse(limits.allow_head) + + def test_make_limits(self): + limits = limit.Limit(**EXAMPLE) + self.assertEqual(EXAMPLE['totalShareNetworksUsed'], + limits.totalShareNetworksUsed) + self.assertEqual(EXAMPLE['maxTotalShareGigabytes'], + limits.maxTotalShareGigabytes) + self.assertEqual(EXAMPLE['maxTotalShareNetworks'], + limits.maxTotalShareNetworks) + self.assertEqual(EXAMPLE['totalSharesUsed'], + limits.totalSharesUsed) + self.assertEqual(EXAMPLE['totalShareGigabytesUsed'], + limits.totalShareGigabytesUsed) + self.assertEqual(EXAMPLE['totalShareSnapshotsUsed'], + limits.totalShareSnapshotsUsed) + self.assertEqual(EXAMPLE['maxTotalShares'], + limits.maxTotalShares) + self.assertEqual(EXAMPLE['totalSnapshotGigabytesUsed'], + limits.totalSnapshotGigabytesUsed) + self.assertEqual(EXAMPLE['maxTotalSnapshotGigabytes'], + limits.maxTotalSnapshotGigabytes) + self.assertEqual(EXAMPLE['maxTotalShareSnapshots'], + limits.maxTotalShareSnapshots) + self.assertEqual(EXAMPLE['maxTotalShareReplicas'], + limits.maxTotalShareReplicas) + self.assertEqual(EXAMPLE['maxTotalReplicaGigabytes'], + limits.maxTotalReplicaGigabytes) + self.assertEqual(EXAMPLE['totalShareReplicasUsed'], + limits.totalShareReplicasUsed) + self.assertEqual(EXAMPLE['totalReplicaGigabytesUsed'], + limits.totalReplicaGigabytesUsed) diff --git a/openstack/tests/unit/shared_file_system/v2/test_proxy.py b/openstack/tests/unit/shared_file_system/v2/test_proxy.py index 251251b44..573a354d2 100644 --- a/openstack/tests/unit/shared_file_system/v2/test_proxy.py +++ b/openstack/tests/unit/shared_file_system/v2/test_proxy.py @@ -13,6 +13,7 @@ from unittest import mock from openstack.shared_file_system.v2 import _proxy +from openstack.shared_file_system.v2 import limit from openstack.shared_file_system.v2 import share from openstack.shared_file_system.v2 import storage_pool from openstack.shared_file_system.v2 import user_message @@ -107,3 +108,6 @@ class TestUserMessageProxy(test_proxy_base.TestProxyBase): def test_delete_user_message_true(self): self.verify_delete( self.proxy.delete_user_message, user_message.UserMessage, True) + + def test_limit(self): + self.verify_list(self.proxy.limits, limit.Limit) diff --git a/releasenotes/notes/add-limit-to-shared-file-2b443c2a00c75e6e.yaml b/releasenotes/notes/add-limit-to-shared-file-2b443c2a00c75e6e.yaml new file mode 100644 index 000000000..58ff44f09 --- /dev/null +++ b/releasenotes/notes/add-limit-to-shared-file-2b443c2a00c75e6e.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added support to list absolute resource limits on the shared + file system service.