Merge "Driver resource for bare-metal service"
This commit is contained in:
commit
ca4261538f
|
@ -0,0 +1,39 @@
|
|||
# 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.bare_metal import bare_metal_service
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Driver(resource.Resource):
|
||||
|
||||
resources_key = 'drivers'
|
||||
base_path = '/drivers'
|
||||
service = bare_metal_service.BareMetalService()
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_get = True
|
||||
allow_update = False
|
||||
allow_delete = False
|
||||
allow_list = True
|
||||
|
||||
# NOTE: Query mapping?
|
||||
|
||||
#: The name of the driver
|
||||
name = resource.Body('name', alternate_id=True)
|
||||
#: A list of active hosts that support this driver.
|
||||
hosts = resource.Body('hosts', type=list)
|
||||
#: A list of relative links, including the self and bookmark links.
|
||||
links = resource.Body('links', type=list)
|
||||
#: A list of links to driver properties.
|
||||
properties = resource.Body('properties', type=list)
|
|
@ -0,0 +1,66 @@
|
|||
# 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.bare_metal.v1 import driver
|
||||
|
||||
FAKE = {
|
||||
"hosts": [
|
||||
"897ab1dad809"
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"href": "http://127.0.0.1:6385/v1/drivers/agent_ipmitool",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://127.0.0.1:6385/drivers/agent_ipmitool",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"name": "agent_ipmitool",
|
||||
"properties": [
|
||||
{
|
||||
"href":
|
||||
"http://127.0.0.1:6385/v1/drivers/agent_ipmitool/properties",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://127.0.0.1:6385/drivers/agent_ipmitool/properties",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
class TestDriver(testtools.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
sot = driver.Driver()
|
||||
self.assertIsNone(sot.resource_key)
|
||||
self.assertEqual('drivers', sot.resources_key)
|
||||
self.assertEqual('/drivers', sot.base_path)
|
||||
self.assertEqual('baremetal', sot.service.service_type)
|
||||
self.assertFalse(sot.allow_create)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertFalse(sot.allow_update)
|
||||
self.assertFalse(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = driver.Driver(**FAKE)
|
||||
self.assertEqual(FAKE['name'], sot.id)
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
self.assertEqual(FAKE['hosts'], sot.hosts)
|
||||
self.assertEqual(FAKE['links'], sot.links)
|
||||
self.assertEqual(FAKE['properties'], sot.properties)
|
Loading…
Reference in New Issue