Merge "volume: Add Capability to volume v2 API"
This commit is contained in:
commit
c9a1d5729b
doc/source/user
openstack
block_storage
tests/unit/block_storage/v2
@ -26,6 +26,13 @@ Backup Operations
|
||||
:noindex:
|
||||
:members: create_backup, delete_backup, get_backup, backups, restore_backup
|
||||
|
||||
Capabilities Operations
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. autoclass:: openstack.block_storage.v2._proxy.Proxy
|
||||
:noindex:
|
||||
:members: get_capabilities
|
||||
|
||||
Type Operations
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
12
doc/source/user/resources/block_storage/v2/capabilities.rst
Normal file
12
doc/source/user/resources/block_storage/v2/capabilities.rst
Normal file
@ -0,0 +1,12 @@
|
||||
openstack.block_storage.v2.capabilities
|
||||
=======================================
|
||||
|
||||
.. automodule:: openstack.block_storage.v2.capabilities
|
||||
|
||||
The Capabilities Class
|
||||
----------------------
|
||||
|
||||
The ``Capabilities`` class inherits from :class:`~openstack.resource.Resource`.
|
||||
|
||||
.. autoclass:: openstack.block_storage.v2.capabilities.Capabilities
|
||||
:members:
|
@ -12,6 +12,7 @@
|
||||
|
||||
from openstack.block_storage import _base_proxy
|
||||
from openstack.block_storage.v2 import backup as _backup
|
||||
from openstack.block_storage.v2 import capabilities as _capabilities
|
||||
from openstack.block_storage.v2 import extension as _extension
|
||||
from openstack.block_storage.v2 import quota_set as _quota_set
|
||||
from openstack.block_storage.v2 import snapshot as _snapshot
|
||||
@ -601,7 +602,7 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
||||
"""Reset status of the backup
|
||||
|
||||
:param backup: The value can be either the ID of a backup or a
|
||||
:class:`~openstack.block_storage.v3.backup.Backup` instance.
|
||||
:class:`~openstack.block_storage.v2.backup.Backup` instance.
|
||||
:param str status: New backup status
|
||||
|
||||
:returns: None
|
||||
@ -609,6 +610,19 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
||||
backup = self._get_resource(_backup.Backup, backup)
|
||||
backup.reset(self, status)
|
||||
|
||||
# ====== CAPABILITIES ======
|
||||
def get_capabilities(self, host):
|
||||
"""Get a backend's capabilites
|
||||
|
||||
:param host: Specified backend to obtain volume stats and properties.
|
||||
|
||||
:returns: One :class:
|
||||
`~openstack.block_storage.v2.capabilites.Capabilities` instance.
|
||||
:raises: :class:`~openstack.exceptions.ResourceNotFound` when no
|
||||
resource can be found.
|
||||
"""
|
||||
return self._get(_capabilities.Capabilities, host)
|
||||
|
||||
# ====== QUOTA SETS ======
|
||||
def get_quota_set(self, project, usage=False, **query):
|
||||
"""Show QuotaSet information for the project
|
||||
@ -784,7 +798,7 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
||||
"""Return a generator of extensions
|
||||
|
||||
:returns: A generator of extension
|
||||
:rtype: :class:`~openstack.block_storage.v3.extension.Extension`
|
||||
:rtype: :class:`~openstack.block_storage.v2.extension.Extension`
|
||||
"""
|
||||
return self._list(_extension.Extension)
|
||||
|
||||
|
45
openstack/block_storage/v2/capabilities.py
Normal file
45
openstack/block_storage/v2/capabilities.py
Normal file
@ -0,0 +1,45 @@
|
||||
# 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 Capabilities(resource.Resource):
|
||||
base_path = "/capabilities"
|
||||
|
||||
# Capabilities
|
||||
allow_fetch = True
|
||||
|
||||
#: Properties
|
||||
#: The capabilities description
|
||||
description = resource.Body("description")
|
||||
#: The name of volume backend capabilities.
|
||||
display_name = resource.Body("display_name")
|
||||
#: The driver version.
|
||||
driver_version = resource.Body("driver_version")
|
||||
#: The storage namespace, such as OS::Storage::Capabilities::foo.
|
||||
namespace = resource.Body("namespace")
|
||||
#: The name of the storage pool.
|
||||
pool_name = resource.Body("pool_name")
|
||||
#: The backend volume capabilites list, which consists of cinder
|
||||
#: standard capabilities and vendor unique properties.
|
||||
properties = resource.Body("properties", type=dict)
|
||||
#: A list of volume backends used to replicate volumes on this backend.
|
||||
replication_targets = resource.Body("replication_targets", type=list)
|
||||
#: The storage backend for the backend volume.
|
||||
storage_protocol = resource.Body("storage_protocol")
|
||||
#: The name of the vendor.
|
||||
vendor_name = resource.Body("vendor_name")
|
||||
#: The volume type access.
|
||||
visibility = resource.Body("visibility")
|
||||
#: The name of the back-end volume.
|
||||
volume_backend_name = resource.Body("volume_backend_name")
|
@ -1219,6 +1219,7 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
||||
params['project_id'] = resource.Resource._get_id(project)
|
||||
return self._get(_limits.Limit, requires_id=False, **params)
|
||||
|
||||
# ====== CAPABILITIES ======
|
||||
def get_capabilities(self, host):
|
||||
"""Get a backend's capabilites
|
||||
|
||||
|
102
openstack/tests/unit/block_storage/v2/test_capabilities.py
Normal file
102
openstack/tests/unit/block_storage/v2/test_capabilities.py
Normal file
@ -0,0 +1,102 @@
|
||||
# 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.block_storage.v2 import capabilities
|
||||
from openstack.tests.unit import base
|
||||
|
||||
CAPABILITIES = {
|
||||
"namespace": "OS::Storage::Capabilities::fake",
|
||||
"vendor_name": "OpenStack",
|
||||
"volume_backend_name": "lvmdriver-1",
|
||||
"pool_name": "pool",
|
||||
"driver_version": "2.0.0",
|
||||
"storage_protocol": "iSCSI",
|
||||
"display_name": "Capabilities of Cinder LVM driver",
|
||||
"description": "These are volume type options",
|
||||
"visibility": "public",
|
||||
"replication_targets": [],
|
||||
"properties": {
|
||||
"compression": {
|
||||
"title": "Compression",
|
||||
"description": "Enables compression.",
|
||||
"type": "boolean",
|
||||
},
|
||||
"qos": {
|
||||
"title": "QoS",
|
||||
"description": "Enables QoS.",
|
||||
"type": "boolean",
|
||||
},
|
||||
"replication": {
|
||||
"title": "Replication",
|
||||
"description": "Enables replication.",
|
||||
"type": "boolean",
|
||||
},
|
||||
"thin_provisioning": {
|
||||
"title": "Thin Provisioning",
|
||||
"description": "Sets thin provisioning.",
|
||||
"type": "boolean",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class TestCapabilites(base.TestCase):
|
||||
def test_basic(self):
|
||||
capabilities_resource = capabilities.Capabilities()
|
||||
self.assertEqual(None, capabilities_resource.resource_key)
|
||||
self.assertEqual(None, capabilities_resource.resources_key)
|
||||
self.assertEqual("/capabilities", capabilities_resource.base_path)
|
||||
self.assertTrue(capabilities_resource.allow_fetch)
|
||||
self.assertFalse(capabilities_resource.allow_create)
|
||||
self.assertFalse(capabilities_resource.allow_commit)
|
||||
self.assertFalse(capabilities_resource.allow_delete)
|
||||
self.assertFalse(capabilities_resource.allow_list)
|
||||
|
||||
def test_make_capabilities(self):
|
||||
capabilities_resource = capabilities.Capabilities(**CAPABILITIES)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["description"], capabilities_resource.description
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["display_name"], capabilities_resource.display_name
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["driver_version"],
|
||||
capabilities_resource.driver_version,
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["namespace"], capabilities_resource.namespace
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["pool_name"], capabilities_resource.pool_name
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["properties"], capabilities_resource.properties
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["replication_targets"],
|
||||
capabilities_resource.replication_targets,
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["storage_protocol"],
|
||||
capabilities_resource.storage_protocol,
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["vendor_name"], capabilities_resource.vendor_name
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["visibility"], capabilities_resource.visibility
|
||||
)
|
||||
self.assertEqual(
|
||||
CAPABILITIES["volume_backend_name"],
|
||||
capabilities_resource.volume_backend_name,
|
||||
)
|
@ -13,6 +13,7 @@ from unittest import mock
|
||||
|
||||
from openstack.block_storage.v2 import _proxy
|
||||
from openstack.block_storage.v2 import backup
|
||||
from openstack.block_storage.v2 import capabilities
|
||||
from openstack.block_storage.v2 import quota_set
|
||||
from openstack.block_storage.v2 import snapshot
|
||||
from openstack.block_storage.v2 import stats
|
||||
@ -289,6 +290,11 @@ class TestBackup(TestVolumeProxy):
|
||||
)
|
||||
|
||||
|
||||
class TestCapabilities(TestVolumeProxy):
|
||||
def test_capabilites_get(self):
|
||||
self.verify_get(self.proxy.get_capabilities, capabilities.Capabilities)
|
||||
|
||||
|
||||
class TestSnapshot(TestVolumeProxy):
|
||||
def test_snapshot_get(self):
|
||||
self.verify_get(self.proxy.get_snapshot, snapshot.Snapshot)
|
||||
|
Loading…
x
Reference in New Issue
Block a user