diff options
| author | Arata Notsu <notsu@virtualtech.jp> | 2013-04-15 20:27:03 +0900 |
|---|---|---|
| committer | Arata Notsu <notsu@virtualtech.jp> | 2013-04-15 20:27:03 +0900 |
| commit | 708ff76a993e48e17025c5c2d5451e2e49adc696 (patch) | |
| tree | 45f674647007b8b65fd80e479df4091b0077ab67 /nova/virt | |
| parent | 0fc0588a41d85a61695f4fa0aab238784ffe5999 (diff) | |
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
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/baremetal/virtual_power_driver.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/nova/virt/baremetal/virtual_power_driver.py b/nova/virt/baremetal/virtual_power_driver.py index e4e91240c..2e659b8c3 100644 --- a/nova/virt/baremetal/virtual_power_driver.py +++ b/nova/virt/baremetal/virtual_power_driver.py @@ -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): |
