Follow-up patch for UEFI iSCSI boot nic adapter fix

This commit addresses comments on UEFI iSCSI boot patch
for multiple nic adapter support.

Change-Id: I626bb5db7d496a68c622fdd6ab6c2fa3ecff07fc
This commit is contained in:
kesper 2019-08-27 12:09:29 +00:00
parent 94d4e1c372
commit bdb14f3419
4 changed files with 11 additions and 8 deletions

View File

@ -607,6 +607,7 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
def _get_uefi_device_path_by_mac(self, mac):
"""Return uefi device path of mac.
:param mac: Mac address.
:returns: Uefi Device path.
Ex. 'PciRoot(0x0)/Pci(0x2,0x3)/Pci(0x0,0x0)'
"""
@ -621,6 +622,7 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
def _get_nic_association_name_by_mac(self, mac):
"""Return nic association name by mac address
:param mac: Mac address.
:returns: Nic association name. Ex. NicBoot1
"""
headers, bios_uri, bios_settings = self._check_bios_resource()
@ -658,7 +660,7 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
macs_available = self._get_all_macs()
if not set(macs).issubset(macs_available):
msg = ("Given macs: %(macs)s not found in the system"
% {'macs': str(macs)})
% {'macs': list(set(macs) - set(macs_available))})
raise exception.InvalidInputError(msg)
def _change_iscsi_settings(self, iscsi_info, macs=[]):

View File

@ -65,7 +65,5 @@ class EthernetInterfaceCollection(base.ResourceCollectionBase):
def get_all_macs(self):
"""Return list of macs available on system"""
macs = []
for mac in self.get_members():
macs.append(mac.mac_address.lower())
macs = [mac.mac_address.lower() for mac in self.get_members()]
return macs

View File

@ -637,12 +637,13 @@ class HPESystem(system.System):
macs_available = self.ethernet_interfaces.get_all_macs()
if not set(macs).issubset(macs_available):
msg = ("Given macs: %(macs)s not found in the system"
% {'macs': str(macs)})
% {'macs': list(set(macs) - set(macs_available))})
raise exception.InvalidInputError(msg)
def get_nic_association_name_by_mac(self, mac):
"""Return nic association name by mac address
:mac: Mac address.
:returns: Nic association name. Ex. NicBoot1
"""
mappings = self.bios_settings.bios_mappings.pci_settings_mappings

View File

@ -1170,10 +1170,12 @@ class HPESystemTestCase(testtools.TestCase):
'ethernet_interface_collection.json')
with open(path, 'r') as f:
eth_coll = json.loads(f.read())
self.conn.get.return_value.json.side_effect = eth_coll
self.conn.get.return_value.json.side_effect = [eth_coll]
get_all_macs_mock.return_value = [
'12:44:6a:3b:04:11', '13:44:6a:3b:04:13']
self.assertRaisesRegex(
exception.InvalidInputError,
"Given macs: \['12:44:6A:3B:04:15'\] not found in the system",
self.sys_inst.validate_macs, ['12:44:6A:3B:04:15'])
"Given macs: \['14:23:AD:3B:4C:78'\] "
"not found in the system",
self.sys_inst.validate_macs,
['12:44:6a:3b:04:11', '14:23:AD:3B:4C:78'])