summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorArata Notsu <notsu@virtualtech.jp>2013-04-03 19:31:09 +0900
committerArata Notsu <notsu@virtualtech.jp>2013-04-11 16:31:11 +0900
commit64a0bcae5aacff2bf2445ab519b837b4e01cce60 (patch)
tree243170bab11e611acaac302b034387360a7fe491 /nova/api
parent6b2af9c084754a1e678f741bfc6b97e13f1cf8a5 (diff)
downloadnova-64a0bcae5aacff2bf2445ab519b837b4e01cce60.tar.gz
nova-64a0bcae5aacff2bf2445ab519b837b4e01cce60.tar.xz
nova-64a0bcae5aacff2bf2445ab519b837b4e01cce60.zip
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
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/baremetal_nodes.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/nova/api/openstack/compute/contrib/baremetal_nodes.py b/nova/api/openstack/compute/contrib/baremetal_nodes.py
index b3f226039..f69db50f0 100644
--- a/nova/api/openstack/compute/contrib/baremetal_nodes.py
+++ b/nova/api/openstack/compute/contrib/baremetal_nodes.py
@@ -26,7 +26,7 @@ from nova.virt.baremetal import db
authorize = extensions.extension_authorizer('compute', 'baremetal_nodes')
node_fields = ['id', 'cpus', 'local_gb', 'memory_mb', 'pm_address',
- 'pm_user', 'prov_mac_address',
+ 'pm_user',
'service_host', 'terminal_port', 'instance_uuid',
]
@@ -129,9 +129,21 @@ class BareMetalNodeController(wsgi.Controller):
def create(self, req, body):
context = req.environ['nova.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['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}
def delete(self, req, id):