Adds storage pools to shared file system
Change-Id: Ia899a7b829302d8a516eb2f3e4ef7f293be26984
This commit is contained in:
parent
21c3c2d6ec
commit
88e520f5ad
@ -33,3 +33,14 @@ service.
|
||||
.. autoclass:: openstack.shared_file_system.v2._proxy.Proxy
|
||||
:noindex:
|
||||
:members: shares, get_share, delete_share, update_share, create_share
|
||||
|
||||
|
||||
Shared File System Storage Pools
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Interact with the storage pool statistics exposed by the Shared File
|
||||
Systems Service.
|
||||
|
||||
.. autoclass:: openstack.shared_file_system.v2._proxy.Proxy
|
||||
:noindex:
|
||||
:members: storage_pools
|
||||
|
@ -5,4 +5,5 @@ Shared File System service resources
|
||||
:maxdepth: 1
|
||||
|
||||
v2/availability_zone
|
||||
v2/storage_pool
|
||||
v2/share
|
||||
|
@ -0,0 +1,13 @@
|
||||
openstack.shared_file_system.v2.storage_pool
|
||||
============================================
|
||||
|
||||
.. automodule:: openstack.shared_file_system.v2.storage_pool
|
||||
|
||||
The StoragePool Class
|
||||
---------------------
|
||||
|
||||
The ``StoragePool`` class inherits from
|
||||
:class:`~openstack.resource.Resource`.
|
||||
|
||||
.. autoclass:: openstack.shared_file_system.v2.storage_pool.StoragePool
|
||||
:members:
|
@ -14,6 +14,9 @@ from openstack import proxy
|
||||
from openstack import resource
|
||||
from openstack.shared_file_system.v2 import (
|
||||
availability_zone as _availability_zone)
|
||||
from openstack.shared_file_system.v2 import (
|
||||
storage_pool as _storage_pool
|
||||
)
|
||||
from openstack.shared_file_system.v2 import share as _share
|
||||
|
||||
|
||||
@ -146,3 +149,22 @@ class Proxy(proxy.Proxy):
|
||||
failures = [] if failures is None else failures
|
||||
return resource.wait_for_status(
|
||||
self, res, status, failures, interval, wait)
|
||||
|
||||
def storage_pools(self, details=True, **query):
|
||||
"""Lists all back-end storage pools with details
|
||||
|
||||
:param kwargs query: Optional query parameters to be sent to limit
|
||||
the storage pools being returned. Available parameters include:
|
||||
|
||||
* pool_name: The pool name for the back end.
|
||||
* host_name: The host name for the back end.
|
||||
* backend_name: The name of the back end.
|
||||
* capabilities: The capabilities for the storage back end.
|
||||
* share_type: The share type name or UUID.
|
||||
:returns: A generator of manila storage pool resources
|
||||
:rtype: :class:`~openstack.shared_file_system.v2.
|
||||
storage_pool.StoragePool`
|
||||
"""
|
||||
base_path = '/scheduler-stats/pools/detail' if details else None
|
||||
return self._list(
|
||||
_storage_pool.StoragePool, base_path=base_path, **query)
|
||||
|
41
openstack/shared_file_system/v2/storage_pool.py
Normal file
41
openstack/shared_file_system/v2/storage_pool.py
Normal file
@ -0,0 +1,41 @@
|
||||
# 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 StoragePool(resource.Resource):
|
||||
|
||||
resources_key = "pools"
|
||||
base_path = "/scheduler-stats/pools"
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_fetch = False
|
||||
allow_commit = False
|
||||
allow_delete = False
|
||||
allow_list = True
|
||||
allow_head = False
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'pool', 'backend', 'host', 'capabilities', 'share_type',
|
||||
)
|
||||
|
||||
#: Properties
|
||||
#: The name of the back end.
|
||||
backend = resource.Body("backend", type=str)
|
||||
#: The host of the back end.
|
||||
host = resource.Body("host", type=str)
|
||||
#: The pool for the back end
|
||||
pool = resource.Body("pool", type=str)
|
||||
#: The back end capabilities.
|
||||
capabilities = resource.Body("capabilities", type=dict)
|
@ -0,0 +1,24 @@
|
||||
# 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 StoragePoolTest(base.BaseSharedFileSystemTest):
|
||||
|
||||
def test_storage_pools(self):
|
||||
pools = self.operator_cloud.shared_file_system.storage_pools()
|
||||
self.assertGreater(len(list(pools)), 0)
|
||||
for pool in pools:
|
||||
for attribute in ('pool', 'name', 'host', 'backend',
|
||||
'capabilities'):
|
||||
self.assertTrue(hasattr(pool, attribute))
|
@ -14,6 +14,7 @@ from unittest import mock
|
||||
|
||||
from openstack.shared_file_system.v2 import _proxy
|
||||
from openstack.shared_file_system.v2 import share
|
||||
from openstack.shared_file_system.v2 import storage_pool
|
||||
from openstack.tests.unit import test_proxy_base
|
||||
|
||||
|
||||
@ -62,3 +63,19 @@ class TestSharedFileSystemProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
mock_wait.assert_called_once_with(self.proxy, mock_resource,
|
||||
'ACTIVE', [], 2, 120)
|
||||
|
||||
def test_storage_pools(self):
|
||||
self.verify_list(
|
||||
self.proxy.storage_pools, storage_pool.StoragePool)
|
||||
|
||||
def test_storage_pool_detailed(self):
|
||||
self.verify_list(
|
||||
self.proxy.storage_pools, storage_pool.StoragePool,
|
||||
method_kwargs={"details": True, "backend": "alpha"},
|
||||
expected_kwargs={"backend": "alpha"})
|
||||
|
||||
def test_storage_pool_not_detailed(self):
|
||||
self.verify_list(
|
||||
self.proxy.storage_pools, storage_pool.StoragePool,
|
||||
method_kwargs={"details": False, "backend": "alpha"},
|
||||
expected_kwargs={"backend": "alpha"})
|
||||
|
@ -0,0 +1,74 @@
|
||||
# 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 storage_pool
|
||||
from openstack.tests.unit import base
|
||||
|
||||
|
||||
EXAMPLE = {
|
||||
"name": "opencloud@alpha#ALPHA_pool",
|
||||
"host": "opencloud",
|
||||
"backend": "alpha",
|
||||
"pool": "ALPHA_pool",
|
||||
"capabilities": {
|
||||
"pool_name": "ALPHA_pool",
|
||||
"total_capacity_gb": 1230.0,
|
||||
"free_capacity_gb": 1210.0,
|
||||
"reserved_percentage": 0,
|
||||
"share_backend_name": "ALPHA",
|
||||
"storage_protocol": "NFS_CIFS",
|
||||
"vendor_name": "Open Source",
|
||||
"driver_version": "1.0",
|
||||
"timestamp": "2021-07-31T00:28:02.935569",
|
||||
"driver_handles_share_servers": True,
|
||||
"snapshot_support": True,
|
||||
"create_share_from_snapshot_support": True,
|
||||
"revert_to_snapshot_support": True,
|
||||
"mount_snapshot_support": True,
|
||||
"dedupe": False,
|
||||
"compression": False,
|
||||
"replication_type": None,
|
||||
"replication_domain": None,
|
||||
"sg_consistent_snapshot_support": "pool",
|
||||
"ipv4_support": True,
|
||||
"ipv6_support": False}
|
||||
}
|
||||
|
||||
|
||||
class TestStoragePool(base.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
pool_resource = storage_pool.StoragePool()
|
||||
self.assertEqual('pools', pool_resource.resources_key)
|
||||
self.assertEqual(
|
||||
'/scheduler-stats/pools', pool_resource.base_path)
|
||||
self.assertTrue(pool_resource.allow_list)
|
||||
|
||||
self.assertDictEqual({
|
||||
'pool': 'pool',
|
||||
'backend': 'backend',
|
||||
'host': 'host',
|
||||
'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'capabilities': 'capabilities',
|
||||
'share_type': 'share_type',
|
||||
},
|
||||
pool_resource._query_mapping._mapping)
|
||||
|
||||
def test_make_storage_pool(self):
|
||||
pool_resource = storage_pool.StoragePool(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['pool'], pool_resource.pool)
|
||||
self.assertEqual(EXAMPLE['host'], pool_resource.host)
|
||||
self.assertEqual(EXAMPLE['name'], pool_resource.name)
|
||||
self.assertEqual(EXAMPLE['backend'], pool_resource.backend)
|
||||
self.assertEqual(
|
||||
EXAMPLE['capabilities'], pool_resource.capabilities)
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Added support for retrieving storage pools information from
|
||||
the Shared File Systems service.
|
Loading…
Reference in New Issue
Block a user