Merge "Add support for API Extensions"
This commit is contained in:
@@ -14,6 +14,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 capabilities as _capabilities
|
||||
from openstack.block_storage.v3 import extension as _extension
|
||||
from openstack.block_storage.v3 import group_type as _group_type
|
||||
from openstack.block_storage.v3 import limits as _limits
|
||||
from openstack.block_storage.v3 import resource_filter as _resource_filter
|
||||
@@ -693,6 +694,15 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
||||
"""
|
||||
return self._list(_resource_filter.ResourceFilter, **query)
|
||||
|
||||
def extensions(self):
|
||||
"""Return a generator of extensions
|
||||
|
||||
:returns: A generator of extension
|
||||
:rtype: :class:`~openstack.block_storage.v3.extension.\
|
||||
Extension`
|
||||
"""
|
||||
return self._list(_extension.Extension)
|
||||
|
||||
def _get_cleanup_dependencies(self):
|
||||
return {
|
||||
'block_storage': {
|
||||
|
||||
31
openstack/block_storage/v3/extension.py
Normal file
31
openstack/block_storage/v3/extension.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# 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 Extension(resource.Resource):
|
||||
"""Extension"""
|
||||
resources_key = "extensions"
|
||||
base_path = "/extensions"
|
||||
|
||||
# Capabilities
|
||||
allow_list = True
|
||||
|
||||
#: Properties
|
||||
#: The alias for the extension.
|
||||
alias = resource.Body('alias', type=str)
|
||||
#: The extension description.
|
||||
description = resource.Body('description', type=str)
|
||||
#: The date and time when the resource was updated.
|
||||
#: The date and time stamp format is ISO 8601.
|
||||
updated = resource.Body('updated', type=str)
|
||||
@@ -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.block_storage.v3 import base
|
||||
|
||||
|
||||
class Extensions(base.BaseBlockStorageTest):
|
||||
|
||||
def test_get(self):
|
||||
extensions = list(self.conn.block_storage.extensions())
|
||||
|
||||
for extension in extensions:
|
||||
self.assertIsInstance(extension.alias, str)
|
||||
self.assertIsInstance(extension.description, str)
|
||||
self.assertIsInstance(extension.updated, str)
|
||||
41
openstack/tests/unit/block_storage/v3/test_extension.py
Normal file
41
openstack/tests/unit/block_storage/v3/test_extension.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.block_storage.v3 import extension
|
||||
from openstack.tests.unit import base
|
||||
|
||||
EXTENSION = {
|
||||
"alias": "os-hosts",
|
||||
"description": "Admin-only host administration.",
|
||||
"links": [],
|
||||
"name": "Hosts",
|
||||
"updated": "2011-06-29T00:00:00+00:00",
|
||||
}
|
||||
|
||||
|
||||
class TestExtension(base.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
extension_resource = extension.Extension()
|
||||
self.assertEqual('extensions', extension_resource.resources_key)
|
||||
self.assertEqual('/extensions', extension_resource.base_path)
|
||||
self.assertFalse(extension_resource.allow_create)
|
||||
self.assertFalse(extension_resource.allow_fetch)
|
||||
self.assertFalse(extension_resource.allow_commit)
|
||||
self.assertFalse(extension_resource.allow_delete)
|
||||
self.assertTrue(extension_resource.allow_list)
|
||||
|
||||
def test_make_extension(self):
|
||||
extension_resource = extension.Extension(**EXTENSION)
|
||||
self.assertEqual(EXTENSION['alias'], extension_resource.alias)
|
||||
self.assertEqual(EXTENSION['description'],
|
||||
extension_resource.description)
|
||||
self.assertEqual(EXTENSION['updated'], extension_resource.updated)
|
||||
@@ -14,6 +14,7 @@ from unittest import mock
|
||||
from openstack.block_storage.v3 import _proxy
|
||||
from openstack.block_storage.v3 import backup
|
||||
from openstack.block_storage.v3 import capabilities
|
||||
from openstack.block_storage.v3 import extension
|
||||
from openstack.block_storage.v3 import group_type
|
||||
from openstack.block_storage.v3 import limits
|
||||
from openstack.block_storage.v3 import resource_filter
|
||||
@@ -269,3 +270,6 @@ class TestVolumeProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
def test_group_type_update(self):
|
||||
self.verify_update(self.proxy.update_group_type, group_type.GroupType)
|
||||
|
||||
def test_extensions(self):
|
||||
self.verify_list(self.proxy.extensions, extension.Extension)
|
||||
|
||||
Reference in New Issue
Block a user