Expose additional status in baremetal API extension

Add fields: uuid, task_state, updated_at, and pxe_config_path
to aid system admins in troubleshooting issues.

Fixes bug 1184449

Change-Id: Ia4c03cb228b3efe602455bf05883ddf03b7f18da
This commit is contained in:
Melanie Witt 2013-10-10 18:13:20 +00:00
parent d8d5e4c4e3
commit e5a5a0f310
44 changed files with 629 additions and 82 deletions

View File

@ -134,7 +134,7 @@
"links": [],
"name": "AssistedVolumeSnapshots",
"namespace": "http://docs.openstack.org/compute/ext/assisted-volume-snapshots/api/v2",
"updated": "2013-08-15T00:00:00-00:00"
"updated": "2013-08-29T00:00:00-00:00"
},
{
"alias": "os-attach-interfaces",
@ -152,6 +152,14 @@
"namespace": "http://docs.openstack.org/compute/ext/availabilityzone/api/v1.1",
"updated": "2012-12-21T00:00:00+00:00"
},
{
"alias": "os-baremetal-ext-status",
"description": "Add extended status in Baremetal Nodes v2 API.",
"links": [],
"name": "BareMetalExtStatus",
"namespace": "http://docs.openstack.org/compute/ext/baremetal_ext_status/api/v2",
"updated": "2013-08-27T00:00:00+00:00"
},
{
"alias": "os-baremetal-nodes",
"description": "Admin-only bare-metal node administration.",

View File

@ -52,7 +52,7 @@
<extension alias="os-aggregates" updated="2012-01-12T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/aggregates/api/v1.1" name="Aggregates">
<description>Admin-only aggregate administration.</description>
</extension>
<extension alias="os-assisted-volume-snapshots" updated="2013-08-15T00:00:00-00:00" namespace="http://docs.openstack.org/compute/ext/assisted-volume-snapshots/api/v2" name="AssistedVolumeSnapshots">
<extension alias="os-assisted-volume-snapshots" updated="2013-08-29T00:00:00-00:00" namespace="http://docs.openstack.org/compute/ext/assisted-volume-snapshots/api/v2" name="AssistedVolumeSnapshots">
<description>Assisted volume snapshots.</description>
</extension>
<extension alias="os-attach-interfaces" updated="2012-07-22T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/interfaces/api/v1.1" name="AttachInterfaces">
@ -63,6 +63,9 @@
2. Add availability zones describing.
</description>
</extension>
<extension alias="os-baremetal-ext-status" updated="2013-08-27T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/baremetal_ext_status/api/v2" name="BareMetalExtStatus">
<description>Add extended status in Baremetal Nodes v2 API.</description>
</extension>
<extension alias="os-baremetal-nodes" updated="2013-01-04T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/baremetal_nodes/api/v2" name="BareMetalNodes">
<description>Admin-only bare-metal node administration.</description>
</extension>

View File

@ -0,0 +1,5 @@
{
"add_interface": {
"address": "aa:aa:aa:aa:aa:aa"
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<add_interface
address="aa:aa:aa:aa:aa:aa"
/>

View File

@ -0,0 +1,8 @@
{
"interface": {
"address": "aa:aa:aa:aa:aa:aa",
"datapath_id": null,
"id": 1,
"port_no": null
}
}

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<interface datapath_id="None" id="1" port_no="None" address="aa:aa:aa:aa:aa:aa"/>

View File

@ -0,0 +1,12 @@
{
"node": {
"service_host": "host",
"cpus": 8,
"memory_mb": 8192,
"local_gb": 128,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pm_password": "pm_pass",
"terminal_port": 8000
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<node
service_host="host"
cpus="8"
memory_mb="8192"
local_gb="128"
pm_address="10.1.2.3"
pm_user="pm_user"
terminal_port="8000"
/>

View File

@ -0,0 +1,18 @@
{
"node": {
"cpus": 8,
"id": 1,
"instance_uuid": null,
"interfaces": [],
"local_gb": 128,
"memory_mb": 8192,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pxe_config_path": null,
"service_host": "host",
"task_state": null,
"terminal_port": 8000,
"updated_at": null,
"uuid": "73d35253-b6fb-4c83-b8eb-0229336e79b6"
}
}

View File

@ -0,0 +1,4 @@
<?xml version='1.0' encoding='UTF-8'?>
<node instance_uuid="None" pm_address="10.1.2.3" task_state="None" uuid="f76b453b-6392-4e21-9191-fe1e3ddb9b23" pxe_config_path="None" cpus="8" updated_at="None" memory_mb="8192" service_host="host" local_gb="128" id="1" pm_user="pm_user" terminal_port="8000">
<interfaces/>
</node>

View File

@ -0,0 +1,13 @@
{
"node": {
"service_host": "host",
"cpus": 8,
"memory_mb": 8192,
"local_gb": 128,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pm_password": "pm_pass",
"prov_mac_address": "12:34:56:78:90:ab",
"terminal_port": 8000
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<node
service_host="host"
cpus="8"
memory_mb="8192"
local_gb="128"
pm_address="10.1.2.3"
pm_user="pm_user"
prov_mac_address="12:34:56:78:90:ab"
terminal_port="8000"
/>

View File

@ -0,0 +1,25 @@
{
"node": {
"cpus": 8,
"id": 1,
"instance_uuid": null,
"interfaces": [
{
"address": "12:34:56:78:90:ab",
"datapath_id": null,
"id": 1,
"port_no": null
}
],
"local_gb": 128,
"memory_mb": 8192,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pxe_config_path": null,
"service_host": "host",
"task_state": null,
"terminal_port": 8000,
"updated_at": null,
"uuid": "0a130464-bccc-4e36-b9d3-9a8c98e636ae"
}
}

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<node instance_uuid="None" pm_address="10.1.2.3" task_state="None" uuid="cbed812a-7126-41a9-a6c1-f563e7f9af1f" pxe_config_path="None" cpus="8" updated_at="None" memory_mb="8192" service_host="host" local_gb="128" id="1" pm_user="pm_user" terminal_port="8000">
<interfaces>
<interface datapath_id="None" id="1" port_no="None" address="12:34:56:78:90:ab"/>
</interfaces>
</node>

View File

@ -0,0 +1,27 @@
{
"nodes": [
{
"cpus": 8,
"id": 1,
"instance_uuid": null,
"interfaces": [
{
"address": "aa:aa:aa:aa:aa:aa",
"datapath_id": null,
"id": 1,
"port_no": null
}
],
"local_gb": 128,
"memory_mb": 8192,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pxe_config_path": null,
"service_host": "host",
"task_state": null,
"terminal_port": 8000,
"updated_at": null,
"uuid": "6fae68da-108b-4a9d-87c4-88831ee1241b"
}
]
}

View File

@ -0,0 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?>
<nodes>
<node instance_uuid="None" pm_address="10.1.2.3" task_state="None" uuid="f76b453b-6392-4e21-9191-fe1e3ddb9b23" pxe_config_path="None" cpus="8" updated_at="None" memory_mb="8192" service_host="host" local_gb="128" id="1" pm_user="pm_user" terminal_port="8000">
<interfaces>
<interface datapath_id="None" id="1" port_no="None" address="aa:aa:aa:aa:aa:aa"/>
</interfaces>
</node>
</nodes>

View File

@ -0,0 +1,5 @@
{
"remove_interface": {
"address": "aa:aa:aa:aa:aa:aa"
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<remove_interface
address="aa:aa:aa:aa:aa:aa"
/>

View File

@ -0,0 +1,25 @@
{
"node": {
"cpus": 8,
"id": 1,
"instance_uuid": null,
"interfaces": [
{
"address": "aa:aa:aa:aa:aa:aa",
"datapath_id": null,
"id": 1,
"port_no": null
}
],
"local_gb": 128,
"memory_mb": 8192,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pxe_config_path": null,
"service_host": "host",
"task_state": null,
"terminal_port": 8000,
"updated_at": null,
"uuid": "c862b836-c7c1-4f7f-8081-6766fa9cf38b"
}
}

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<node instance_uuid="None" pm_address="10.1.2.3" task_state="None" uuid="8a819ee6-fd03-4122-963c-d924c6cb729f" pxe_config_path="None" cpus="8" updated_at="None" memory_mb="8192" service_host="host" local_gb="128" id="1" pm_user="pm_user" terminal_port="8000">
<interfaces>
<interface datapath_id="None" id="1" port_no="None" address="aa:aa:aa:aa:aa:aa"/>
</interfaces>
</node>

View File

@ -0,0 +1,27 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 OpenStack Foundation
#
# 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 nova.api.openstack import extensions
class Baremetal_ext_status(extensions.ExtensionDescriptor):
"""Add extended status in Baremetal Nodes v2 API."""
name = "BareMetalExtStatus"
alias = "os-baremetal-ext-status"
namespace = ("http://docs.openstack.org/compute/ext/"
"baremetal_ext_status/api/v2")
updated = "2013-08-27T00:00:00+00:00"

View File

@ -31,16 +31,11 @@ node_fields = ['id', 'cpus', 'local_gb', 'memory_mb', 'pm_address',
'service_host', 'terminal_port', 'instance_uuid',
]
node_ext_fields = ['uuid', 'task_state', 'updated_at', 'pxe_config_path']
interface_fields = ['id', 'address', 'datapath_id', 'port_no']
def _node_dict(node_ref):
d = {}
for f in node_fields:
d[f] = node_ref.get(f)
return d
def _interface_dict(interface_ref):
d = {}
for f in interface_fields:
@ -51,6 +46,8 @@ def _interface_dict(interface_ref):
def _make_node_elem(elem):
for f in node_fields:
elem.set(f)
for f in node_ext_fields:
elem.set(f)
def _make_interface_elem(elem):
@ -93,6 +90,19 @@ class InterfaceTemplate(xmlutil.TemplateBuilder):
class BareMetalNodeController(wsgi.Controller):
"""The Bare-Metal Node API controller for the OpenStack API."""
def __init__(self, ext_mgr=None, *args, **kwargs):
super(BareMetalNodeController, self).__init__(*args, **kwargs)
self.ext_mgr = ext_mgr
def _node_dict(self, node_ref):
d = {}
for f in node_fields:
d[f] = node_ref.get(f)
if self.ext_mgr.is_loaded('os-baremetal-ext-status'):
for f in node_ext_fields:
d[f] = node_ref.get(f)
return d
@wsgi.serializers(xml=NodesTemplate)
def index(self, req):
context = req.environ['nova.context']
@ -105,7 +115,7 @@ class BareMetalNodeController(wsgi.Controller):
context, node_from_db['id'])
except exception.NodeNotFound:
ifs = []
node = _node_dict(node_from_db)
node = self._node_dict(node_from_db)
node['interfaces'] = [_interface_dict(i) for i in ifs]
nodes.append(node)
return {'nodes': nodes}
@ -122,7 +132,7 @@ class BareMetalNodeController(wsgi.Controller):
ifs = db.bm_interface_get_all_by_bm_node_id(context, id)
except exception.NodeNotFound:
ifs = []
node = _node_dict(node)
node = self._node_dict(node)
node['interfaces'] = [_interface_dict(i) for i in ifs]
return {'node': node}
@ -133,7 +143,7 @@ class BareMetalNodeController(wsgi.Controller):
values = body['node'].copy()
prov_mac_address = values.pop('prov_mac_address', None)
node = db.bm_node_create(context, values)
node = _node_dict(node)
node = self._node_dict(node)
if prov_mac_address:
if_id = db.bm_interface_create(context,
bm_node_id=node['id'],
@ -213,7 +223,7 @@ class Baremetal_nodes(extensions.ExtensionDescriptor):
def get_resources(self):
resources = []
res = extensions.ResourceExtension('os-baremetal-nodes',
BareMetalNodeController(),
BareMetalNodeController(self.ext_mgr),
member_actions={"action": "POST", })
resources.append(res)
return resources

View File

@ -16,6 +16,7 @@
from webob import exc
from nova.api.openstack.compute.contrib import baremetal_nodes
from nova.api.openstack import extensions
from nova import context
from nova import exception
from nova import test
@ -28,37 +29,131 @@ class FakeRequest(object):
self.environ = {"nova.context": context}
def fake_node(**updates):
node = {
'id': 1,
'service_host': "host",
'cpus': 8,
'memory_mb': 8192,
'local_gb': 128,
'pm_address': "10.1.2.3",
'pm_user': "pm_user",
'pm_password': "pm_pass",
'terminal_port': 8000,
'interfaces': [],
'instance_uuid': 'fake-instance-uuid',
}
if updates:
node.update(updates)
return node
def fake_node_ext_status(**updates):
node = fake_node(uuid='fake-uuid',
task_state='fake-task-state',
updated_at='fake-updated-at',
pxe_config_path='fake-pxe-config-path')
if updates:
node.update(updates)
return node
def fake_interface(**updates):
interface = {
'id': 1,
'address': '11:11:11:11:11:11',
'datapath_id': 2,
'port_no': 3,
}
if updates:
interface.update(updates)
return interface
class BareMetalNodesTest(test.NoDBTestCase):
def setUp(self):
super(BareMetalNodesTest, self).setUp()
self.ext_mgr = self.mox.CreateMock(extensions.ExtensionManager)
self.context = context.get_admin_context()
self.controller = baremetal_nodes.BareMetalNodeController()
self.controller = baremetal_nodes.BareMetalNodeController(self.ext_mgr)
self.request = FakeRequest(self.context)
def test_create(self):
node = {
'service_host': "host",
'cpus': 8,
'memory_mb': 8192,
'local_gb': 128,
'pm_address': "10.1.2.3",
'pm_user': "pm_user",
'pm_password': "pm_pass",
'terminal_port': 8000,
'interfaces': [],
}
def _test_create(self, node, ext_status=False):
response = node.copy()
response['id'] = 100
del response['pm_password']
response['instance_uuid'] = None
self.mox.StubOutWithMock(db, 'bm_node_create')
db.bm_node_create(self.context, node).AndReturn(response)
self.ext_mgr.is_loaded('os-baremetal-ext-status').AndReturn(ext_status)
self.mox.ReplayAll()
res_dict = self.controller.create(self.request, {'node': node})
self.assertEqual({'node': response}, res_dict)
def _test_show(self, node, ext_status=False):
interfaces = [fake_interface(id=1, address='11:11:11:11:11:11'),
fake_interface(id=2, address='22:22:22:22:22:22'),
]
node.update(interfaces=interfaces)
response = node.copy()
del response['pm_password']
self.mox.StubOutWithMock(db, 'bm_node_get')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
db.bm_node_get(self.context, node['id']).AndReturn(node)
db.bm_interface_get_all_by_bm_node_id(self.context, node['id']).\
AndReturn(interfaces)
self.ext_mgr.is_loaded('os-baremetal-ext-status').AndReturn(ext_status)
self.mox.ReplayAll()
res_dict = self.controller.show(self.request, node['id'])
self.assertEqual({'node': response}, res_dict)
self.assertEqual(2, len(res_dict['node']['interfaces']))
def _test_show_no_interfaces(self, ext_status=False):
node_id = 1
node = {'id': node_id}
self.mox.StubOutWithMock(db, 'bm_node_get')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
db.bm_node_get(self.context, node_id).AndReturn(node)
db.bm_interface_get_all_by_bm_node_id(self.context, node_id).\
AndRaise(exception.NodeNotFound(node_id=node_id))
self.ext_mgr.is_loaded('os-baremetal-ext-status').AndReturn(ext_status)
self.mox.ReplayAll()
res_dict = self.controller.show(self.request, node_id)
self.assertEqual(node_id, res_dict['node']['id'])
self.assertEqual(0, len(res_dict['node']['interfaces']))
def _test_index(self, ext_status=False):
nodes = [{'id': 1},
{'id': 2},
]
interfaces = [{'id': 1, 'address': '11:11:11:11:11:11'},
{'id': 2, 'address': '22:22:22:22:22:22'},
]
self.mox.StubOutWithMock(db, 'bm_node_get_all')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
db.bm_node_get_all(self.context).AndReturn(nodes)
db.bm_interface_get_all_by_bm_node_id(self.context, 1).\
AndRaise(exception.NodeNotFound(node_id=1))
for n in nodes:
self.ext_mgr.is_loaded('os-baremetal-ext-status').\
AndReturn(ext_status)
db.bm_interface_get_all_by_bm_node_id(self.context, 2).\
AndReturn(interfaces)
self.mox.ReplayAll()
res_dict = self.controller.index(self.request)
self.assertEqual(2, len(res_dict['nodes']))
self.assertEqual([], res_dict['nodes'][0]['interfaces'])
self.assertEqual(2, len(res_dict['nodes'][1]['interfaces']))
def test_create(self):
node = fake_node(id=100)
self._test_create(node)
def test_create_ext_status(self):
node = fake_node_ext_status(id=100)
self._test_create(node, ext_status=True)
def test_delete(self):
self.mox.StubOutWithMock(db, 'bm_node_destroy')
db.bm_node_destroy(self.context, 1)
@ -77,53 +172,24 @@ class BareMetalNodesTest(test.NoDBTestCase):
1)
def test_index(self):
nodes = [{'id': 1},
{'id': 2},
]
interfaces = [{'id': 1, 'address': '11:11:11:11:11:11'},
{'id': 2, 'address': '22:22:22:22:22:22'},
]
self.mox.StubOutWithMock(db, 'bm_node_get_all')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
db.bm_node_get_all(self.context).AndReturn(nodes)
db.bm_interface_get_all_by_bm_node_id(self.context, 1).\
AndRaise(exception.NodeNotFound(node_id=1))
db.bm_interface_get_all_by_bm_node_id(self.context, 2).\
AndReturn(interfaces)
self.mox.ReplayAll()
res_dict = self.controller.index(self.request)
self.assertEqual(2, len(res_dict['nodes']))
self.assertEqual([], res_dict['nodes'][0]['interfaces'])
self.assertEqual(2, len(res_dict['nodes'][1]['interfaces']))
self._test_index()
def test_index_ext_status(self):
self._test_index(ext_status=True)
def test_show(self):
node_id = 1
node = {'id': node_id}
interfaces = [{'id': 1, 'address': '11:11:11:11:11:11'},
{'id': 2, 'address': '22:22:22:22:22:22'},
]
self.mox.StubOutWithMock(db, 'bm_node_get')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
db.bm_node_get(self.context, node_id).AndReturn(node)
db.bm_interface_get_all_by_bm_node_id(self.context, node_id).\
AndReturn(interfaces)
self.mox.ReplayAll()
res_dict = self.controller.show(self.request, node_id)
self.assertEqual(node_id, res_dict['node']['id'])
self.assertEqual(2, len(res_dict['node']['interfaces']))
node = fake_node(id=1)
self._test_show(node)
def test_show_ext_status(self):
node = fake_node_ext_status(id=1)
self._test_show(node, ext_status=True)
def test_show_no_interfaces(self):
node_id = 1
node = {'id': node_id}
self.mox.StubOutWithMock(db, 'bm_node_get')
self.mox.StubOutWithMock(db, 'bm_interface_get_all_by_bm_node_id')
db.bm_node_get(self.context, node_id).AndReturn(node)
db.bm_interface_get_all_by_bm_node_id(self.context, node_id).\
AndRaise(exception.NodeNotFound(node_id=node_id))
self.mox.ReplayAll()
res_dict = self.controller.show(self.request, node_id)
self.assertEqual(node_id, res_dict['node']['id'])
self.assertEqual(0, len(res_dict['node']['interfaces']))
self._test_show_no_interfaces()
def test_show_no_interfaces_ext_status(self):
self._test_show_no_interfaces(ext_status=True)
def test_add_interface(self):
node_id = 1

View File

@ -615,6 +615,14 @@
"name": "Migrations",
"namespace": "http://docs.openstack.org/compute/ext/migrations/api/v2.0",
"updated": "%(timestamp)s"
},
{
"alias": "os-baremetal-ext-status",
"description": "%(text)s",
"links": [],
"name": "BareMetalExtStatus",
"namespace": "http://docs.openstack.org/compute/ext/baremetal_ext_status/api/v2",
"updated": "%(timestamp)s"
}
]
}

View File

@ -231,4 +231,6 @@
<extension alias="os-assisted-volume-snapshots" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/assisted-volume-snapshots/api/v2" name="AssistedVolumeSnapshots">
<description>%(text)s</description>
</extension>
<extension alias="os-baremetal-ext-status" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/baremetal_ext_status/api/v2" name="BareMetalExtStatus"> <description>%(text)s</description>
</extension>
</extensions>

View File

@ -0,0 +1,5 @@
{
"add_interface": {
"address": "%(address)s"
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<add_interface
address="%(address)s"
/>

View File

@ -0,0 +1,8 @@
{
"interface": {
"id": %(interface_id)s,
"address": "aa:aa:aa:aa:aa:aa",
"datapath_id": null,
"port_no": null
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface
id="%(interface_id)s"
address="aa:aa:aa:aa:aa:aa"
datapath_id="None"
port_no="None"
/>

View File

@ -0,0 +1,12 @@
{
"node": {
"service_host": "host",
"cpus": 8,
"memory_mb": 8192,
"local_gb": 128,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pm_password": "pm_pass",
"terminal_port": 8000
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<node
service_host="host"
cpus="8"
memory_mb="8192"
local_gb="128"
pm_address="10.1.2.3"
pm_user="pm_user"
terminal_port="8000"
/>

View File

@ -0,0 +1,18 @@
{
"node": {
"cpus": 8,
"id": %(node_id)s,
"instance_uuid": null,
"interfaces": [],
"local_gb": 128,
"memory_mb": 8192,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pxe_config_path": null,
"service_host": "host",
"task_state": null,
"terminal_port": 8000,
"updated_at": null,
"uuid": "%(node_uuid)s"
}
}

View File

@ -0,0 +1,4 @@
<?xml version='1.0' encoding='UTF-8'?>
<node instance_uuid="None" pm_address="10.1.2.3" task_state="None" uuid="%(node_uuid)s" pxe_config_path="None" cpus="8" updated_at="None" memory_mb="8192" service_host="host" local_gb="128" id="%(node_id)s" pm_user="pm_user" terminal_port="8000">
<interfaces/>
</node>

View File

@ -0,0 +1,13 @@
{
"node": {
"service_host": "host",
"cpus": 8,
"memory_mb": 8192,
"local_gb": 128,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pm_password": "pm_pass",
"prov_mac_address": "%(address)s",
"terminal_port": 8000
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<node
service_host="host"
cpus="8"
memory_mb="8192"
local_gb="128"
pm_address="10.1.2.3"
pm_user="pm_user"
prov_mac_address="%(address)s"
terminal_port="8000"
/>

View File

@ -0,0 +1,25 @@
{
"node": {
"cpus": 8,
"id": %(node_id)s,
"instance_uuid": null,
"interfaces": [
{
"address": "%(address)s",
"datapath_id": null,
"id": %(interface_id)s,
"port_no": null
}
],
"local_gb": 128,
"memory_mb": 8192,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pxe_config_path": null,
"service_host": "host",
"task_state": null,
"terminal_port": 8000,
"updated_at": null,
"uuid": "%(node_uuid)s"
}
}

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<node instance_uuid="None" pm_address="10.1.2.3" task_state="None" uuid="%(node_uuid)s" pxe_config_path="None" cpus="8" updated_at="None" memory_mb="8192" service_host="host" local_gb="128" id="%(node_id)s" pm_user="pm_user" terminal_port="8000">
<interfaces>
<interface datapath_id="None" id="%(interface_id)s" port_no="None" address="%(address)s"/>
</interfaces>
</node>

View File

@ -0,0 +1,27 @@
{
"nodes": [
{
"cpus": 8,
"id": %(node_id)s,
"instance_uuid": null,
"interfaces": [
{
"address": "%(address)s",
"datapath_id": null,
"id": %(interface_id)s,
"port_no": null
}
],
"local_gb": 128,
"memory_mb": 8192,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pxe_config_path": null,
"service_host": "host",
"task_state": null,
"terminal_port": 8000,
"updated_at": null,
"uuid": "%(node_uuid)s"
}
]
}

View File

@ -0,0 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?>
<nodes>
<node instance_uuid="None" pm_address="10.1.2.3" task_state="None" uuid="%(node_uuid)s" pxe_config_path="None" cpus="8" updated_at="None" memory_mb="8192" service_host="host" local_gb="128" id="%(node_id)s" pm_user="pm_user" terminal_port="8000">
<interfaces>
<interface datapath_id="None" id="%(interface_id)s" port_no="None" address="%(address)s"/>
</interfaces>
</node>
</nodes>

View File

@ -0,0 +1,5 @@
{
"remove_interface": {
"address": "%(address)s"
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<remove_interface
address="%(address)s"
/>

View File

@ -0,0 +1,25 @@
{
"node": {
"cpus": 8,
"id": %(node_id)s,
"instance_uuid": null,
"interfaces": [
{
"address": "%(address)s",
"datapath_id": null,
"id": %(interface_id)s,
"port_no": null
}
],
"local_gb": 128,
"memory_mb": 8192,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"pxe_config_path": null,
"service_host": "host",
"task_state": null,
"terminal_port": 8000,
"updated_at": null,
"uuid": "%(node_uuid)s"
}
}

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<node instance_uuid="None" pm_address="10.1.2.3" task_state="None" uuid="%(node_uuid)s" pxe_config_path="None" cpus="8" updated_at="None" memory_mb="8192" service_host="host" local_gb="128" id="%(node_id)s" pm_user="pm_user" terminal_port="8000">
<interfaces>
<interface datapath_id="None" id="%(interface_id)s" port_no="None" address="%(address)s"/>
</interfaces>
</node>

View File

@ -2766,11 +2766,16 @@ class BareMetalNodesJsonTest(ApiSampleTestBaseV2, bm_db_base.BMDBTestCase):
extension_name = ('nova.api.openstack.compute.contrib.baremetal_nodes.'
'Baremetal_nodes')
def _get_subs(self):
subs = {}
return subs
def _create_node(self):
response = self._do_post("os-baremetal-nodes",
"baremetal-node-create-req",
{})
subs = {'node_id': '(?P<id>\d+)'}
subs = self._get_subs()
subs.update({'node_id': '(?P<id>\d+)'})
return self._verify_response("baremetal-node-create-resp", subs,
response, 200)
@ -2780,9 +2785,11 @@ class BareMetalNodesJsonTest(ApiSampleTestBaseV2, bm_db_base.BMDBTestCase):
response = self._do_post("os-baremetal-nodes",
"baremetal-node-create-with-address-req",
req_subs)
subs = {'node_id': '(?P<id>\d+)',
'interface_id': '\d+',
'address': address}
subs = self._get_subs()
subs.update({'node_id': '(?P<id>\d+)',
'interface_id': '\d+',
'address': address,
})
self._verify_response("baremetal-node-create-with-address-resp",
subs, response, 200)
@ -2796,10 +2803,11 @@ class BareMetalNodesJsonTest(ApiSampleTestBaseV2, bm_db_base.BMDBTestCase):
node_id = self._create_node()
interface_id = self._add_interface(node_id)
response = self._do_get('os-baremetal-nodes')
subs = {'node_id': node_id,
'interface_id': interface_id,
'address': 'aa:aa:aa:aa:aa:aa',
}
subs = self._get_subs()
subs.update({'node_id': node_id,
'interface_id': interface_id,
'address': 'aa:aa:aa:aa:aa:aa',
})
self._verify_response('baremetal-node-list-resp', subs,
response, 200)
@ -2807,10 +2815,11 @@ class BareMetalNodesJsonTest(ApiSampleTestBaseV2, bm_db_base.BMDBTestCase):
node_id = self._create_node()
interface_id = self._add_interface(node_id)
response = self._do_get('os-baremetal-nodes/%s' % node_id)
subs = {'node_id': node_id,
'interface_id': interface_id,
'address': 'aa:aa:aa:aa:aa:aa',
}
subs = self._get_subs()
subs.update({'node_id': node_id,
'interface_id': interface_id,
'address': 'aa:aa:aa:aa:aa:aa',
})
self._verify_response('baremetal-node-show-resp', subs, response, 200)
def test_delete_node(self):
@ -2844,6 +2853,29 @@ class BareMetalNodesXmlTest(BareMetalNodesJsonTest):
ctype = 'xml'
class BareMetalExtStatusJsonTest(BareMetalNodesJsonTest):
extension_name = ('nova.api.openstack.compute.contrib.'
'baremetal_ext_status.Baremetal_ext_status')
def _get_flags(self):
f = super(BareMetalExtStatusJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
# BareMetalExtStatus extension also needs BareMetalNodes to be loaded.
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.baremetal_nodes.'
'Baremetal_nodes')
return f
def _get_subs(self):
vanilla_regexes = self._get_regexes()
subs = {'node_uuid': vanilla_regexes['uuid']}
return subs
class BareMetalExtStatusXmlTest(BareMetalExtStatusJsonTest):
ctype = 'xml'
class BlockDeviceMappingV2BootJsonTest(ServersSampleBase):
extension_name = ('nova.api.openstack.compute.contrib.'
'block_device_mapping_v2_boot.'