From 64a0bcae5aacff2bf2445ab519b837b4e01cce60 Mon Sep 17 00:00:00 2001 From: Arata Notsu Date: Wed, 3 Apr 2013 19:31:09 +0900 Subject: 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 --- nova/api/openstack/compute/contrib/baremetal_nodes.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'nova/api') 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): -- cgit