baremetal: VirtualPowerDriver uses mac addresses in bm_interfaces
After the change I6653829364b0a641442d45e766493180d6f2a880, bm_nodes.prov_mac_address is no longer set. However VPD still uses it. This patch changes VPD to use bm_interfaces.address instead of bm_nodes.prov_mac_address. Fixes bug 1168574. Change-Id: I2bab869b282958ee9fd0e4776928e56351018324
This commit is contained in:
parent
f3a0117ecd
commit
4c82958f3d
|
@ -71,12 +71,12 @@ class BareMetalVPDTestCase(bm_db_base.BMDBTestCase):
|
|||
service_host='test_host',
|
||||
cpus=2,
|
||||
memory_mb=2048,
|
||||
prov_mac_address='11:11:11:11:11:11',
|
||||
prov_mac_address='aa:bb:cc:dd:ee:ff',
|
||||
)
|
||||
self.nic_info = [
|
||||
{'address': '22:22:22:22:22:22', 'datapath_id': '0x1',
|
||||
{'address': '11:11:11:11:11:11', 'datapath_id': '0x1',
|
||||
'port_no': 1},
|
||||
{'address': '33:33:33:33:33:33', 'datapath_id': '0x2',
|
||||
{'address': '22:22:22:22:22:22', 'datapath_id': '0x2',
|
||||
'port_no': 2},
|
||||
]
|
||||
self.addCleanup(fake_image.FakeImageService_reset)
|
||||
|
@ -200,6 +200,8 @@ class VPDClassMethodsTestCase(BareMetalVPDTestCase):
|
|||
|
||||
self.mox.StubOutWithMock(self.pm, '_run_command')
|
||||
cmd = self.pm._vp_cmd.get_node_macs.replace('{_NodeName_}', 'testNode')
|
||||
# aa:bb:cc:dd:ee:ff is prov_mac_adress. Check it is not used to
|
||||
# find the node.
|
||||
self.pm._run_command(cmd).AndReturn(["aabbccddeeff", "ffeeddccbbaa"])
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
|
|
@ -19,12 +19,14 @@
|
|||
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova import context as nova_context
|
||||
from nova import exception
|
||||
from nova.openstack.common import importutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import utils
|
||||
from nova.virt.baremetal import baremetal_states
|
||||
from nova.virt.baremetal import base
|
||||
from nova.virt.baremetal import db
|
||||
import nova.virt.powervm.common as connection
|
||||
|
||||
opts = [
|
||||
|
@ -64,6 +66,10 @@ _cmds = None
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _normalize_mac(mac):
|
||||
return mac.replace(':', '').lower()
|
||||
|
||||
|
||||
class VirtualPowerManager(base.PowerManager):
|
||||
"""Virtual Power Driver for Baremetal Nova Compute
|
||||
|
||||
|
@ -92,8 +98,9 @@ class VirtualPowerManager(base.PowerManager):
|
|||
node = kwargs.pop('node', {})
|
||||
instance = kwargs.pop('instance', {})
|
||||
self._node_name = instance.get('hostname', "")
|
||||
self._mac_address = node.get('prov_mac_address', "")
|
||||
self._mac_address = self._mac_address.replace(':', '')
|
||||
context = nova_context.get_admin_context()
|
||||
ifs = db.bm_interface_get_all_by_bm_node_id(context, node['id'])
|
||||
self._mac_addresses = [_normalize_mac(i['address']) for i in ifs]
|
||||
self._connection = None
|
||||
self._matched_name = ''
|
||||
self.state = None
|
||||
|
@ -135,7 +142,7 @@ class VirtualPowerManager(base.PowerManager):
|
|||
return full_list
|
||||
|
||||
def _check_for_node(self):
|
||||
LOG.debug("Looking up Name for Mac address %s." % self._mac_address)
|
||||
LOG.debug("Looking up Name for Mac address %s." % self._mac_addresses)
|
||||
self._matched_name = ''
|
||||
full_node_list = self._get_full_node_list()
|
||||
|
||||
|
@ -144,11 +151,9 @@ class VirtualPowerManager(base.PowerManager):
|
|||
mac_address_list = self._run_command(cmd)
|
||||
|
||||
for mac in mac_address_list:
|
||||
if self._mac_address.lower() in mac.lower():
|
||||
if _normalize_mac(mac) in self._mac_addresses:
|
||||
self._matched_name = ('"%s"' % node)
|
||||
break
|
||||
if self._matched_name:
|
||||
break
|
||||
return self._matched_name
|
||||
|
||||
def activate_node(self):
|
||||
|
|
Loading…
Reference in New Issue