baremetal: Integrate provisioning and non-provisioning interfaces
Originally, baremetal pxe/tilera driver managed two types of network interfaces in two tables; provisioning interfaces in bm_nodes table and non-provisioning (normal) interfaces in bm_interfaces table. But, now actually both types are handled in the same way and there is no difference between them except for which table they are in. This patch moves the provisioning interfaces to bm_interfaces. However it does not drop prov_mac_address in bm_nodes since VirtualPowerManager still uses it to identify a target in a list of VMs returned by the VM's host. Change-Id: I5ce940e7127aa3b29ba7802612938dc5dbc3152f
This commit is contained in:
parent
c2e75cad16
commit
f5d9ded9c4
@ -314,7 +314,6 @@ class PXEPrivateMethodsTestCase(BareMetalPXETestCase):
|
||||
def test_collect_mac_addresses(self):
|
||||
self._create_node()
|
||||
address_list = [nic['address'] for nic in self.nic_info]
|
||||
address_list.append(self.node_info['prov_mac_address'])
|
||||
address_list.sort()
|
||||
macs = self.driver._collect_mac_addresses(self.context, self.node)
|
||||
self.assertEqual(macs, address_list)
|
||||
@ -432,7 +431,6 @@ class PXEPublicMethodsTestCase(BareMetalPXETestCase):
|
||||
def test_activate_bootloader_passes_details(self):
|
||||
self._create_node()
|
||||
macs = [nic['address'] for nic in self.nic_info]
|
||||
macs.append(self.node_info['prov_mac_address'])
|
||||
macs.sort()
|
||||
image_info = {
|
||||
'deploy_kernel': [None, 'aaaa'],
|
||||
@ -496,16 +494,16 @@ class PXEPublicMethodsTestCase(BareMetalPXETestCase):
|
||||
# create the config file
|
||||
bm_utils.write_to_file(mox.StrContains('fake-uuid'),
|
||||
mox.StrContains(CONF.baremetal.tftp_root))
|
||||
# unlink and link the 3 interfaces
|
||||
for i in range(3):
|
||||
# unlink and link the 2 interfaces
|
||||
for i in range(2):
|
||||
bm_utils.unlink_without_raise(mox.Or(
|
||||
mox.StrContains('fake-uuid'),
|
||||
mox.StrContains(CONF.baremetal.tftp_root)))
|
||||
bm_utils.create_link_without_raise(
|
||||
mox.StrContains('fake-uuid'),
|
||||
mox.StrContains(CONF.baremetal.tftp_root))
|
||||
# unlink all 3 interfaces, 4 images, and the config file
|
||||
for i in range(8):
|
||||
# unlink all 2 interfaces, 4 images, and the config file
|
||||
for i in range(7):
|
||||
bm_utils.unlink_without_raise(mox.Or(
|
||||
mox.StrContains('fake-uuid'),
|
||||
mox.StrContains(CONF.baremetal.tftp_root)))
|
||||
|
@ -195,7 +195,6 @@ class TileraPrivateMethodsTestCase(BareMetalTileraTestCase):
|
||||
def test_collect_mac_addresses(self):
|
||||
self._create_node()
|
||||
address_list = [nic['address'] for nic in self.nic_info]
|
||||
address_list.append(self.node_info['prov_mac_address'])
|
||||
address_list.sort()
|
||||
macs = self.driver._collect_mac_addresses(self.context, self.node)
|
||||
self.assertEqual(macs, address_list)
|
||||
@ -301,9 +300,6 @@ class TileraPublicMethodsTestCase(BareMetalTileraTestCase):
|
||||
|
||||
def test_activate_bootloader_passes_details(self):
|
||||
self._create_node()
|
||||
macs = [nic['address'] for nic in self.nic_info]
|
||||
macs.append(self.node_info['prov_mac_address'])
|
||||
macs.sort()
|
||||
image_info = {
|
||||
'kernel': [None, 'cccc'],
|
||||
}
|
||||
|
@ -0,0 +1,84 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2013 NTT DOCOMO, INC.
|
||||
#
|
||||
# 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.openstack.common import log as logging
|
||||
from sqlalchemy import and_, MetaData, select, Table, exists
|
||||
from sqlalchemy import exc
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
nodes = Table('bm_nodes', meta, autoload=True)
|
||||
ifs = Table('bm_interfaces', meta, autoload=True)
|
||||
|
||||
q = select([nodes.c.id, nodes.c.prov_mac_address],
|
||||
from_obj=nodes)
|
||||
|
||||
# Iterate all elements before starting insert since IntegrityError
|
||||
# may disturb the iteration.
|
||||
node_address = {}
|
||||
for node_id, address in q.execute():
|
||||
node_address[node_id] = address
|
||||
|
||||
i = ifs.insert()
|
||||
for node_id, address in node_address.iteritems():
|
||||
try:
|
||||
i.execute({'bm_node_id': node_id, 'address': address})
|
||||
except exc.IntegrityError:
|
||||
# The address is registered in both bm_nodes and bm_interfaces.
|
||||
# It is expected.
|
||||
pass
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
nodes = Table('bm_nodes', meta, autoload=True)
|
||||
ifs = Table('bm_interfaces', meta, autoload=True)
|
||||
|
||||
subq = exists().where(and_(ifs.c.bm_node_id == nodes.c.id,
|
||||
ifs.c.address == nodes.c.prov_mac_address))
|
||||
|
||||
ifs.delete().where(subq).execute()
|
||||
|
||||
# NOTE(arata):
|
||||
# In fact, this downgrade may not return the db to the previous state.
|
||||
# It seems to be not so match a problem, so this is just for memo.
|
||||
#
|
||||
# Think these two state before upgrading:
|
||||
#
|
||||
# (A) address 'x' is duplicate
|
||||
# bm_nodes.prov_mac_address='x'
|
||||
# bm_interfaces.address=['x', 'y']
|
||||
#
|
||||
# (B) no address is duplicate
|
||||
# bm_nodes.prov_mac_address='x'
|
||||
# bm_interfaces.address=['y']
|
||||
#
|
||||
# Upgrading them results in the same state:
|
||||
#
|
||||
# bm_nodes.prov_mac_address='x'
|
||||
# bm_interfaces.address=['x', 'y']
|
||||
#
|
||||
# Downgrading this results in B, even if the actual initial status was A
|
||||
# Of course we can change it to downgrade to B, but then we cannot
|
||||
# downgrade to A; it is an exclusive choice since we do not have
|
||||
# information about the initial state.
|
@ -242,7 +242,6 @@ class PXE(base.NodeDriver):
|
||||
|
||||
def _collect_mac_addresses(self, context, node):
|
||||
macs = set()
|
||||
macs.add(db.bm_node_get(context, node['id'])['prov_mac_address'])
|
||||
for nic in db.bm_interface_get_all_by_bm_node_id(context, node['id']):
|
||||
if nic['address']:
|
||||
macs.add(nic['address'])
|
||||
|
@ -166,7 +166,6 @@ class Tilera(base.NodeDriver):
|
||||
|
||||
def _collect_mac_addresses(self, context, node):
|
||||
macs = set()
|
||||
macs.add(db.bm_node_get(context, node['id'])['prov_mac_address'])
|
||||
for nic in db.bm_interface_get_all_by_bm_node_id(context, node['id']):
|
||||
if nic['address']:
|
||||
macs.add(nic['address'])
|
||||
|
Loading…
Reference in New Issue
Block a user