Add the Type resource for the Volume service
This change also enables documentation to start showing up for Volume resources. Change-Id: I3193f973a5c0ad00c2bebe477a8748fc7a7d7a5f
This commit is contained in:
@@ -76,6 +76,7 @@ The following services have exposed *Resource* classes.
|
|||||||
Database <resources/database/index>
|
Database <resources/database/index>
|
||||||
Network <resources/network/index>
|
Network <resources/network/index>
|
||||||
Object Store <resources/object_store/index>
|
Object Store <resources/object_store/index>
|
||||||
|
Volume <resources/volume/index>
|
||||||
|
|
||||||
Low-Level Classes
|
Low-Level Classes
|
||||||
*****************
|
*****************
|
||||||
|
|||||||
7
doc/source/users/resources/volume/index.rst
Normal file
7
doc/source/users/resources/volume/index.rst
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Volume Resources
|
||||||
|
================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
v2/type
|
||||||
13
doc/source/users/resources/volume/v2/type.rst
Normal file
13
doc/source/users/resources/volume/v2/type.rst
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
openstack.volume.v2.type
|
||||||
|
========================
|
||||||
|
|
||||||
|
.. automodule:: openstack.volume.v2.type
|
||||||
|
|
||||||
|
The Type Class
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The ``Type`` class inherits from :class:`~openstack.resource.Resource`.
|
||||||
|
|
||||||
|
.. autoclass:: openstack.volume.v2.type.Type
|
||||||
|
:members:
|
||||||
|
|
||||||
0
openstack/tests/volume/v2/__init__.py
Normal file
0
openstack/tests/volume/v2/__init__.py
Normal file
49
openstack/tests/volume/v2/test_type.py
Normal file
49
openstack/tests/volume/v2/test_type.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# 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 testtools
|
||||||
|
|
||||||
|
from openstack.volume.v2 import type
|
||||||
|
|
||||||
|
FAKE_ID = "6685584b-1eac-4da6-b5c3-555430cf68ff"
|
||||||
|
TYPE = {
|
||||||
|
"extra_specs": {
|
||||||
|
"capabilities": "gpu"
|
||||||
|
},
|
||||||
|
"id": FAKE_ID,
|
||||||
|
"name": "SSD"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TestType(testtools.TestCase):
|
||||||
|
|
||||||
|
def test_basic(self):
|
||||||
|
sot = type.Type(TYPE)
|
||||||
|
self.assertEqual("volume_type", sot.resource_key)
|
||||||
|
self.assertEqual("volume_types", sot.resources_key)
|
||||||
|
self.assertEqual("id", sot.id_attribute)
|
||||||
|
self.assertEqual("/types", sot.base_path)
|
||||||
|
self.assertEqual("volume", sot.service.service_type)
|
||||||
|
self.assertTrue(sot.allow_create)
|
||||||
|
self.assertTrue(sot.allow_retrieve)
|
||||||
|
self.assertTrue(sot.allow_delete)
|
||||||
|
self.assertFalse(sot.allow_list)
|
||||||
|
|
||||||
|
def test_new(self):
|
||||||
|
sot = type.Type.new(id=FAKE_ID)
|
||||||
|
self.assertEqual(FAKE_ID, sot.id)
|
||||||
|
|
||||||
|
def test_create(self):
|
||||||
|
sot = type.Type(TYPE)
|
||||||
|
self.assertEqual(TYPE["id"], sot.id)
|
||||||
|
self.assertEqual(TYPE["extra_specs"], sot.extra_specs)
|
||||||
|
self.assertEqual(TYPE["name"], sot.name)
|
||||||
0
openstack/volume/v2/__init__.py
Normal file
0
openstack/volume/v2/__init__.py
Normal file
34
openstack/volume/v2/type.py
Normal file
34
openstack/volume/v2/type.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# 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
|
||||||
|
from openstack.volume import volume_service
|
||||||
|
|
||||||
|
|
||||||
|
class Type(resource.Resource):
|
||||||
|
resource_key = "volume_type"
|
||||||
|
resources_key = "volume_types"
|
||||||
|
base_path = "/types"
|
||||||
|
service = volume_service.VolumeService()
|
||||||
|
|
||||||
|
# capabilities
|
||||||
|
allow_retrieve = True
|
||||||
|
allow_create = True
|
||||||
|
allow_delete = True
|
||||||
|
|
||||||
|
# Properties
|
||||||
|
#: A UUID representing this volume.
|
||||||
|
id = resource.prop("id")
|
||||||
|
#: Name of the type.
|
||||||
|
name = resource.prop("name")
|
||||||
|
#: A dict of extra specifications. "capabilities" is a usual key.
|
||||||
|
extra_specs = resource.prop("extra_specs", type=dict)
|
||||||
Reference in New Issue
Block a user