Add limit resource to shared file system
Introduce Limit class to shared file system. Change-Id: Ib1f68e43cf406401038e42879147b1268ba1a2c8
This commit is contained in:
parent
8c016689c0
commit
290a6cf56b
@ -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
|
||||
|
@ -6,5 +6,6 @@ Shared File System service resources
|
||||
|
||||
v2/availability_zone
|
||||
v2/storage_pool
|
||||
v2/limit
|
||||
v2/share
|
||||
v2/user_message
|
||||
|
13
doc/source/user/resources/shared_file_system/v2/limit.rst
Normal file
13
doc/source/user/resources/shared_file_system/v2/limit.rst
Normal file
@ -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:
|
@ -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)
|
||||
|
75
openstack/shared_file_system/v2/limit.py
Normal file
75
openstack/shared_file_system/v2/limit.py
Normal file
@ -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)
|
36
openstack/tests/functional/shared_file_system/test_limit.py
Normal file
36
openstack/tests/functional/shared_file_system/test_limit.py
Normal file
@ -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))
|
@ -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)
|
||||
|
76
openstack/tests/unit/shared_file_system/v2/test_limit.py
Normal file
76
openstack/tests/unit/shared_file_system/v2/test_limit.py
Normal file
@ -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)
|
@ -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)
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Added support to list absolute resource limits on the shared
|
||||
file system service.
|
Loading…
Reference in New Issue
Block a user