baremetal: Change node api related to prov_mac_address
Now prov_mac_address is going to be dropped from bm_nodes table. This patch adjust api to the change. A user is expected to create a node without specifying prov_mac_address, then add an interface having the address to the node. However, for compatibility, a user still can specify prov_mac_address when create a node. In this case, an interface having prov_mac_address is automatically added to the node. In response body of create, index and show, "prov_mac_address" field no longer exists since they are showed as a member of "interfaces" fileld. DocImpact Change-Id: I6653829364b0a641442d45e766493180d6f2a880
This commit is contained in:
parent
6b2af9c084
commit
64a0bcae5a
@ -7,7 +7,6 @@
|
|||||||
"pm_address": "10.1.2.3",
|
"pm_address": "10.1.2.3",
|
||||||
"pm_user": "pm_user",
|
"pm_user": "pm_user",
|
||||||
"pm_password": "pm_pass",
|
"pm_password": "pm_pass",
|
||||||
"prov_mac_address": "12:34:56:78:90:ab",
|
|
||||||
"terminal_port": 8000
|
"terminal_port": 8000
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,5 @@
|
|||||||
local_gb="128"
|
local_gb="128"
|
||||||
pm_address="10.1.2.3"
|
pm_address="10.1.2.3"
|
||||||
pm_user="pm_user"
|
pm_user="pm_user"
|
||||||
prov_mac_address="12:34:56:78:90:ab"
|
|
||||||
terminal_port="8000"
|
terminal_port="8000"
|
||||||
/>
|
/>
|
@ -8,7 +8,6 @@
|
|||||||
"memory_mb": 8192,
|
"memory_mb": 8192,
|
||||||
"pm_address": "10.1.2.3",
|
"pm_address": "10.1.2.3",
|
||||||
"pm_user": "pm_user",
|
"pm_user": "pm_user",
|
||||||
"prov_mac_address": "12:34:56:78:90:ab",
|
|
||||||
"service_host": "host",
|
"service_host": "host",
|
||||||
"terminal_port": 8000
|
"terminal_port": 8000
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
pm_address="10.1.2.3"
|
pm_address="10.1.2.3"
|
||||||
cpus="8"
|
cpus="8"
|
||||||
memory_mb="8192"
|
memory_mb="8192"
|
||||||
prov_mac_address="12:34:56:78:90:ab"
|
|
||||||
service_host="host"
|
service_host="host"
|
||||||
local_gb="128"
|
local_gb="128"
|
||||||
id="1"
|
id="1"
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -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"
|
||||||
|
/>
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"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",
|
||||||
|
"service_host": "host",
|
||||||
|
"terminal_port": 8000
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<node
|
||||||
|
instance_uuid="None"
|
||||||
|
pm_address="10.1.2.3"
|
||||||
|
cpus="8"
|
||||||
|
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>
|
@ -16,7 +16,6 @@
|
|||||||
"memory_mb": 8192,
|
"memory_mb": 8192,
|
||||||
"pm_address": "10.1.2.3",
|
"pm_address": "10.1.2.3",
|
||||||
"pm_user": "pm_user",
|
"pm_user": "pm_user",
|
||||||
"prov_mac_address": "12:34:56:78:90:ab",
|
|
||||||
"service_host": "host",
|
"service_host": "host",
|
||||||
"terminal_port": 8000
|
"terminal_port": 8000
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
pm_address="10.1.2.3"
|
pm_address="10.1.2.3"
|
||||||
cpus="8"
|
cpus="8"
|
||||||
memory_mb="8192"
|
memory_mb="8192"
|
||||||
prov_mac_address="12:34:56:78:90:ab"
|
|
||||||
service_host="host"
|
service_host="host"
|
||||||
local_gb="128"
|
local_gb="128"
|
||||||
id="1"
|
id="1"
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"memory_mb": 8192,
|
"memory_mb": 8192,
|
||||||
"pm_address": "10.1.2.3",
|
"pm_address": "10.1.2.3",
|
||||||
"pm_user": "pm_user",
|
"pm_user": "pm_user",
|
||||||
"prov_mac_address": "12:34:56:78:90:ab",
|
|
||||||
"service_host": "host",
|
"service_host": "host",
|
||||||
"terminal_port": 8000
|
"terminal_port": 8000
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
pm_address="10.1.2.3"
|
pm_address="10.1.2.3"
|
||||||
cpus="8"
|
cpus="8"
|
||||||
memory_mb="8192"
|
memory_mb="8192"
|
||||||
prov_mac_address="12:34:56:78:90:ab"
|
|
||||||
service_host="host"
|
service_host="host"
|
||||||
local_gb="128"
|
local_gb="128"
|
||||||
id="1"
|
id="1"
|
||||||
|
@ -26,7 +26,7 @@ from nova.virt.baremetal import db
|
|||||||
authorize = extensions.extension_authorizer('compute', 'baremetal_nodes')
|
authorize = extensions.extension_authorizer('compute', 'baremetal_nodes')
|
||||||
|
|
||||||
node_fields = ['id', 'cpus', 'local_gb', 'memory_mb', 'pm_address',
|
node_fields = ['id', 'cpus', 'local_gb', 'memory_mb', 'pm_address',
|
||||||
'pm_user', 'prov_mac_address',
|
'pm_user',
|
||||||
'service_host', 'terminal_port', 'instance_uuid',
|
'service_host', 'terminal_port', 'instance_uuid',
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -129,9 +129,21 @@ class BareMetalNodeController(wsgi.Controller):
|
|||||||
def create(self, req, body):
|
def create(self, req, body):
|
||||||
context = req.environ['nova.context']
|
context = req.environ['nova.context']
|
||||||
authorize(context)
|
authorize(context)
|
||||||
node = db.bm_node_create(context, body['node'])
|
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 = _node_dict(node)
|
||||||
node['interfaces'] = []
|
if prov_mac_address:
|
||||||
|
if_id = db.bm_interface_create(context,
|
||||||
|
bm_node_id=node['id'],
|
||||||
|
address=prov_mac_address,
|
||||||
|
datapath_id=None,
|
||||||
|
port_no=None)
|
||||||
|
if_ref = db.bm_interface_get(context, if_id)
|
||||||
|
node['interfaces'] = [_interface_dict(if_ref)]
|
||||||
|
else:
|
||||||
|
node['interfaces'] = []
|
||||||
|
print node
|
||||||
return {'node': node}
|
return {'node': node}
|
||||||
|
|
||||||
def delete(self, req, id):
|
def delete(self, req, id):
|
||||||
|
@ -46,7 +46,6 @@ class BareMetalNodesTest(test.TestCase):
|
|||||||
'pm_address': "10.1.2.3",
|
'pm_address': "10.1.2.3",
|
||||||
'pm_user': "pm_user",
|
'pm_user': "pm_user",
|
||||||
'pm_password': "pm_pass",
|
'pm_password': "pm_pass",
|
||||||
'prov_mac_address': "12:34:56:78:90:ab",
|
|
||||||
'terminal_port': 8000,
|
'terminal_port': 8000,
|
||||||
'interfaces': [],
|
'interfaces': [],
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
"pm_address": "10.1.2.3",
|
"pm_address": "10.1.2.3",
|
||||||
"pm_user": "pm_user",
|
"pm_user": "pm_user",
|
||||||
"pm_password": "pm_pass",
|
"pm_password": "pm_pass",
|
||||||
"prov_mac_address": "12:34:56:78:90:ab",
|
|
||||||
"terminal_port": 8000
|
"terminal_port": 8000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,5 @@
|
|||||||
local_gb="128"
|
local_gb="128"
|
||||||
pm_address="10.1.2.3"
|
pm_address="10.1.2.3"
|
||||||
pm_user="pm_user"
|
pm_user="pm_user"
|
||||||
prov_mac_address="12:34:56:78:90:ab"
|
|
||||||
terminal_port="8000"
|
terminal_port="8000"
|
||||||
/>
|
/>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
"local_gb": 128,
|
"local_gb": 128,
|
||||||
"pm_address": "10.1.2.3",
|
"pm_address": "10.1.2.3",
|
||||||
"pm_user": "pm_user",
|
"pm_user": "pm_user",
|
||||||
"prov_mac_address": "12:34:56:78:90:ab",
|
|
||||||
"terminal_port": 8000,
|
"terminal_port": 8000,
|
||||||
"instance_uuid": null,
|
"instance_uuid": null,
|
||||||
"id": %(node_id)s,
|
"id": %(node_id)s,
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
local_gb="128"
|
local_gb="128"
|
||||||
pm_address="10.1.2.3"
|
pm_address="10.1.2.3"
|
||||||
pm_user="pm_user"
|
pm_user="pm_user"
|
||||||
prov_mac_address="12:34:56:78:90:ab"
|
|
||||||
terminal_port="8000"
|
terminal_port="8000"
|
||||||
instance_uuid="None"
|
instance_uuid="None"
|
||||||
id="%(node_id)s">
|
id="%(node_id)s">
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -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"
|
||||||
|
/>
|
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"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,
|
||||||
|
"instance_uuid": null,
|
||||||
|
"id": %(node_id)s,
|
||||||
|
"interfaces": [{
|
||||||
|
"id": %(interface_id)s,
|
||||||
|
"address": "%(address)s",
|
||||||
|
"datapath_id": null,
|
||||||
|
"port_no": null
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?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"
|
||||||
|
instance_uuid="None"
|
||||||
|
id="%(node_id)s">
|
||||||
|
<interfaces>
|
||||||
|
<interface
|
||||||
|
id="%(interface_id)s"
|
||||||
|
address="%(address)s"
|
||||||
|
datapath_id="None"
|
||||||
|
port_no="None"/>
|
||||||
|
</interfaces>
|
||||||
|
</node>
|
@ -6,7 +6,6 @@
|
|||||||
"local_gb": 128,
|
"local_gb": 128,
|
||||||
"pm_address": "10.1.2.3",
|
"pm_address": "10.1.2.3",
|
||||||
"pm_user": "pm_user",
|
"pm_user": "pm_user",
|
||||||
"prov_mac_address": "12:34:56:78:90:ab",
|
|
||||||
"terminal_port": 8000,
|
"terminal_port": 8000,
|
||||||
"instance_uuid": null,
|
"instance_uuid": null,
|
||||||
"id": %(node_id)s,
|
"id": %(node_id)s,
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
local_gb="128"
|
local_gb="128"
|
||||||
pm_address="10.1.2.3"
|
pm_address="10.1.2.3"
|
||||||
pm_user="pm_user"
|
pm_user="pm_user"
|
||||||
prov_mac_address="12:34:56:78:90:ab"
|
|
||||||
terminal_port="8000"
|
terminal_port="8000"
|
||||||
instance_uuid="None"
|
instance_uuid="None"
|
||||||
id="%(node_id)s">
|
id="%(node_id)s">
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
"local_gb": 128,
|
"local_gb": 128,
|
||||||
"pm_address": "10.1.2.3",
|
"pm_address": "10.1.2.3",
|
||||||
"pm_user": "pm_user",
|
"pm_user": "pm_user",
|
||||||
"prov_mac_address": "12:34:56:78:90:ab",
|
|
||||||
"terminal_port": 8000,
|
"terminal_port": 8000,
|
||||||
"instance_uuid": null,
|
"instance_uuid": null,
|
||||||
"id": %(node_id)s,
|
"id": %(node_id)s,
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
local_gb="128"
|
local_gb="128"
|
||||||
pm_address="10.1.2.3"
|
pm_address="10.1.2.3"
|
||||||
pm_user="pm_user"
|
pm_user="pm_user"
|
||||||
prov_mac_address="12:34:56:78:90:ab"
|
|
||||||
terminal_port="8000"
|
terminal_port="8000"
|
||||||
instance_uuid="None"
|
instance_uuid="None"
|
||||||
id="%(node_id)s">
|
id="%(node_id)s">
|
||||||
|
@ -2782,9 +2782,24 @@ class BareMetalNodesJsonTest(ApiSampleTestBase, bm_db_base.BMDBTestCase):
|
|||||||
return self._verify_response("baremetal-node-create-resp", subs,
|
return self._verify_response("baremetal-node-create-resp", subs,
|
||||||
response, 200)
|
response, 200)
|
||||||
|
|
||||||
|
def _create_node_with_address(self):
|
||||||
|
address = '12:34:56:78:90:ab'
|
||||||
|
req_subs = {'address': address}
|
||||||
|
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}
|
||||||
|
return self._verify_response("baremetal-node-create-with-address-resp",
|
||||||
|
subs, response, 200)
|
||||||
|
|
||||||
def test_create_node(self):
|
def test_create_node(self):
|
||||||
self._create_node()
|
self._create_node()
|
||||||
|
|
||||||
|
def test_create_node_with_address(self):
|
||||||
|
self._create_node_with_address()
|
||||||
|
|
||||||
def test_list_nodes(self):
|
def test_list_nodes(self):
|
||||||
node_id = self._create_node()
|
node_id = self._create_node()
|
||||||
interface_id = self._add_interface(node_id)
|
interface_id = self._add_interface(node_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user