Add block storage summary support
Added support to provide block storage summary. Change-Id: I1e665a45c8c2c3658099aa6aa070facb3a6c9e60
This commit is contained in:
parent
b7ff0313aa
commit
200cd5c4f8
@ -133,3 +133,11 @@ Helpers
|
||||
.. autoclass:: openstack.block_storage.v3._proxy.Proxy
|
||||
:noindex:
|
||||
:members: wait_for_status, wait_for_delete
|
||||
|
||||
BlockStorageSummary Operations
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. autoclass:: openstack.block_storage.v3._proxy.Proxy
|
||||
:noindex:
|
||||
:members: summary
|
||||
|
||||
|
@ -15,3 +15,4 @@ Block Storage Resources
|
||||
v3/snapshot
|
||||
v3/type
|
||||
v3/volume
|
||||
v3/block_storage_summary
|
||||
|
@ -0,0 +1,14 @@
|
||||
openstack.block_storage.v3.block_storage_summary
|
||||
================================================
|
||||
|
||||
.. automodule:: openstack.block_storage.v3.block_storage_summary
|
||||
|
||||
The Block Storage Summary Class
|
||||
-------------------------------
|
||||
|
||||
The ``Block Storage Summary`` class inherits from
|
||||
:class:`~openstack.resource.Resource`.
|
||||
|
||||
.. autoclass:: openstack.block_storage.v3.block_storage_summary.BlockStorageSummary
|
||||
:members:
|
||||
|
@ -13,6 +13,7 @@
|
||||
from openstack.block_storage import _base_proxy
|
||||
from openstack.block_storage.v3 import availability_zone
|
||||
from openstack.block_storage.v3 import backup as _backup
|
||||
from openstack.block_storage.v3 import block_storage_summary as _summary
|
||||
from openstack.block_storage.v3 import capabilities as _capabilities
|
||||
from openstack.block_storage.v3 import extension as _extension
|
||||
from openstack.block_storage.v3 import group as _group
|
||||
@ -44,6 +45,7 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
||||
"resource_filter": _resource_filter.ResourceFilter,
|
||||
"snapshot": _snapshot.Snapshot,
|
||||
"stats_pools": _stats.Pools,
|
||||
"summary": _summary.BlockStorageSummary,
|
||||
"type": _type.Type,
|
||||
"volume": _volume.Volume,
|
||||
}
|
||||
@ -662,6 +664,26 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
||||
else:
|
||||
volume.delete_metadata(self)
|
||||
|
||||
def summary(self, all_projects):
|
||||
"""Get Volumes Summary
|
||||
|
||||
This method returns the volumes summary in the deployment.
|
||||
|
||||
:param all_projects: Whether to return the summary of all projects
|
||||
or not.
|
||||
|
||||
:returns: One :class:
|
||||
`~openstack.block_storage.v3.block_storage_summary.Summary`
|
||||
instance.
|
||||
"""
|
||||
res = self._get(_summary.BlockStorageSummary, requires_id=False)
|
||||
return res.fetch(
|
||||
self,
|
||||
requires_id=False,
|
||||
resource_response_key='volume-summary',
|
||||
all_projects=all_projects,
|
||||
)
|
||||
|
||||
# ====== VOLUME ACTIONS ======
|
||||
def extend_volume(self, volume, size):
|
||||
"""Extend a volume
|
||||
|
30
openstack/block_storage/v3/block_storage_summary.py
Normal file
30
openstack/block_storage/v3/block_storage_summary.py
Normal file
@ -0,0 +1,30 @@
|
||||
# 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 BlockStorageSummary(resource.Resource):
|
||||
base_path = "/volumes/summary"
|
||||
|
||||
# capabilities
|
||||
allow_fetch = True
|
||||
|
||||
# Properties
|
||||
#: Total size of all the volumes
|
||||
total_size = resource.Body("total_size")
|
||||
#: Total count of all the volumes
|
||||
total_count = resource.Body("total_count")
|
||||
#: Metadata of all the volumes
|
||||
metadata = resource.Body("metadata")
|
||||
|
||||
_max_microversion = "3.36"
|
@ -0,0 +1,21 @@
|
||||
# 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.block_storage.v3 import base
|
||||
|
||||
|
||||
class TestBlockStorageSummary(base.BaseBlockStorageTest):
|
||||
def test_get(self):
|
||||
sot = self.conn.block_storage.summary(all_projects=True)
|
||||
self.assertIn('total_size', sot)
|
||||
self.assertIn('total_count', sot)
|
||||
self.assertIn('metadata', sot)
|
@ -0,0 +1,69 @@
|
||||
# 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.
|
||||
|
||||
import copy
|
||||
|
||||
from openstack.block_storage.v3 import block_storage_summary as summary
|
||||
from openstack.tests.unit import base
|
||||
|
||||
|
||||
BLOCK_STORAGE_SUMMARY_312 = {
|
||||
"total_size": "4",
|
||||
"total_count": "2",
|
||||
"metadata": {"key1": "value1"},
|
||||
}
|
||||
|
||||
|
||||
BLOCK_STORAGE_SUMMARY_326 = copy.deepcopy(BLOCK_STORAGE_SUMMARY_312)
|
||||
BLOCK_STORAGE_SUMMARY_326['metadata'] = {"key1": "value1"}
|
||||
|
||||
|
||||
class TestBlockStorageSummary(base.TestCase):
|
||||
def test_basic(self):
|
||||
summary_resource = summary.BlockStorageSummary()
|
||||
self.assertEqual(None, summary_resource.resource_key)
|
||||
self.assertEqual(None, summary_resource.resources_key)
|
||||
self.assertEqual("/volumes/summary", summary_resource.base_path)
|
||||
self.assertTrue(summary_resource.allow_fetch)
|
||||
self.assertFalse(summary_resource.allow_create)
|
||||
self.assertFalse(summary_resource.allow_commit)
|
||||
self.assertFalse(summary_resource.allow_delete)
|
||||
self.assertFalse(summary_resource.allow_list)
|
||||
|
||||
def test_get_summary_312(self):
|
||||
summary_resource = summary.BlockStorageSummary(
|
||||
**BLOCK_STORAGE_SUMMARY_312
|
||||
)
|
||||
self.assertEqual(
|
||||
BLOCK_STORAGE_SUMMARY_312["total_size"],
|
||||
summary_resource.total_size,
|
||||
)
|
||||
self.assertEqual(
|
||||
BLOCK_STORAGE_SUMMARY_312["total_count"],
|
||||
summary_resource.total_count,
|
||||
)
|
||||
|
||||
def test_get_summary_326(self):
|
||||
summary_resource = summary.BlockStorageSummary(
|
||||
**BLOCK_STORAGE_SUMMARY_326
|
||||
)
|
||||
self.assertEqual(
|
||||
BLOCK_STORAGE_SUMMARY_326["total_size"],
|
||||
summary_resource.total_size,
|
||||
)
|
||||
self.assertEqual(
|
||||
BLOCK_STORAGE_SUMMARY_326["total_count"],
|
||||
summary_resource.total_count,
|
||||
)
|
||||
self.assertEqual(
|
||||
BLOCK_STORAGE_SUMMARY_326["metadata"], summary_resource.metadata
|
||||
)
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Added support for block storage summary.
|
||||
|
Loading…
Reference in New Issue
Block a user