diff --git a/sushy_oem_idrac/resources/manager/manager.py b/sushy_oem_idrac/resources/manager/manager.py index b81e57e..334e24b 100644 --- a/sushy_oem_idrac/resources/manager/manager.py +++ b/sushy_oem_idrac/resources/manager/manager.py @@ -23,11 +23,18 @@ from sushy.resources.oem import base as oem_base from sushy_oem_idrac import asynchronous from sushy_oem_idrac import constants from sushy_oem_idrac.resources import common as res_common +from sushy_oem_idrac.resources.manager import constants as mgr_cons from sushy_oem_idrac.resources.manager import mappings as mgr_maps from sushy_oem_idrac import utils LOG = logging.getLogger(__name__) +# System Configuration Tag Constant +_SYSTEM_CONFIG_TAG = "SystemConfiguration" + +# Response Code Constant +_RESPONSE_OK_CODE = 200 + class DellManagerActionsField(base.CompositeField): import_system_configuration = common.ActionField( @@ -243,6 +250,44 @@ VFDD\ LOG.error('Dell OEM export system configuration failed : %s', exc) raise + def get_pxe_port_macs_bios(self, ethernet_interfaces_mac): + """Get a list of pxe port MAC addresses for BIOS. + + :param ethernet_interfaces_mac: Dictionary of ethernet interfaces. + :returns: List of pxe port MAC addresses. + :raises: ExtensionError on failure to perform requested operation. + """ + pxe_port_macs = [] + # Get NIC configuration + nic_settings = self._export_system_configuration( + target=mgr_cons.EXPORT_NIC_CONFIG) + + if nic_settings.status_code != _RESPONSE_OK_CODE: + error = (('An error occurred when attempting to export ' + 'the system configuration. Status code: %(code), ' + 'Error details: %(err)'), + {'code': nic_settings.status_code, + 'err': nic_settings.__dict__}) + LOG.error(error) + raise sushy.exceptions.ExtensionError(error=error) + # Parse the exported system configuration for the NIC + # ports that are set to PXE boot + json_data = nic_settings.json() + if _SYSTEM_CONFIG_TAG in json_data.keys(): + for root in json_data[_SYSTEM_CONFIG_TAG]['Components']: + nic_id = root['FQDD'] + for child in root['Attributes']: + if child.get('Name') == "LegacyBootProto": + if child['Value'] == "PXE": + mac_address = ethernet_interfaces_mac[nic_id] + pxe_port_macs.append(mac_address) + return pxe_port_macs + + else: + error = (('Failed to get system configuration from response')) + LOG.error(error) + raise sushy.exceptions.ExtensionError(error=error) + def get_extension(*args, **kwargs): return DellManagerExtension diff --git a/sushy_oem_idrac/tests/unit/json_samples/export_configuration_nic_bios.json b/sushy_oem_idrac/tests/unit/json_samples/export_configuration_nic_bios.json new file mode 100644 index 0000000..a56202a --- /dev/null +++ b/sushy_oem_idrac/tests/unit/json_samples/export_configuration_nic_bios.json @@ -0,0 +1,1435 @@ +{ + "SystemConfiguration": { + "Comments": [ + { + "Comment": "Export type is Normal,JSON,Selective" + }, + { + "Comment": "Exported configuration may contain commented attributes. Attributes may be commented due to dependency, destructive nature, preserving server identity or for security reasons." + } + ], + "Model": "PowerEdge R7525", + "ServiceTag": "C6DCS33", + "TimeStamp": "Wed Feb 3 06:53:31 2021", + "Components": [ + { + "FQDD": "NIC.Integrated.1-4-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VirtualizationMode", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LnkSpeed", + "Value": "AutoNeg", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "WakeOnLan", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "NumberVFAdvertised", + "Value": "8", + "Set On Import": "False", + "Comment": "Read and Write" + } + ] + }, + { + "FQDD": "NIC.Integrated.1-2-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VirtualizationMode", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LnkSpeed", + "Value": "AutoNeg", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "WakeOnLan", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "NumberVFAdvertised", + "Value": "8", + "Set On Import": "False", + "Comment": "Read and Write" + } + ] + }, + { + "FQDD": "NIC.Integrated.1-3-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VirtualizationMode", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "PXE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LnkSpeed", + "Value": "AutoNeg", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "WakeOnLan", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "NumberVFAdvertised", + "Value": "8", + "Set On Import": "False", + "Comment": "Read and Write" + } + ] + }, + { + "FQDD": "NIC.Integrated.1-1-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VirtualizationMode", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LnkSpeed", + "Value": "AutoNeg", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "WakeOnLan", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "NumberVFAdvertised", + "Value": "8", + "Set On Import": "False", + "Comment": "Read and Write" + } + ] + }, + { + "FQDD": "NIC.Embedded.1-1-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "EEEControl", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "F4:02:70:B8:A6:7A", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "TcpIpViaDHCP", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IpAutoConfig", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiViaDHCP", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "ChapAuthEnable", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiTgtBoot", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "DhcpVendId", + "Value": "BRCM ISAN", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LnkUpDelayTime", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "TcpTimestmp", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "FirstHddTarget", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LunBusyRetryCnt", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IpVer", + "Value": "IPv4", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorIpAddr", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSubnet", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSubnetPrefix", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorGateway", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorPrimDns", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSecDns", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorName", + "Value": "iqn.1995-05.com.broadcom.iscsiboot", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "ConnectFirstTgt", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIpAddress", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtTcpPort", + "Value": "3260", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtBootLun", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIscsiName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "ConnectSecondTgt", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtIpAddress", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtTcpPort", + "Value": "3260", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtBootLun", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtIscsiName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondaryDeviceMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "UseIndTgtPortal", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "UseIndTgtName", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "BootOptionROM", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "BootStrapType", + "Value": "AutoDetect", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "HideSetupPrompt", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "BannerMessageTimeout", + "Value": "5", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LnkSpeed", + "Value": "AutoNeg", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "WakeOnLan", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanMode", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "1", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "PermitTotalPortShutdown", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + } + ] + }, + { + "FQDD": "NIC.Slot.1-2-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VirtualizationMode", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "NParEP", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "NumberVFAdvertised", + "Value": "64", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "INTEL_LLDPAgent", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "TcpIpViaDHCP", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiViaDHCP", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "ChapAuthEnable", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "ChapMutualAuth", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorIpAddr", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSubnet", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorGateway", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIpAddress", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtTcpPort", + "Value": "3260", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtBootLun", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIscsiName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VFDistribution", + "Value": "64:0:0:0:0:0:0:0", + "Set On Import": "False", + "Comment": "Read and Write" + } + ] + }, + { + "FQDD": "NIC.Slot.1-1-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VirtualizationMode", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "NParEP", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "NumberVFAdvertised", + "Value": "64", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "INTEL_LLDPAgent", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "TcpIpViaDHCP", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiViaDHCP", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "ChapAuthEnable", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "ChapMutualAuth", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorIpAddr", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSubnet", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorGateway", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIpAddress", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtTcpPort", + "Value": "3260", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtBootLun", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIscsiName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VFDistribution", + "Value": "64:0:0:0:0:0:0:0", + "Set On Import": "False", + "Comment": "Read and Write" + } + ] + }, + { + "FQDD": "NIC.Embedded.2-1-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "EEEControl", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "F4:02:70:B8:A6:7B", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "TcpIpViaDHCP", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IpAutoConfig", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiViaDHCP", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "ChapAuthEnable", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiTgtBoot", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "DhcpVendId", + "Value": "BRCM ISAN", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LnkUpDelayTime", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "TcpTimestmp", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "FirstHddTarget", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LunBusyRetryCnt", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IpVer", + "Value": "IPv4", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorIpAddr", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSubnet", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSubnetPrefix", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorGateway", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorPrimDns", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSecDns", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorName", + "Value": "iqn.1995-05.com.broadcom.iscsiboot", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "ConnectFirstTgt", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIpAddress", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtTcpPort", + "Value": "3260", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtBootLun", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIscsiName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "ConnectSecondTgt", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtIpAddress", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtTcpPort", + "Value": "3260", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtBootLun", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtIscsiName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondTgtChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "SecondaryDeviceMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "UseIndTgtPortal", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "UseIndTgtName", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "BootOptionROM", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "BootStrapType", + "Value": "AutoDetect", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "HideSetupPrompt", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "BannerMessageTimeout", + "Value": "5", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "LnkSpeed", + "Value": "AutoNeg", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "WakeOnLan", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanMode", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "1", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "PermitTotalPortShutdown", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + } + ] + }, + { + "FQDD": "NIC.Slot.2-2-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VirtualizationMode", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "NParEP", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "NumberVFAdvertised", + "Value": "64", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "INTEL_LLDPAgent", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "TcpIpViaDHCP", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiViaDHCP", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "ChapAuthEnable", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "ChapMutualAuth", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorIpAddr", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSubnet", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorGateway", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIpAddress", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtTcpPort", + "Value": "3260", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtBootLun", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIscsiName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VFDistribution", + "Value": "64:0:0:0:0:0:0:0", + "Set On Import": "False", + "Comment": "Read and Write" + } + ] + }, + { + "FQDD": "NIC.Slot.2-1-1", + "Attributes": [ + { + "Name": "BlnkLeds", + "Value": "0", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VirtMacAddr", + "Value": "00:00:00:00:00:00", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VirtualizationMode", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "NParEP", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "LegacyBootProto", + "Value": "NONE", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "VLanId", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "NumberVFAdvertised", + "Value": "64", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "INTEL_LLDPAgent", + "Value": "Enabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "TcpIpViaDHCP", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "IscsiViaDHCP", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "ChapAuthEnable", + "Value": "Disabled", + "Set On Import": "True", + "Comment": "Read and Write" + }, + { + "Name": "ChapMutualAuth", + "Value": "Disabled", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorIpAddr", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorSubnet", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorGateway", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapId", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "IscsiInitiatorChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIpAddress", + "Value": "0.0.0.0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtTcpPort", + "Value": "3260", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtBootLun", + "Value": "0", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtIscsiName", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "FirstTgtChapPwd", + "Value": "", + "Set On Import": "False", + "Comment": "Read and Write" + }, + { + "Name": "VFDistribution", + "Value": "64:0:0:0:0:0:0:0", + "Set On Import": "False", + "Comment": "Read and Write" + } + ] + } + ] + } +} diff --git a/sushy_oem_idrac/tests/unit/test_manager.py b/sushy_oem_idrac/tests/unit/test_manager.py index 2742c73..e06a349 100644 --- a/sushy_oem_idrac/tests/unit/test_manager.py +++ b/sushy_oem_idrac/tests/unit/test_manager.py @@ -100,3 +100,55 @@ class ManagerTestCase(BaseTestCase): target = "xyz" self.assertRaises(sushy.exceptions.InvalidParameterValueError, oem._export_system_configuration, target) + + @mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {}) + def test_get_pxe_port_macs_bios(self): + oem = self.manager.get_oem_extension('Dell') + oem._export_system_configuration = mock.Mock() + with open('sushy_oem_idrac/tests/unit/json_samples/' + 'export_configuration_nic_bios.json') as f: + mock_response = oem._export_system_configuration.return_value + mock_response.json.return_value = json.load(f) + mock_response.status_code = 200 + ethernet_interfaces_mac = {'NIC.Integrated.1-4-1': '68:05:CA:AF:AA:C9', + 'NIC.Slot.7-2-1': '3C:FD:FE:CD:67:31', + 'NIC.Slot.7-1-1': '3C:FD:FE:CD:67:30', + 'NIC.Integrated.1-2-1': '68:05:CA:AF:AA:C7', + 'NIC.Integrated.1-3-1': '68:05:CA:AF:AA:C8', + 'NIC.Integrated.1-1-1': '68:05:CA:AF:AA:C6'} + + self.assertEqual(["68:05:CA:AF:AA:C8"], + oem.get_pxe_port_macs_bios(ethernet_interfaces_mac)) + + @mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {}) + def test_get_pxe_port_macs_bios_invalid_system_config_tag(self): + oem = self.manager.get_oem_extension('Dell') + oem._export_system_configuration = mock.Mock() + mock_response = oem._export_system_configuration.return_value + mock_response.json.return_value = {'Model': 'PowerEdge R7525'} + mock_response.status_code = 200 + ethernet_interfaces_mac = {'NIC.Integrated.1-4-1': '68:05:CA:AF:AA:C9', + 'NIC.Slot.7-2-1': '3C:FD:FE:CD:67:31', + 'NIC.Slot.7-1-1': '3C:FD:FE:CD:67:30', + 'NIC.Integrated.1-2-1': '68:05:CA:AF:AA:C7', + 'NIC.Integrated.1-3-1': '68:05:CA:AF:AA:C8', + 'NIC.Integrated.1-1-1': '68:05:CA:AF:AA:C6'} + + self.assertRaises(sushy.exceptions.ExtensionError, + oem.get_pxe_port_macs_bios, ethernet_interfaces_mac) + + @mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {}) + def test_get_pxe_port_macs_bios_invalid_response(self): + oem = self.manager.get_oem_extension('Dell') + oem._export_system_configuration = mock.Mock() + mock_response = oem._export_system_configuration.return_value + mock_response.status_code = 204 + ethernet_interfaces_mac = {'NIC.Integrated.1-4-1': '68:05:CA:AF:AA:C9', + 'NIC.Slot.7-2-1': '3C:FD:FE:CD:67:31', + 'NIC.Slot.7-1-1': '3C:FD:FE:CD:67:30', + 'NIC.Integrated.1-2-1': '68:05:CA:AF:AA:C7', + 'NIC.Integrated.1-3-1': '68:05:CA:AF:AA:C8', + 'NIC.Integrated.1-1-1': '68:05:CA:AF:AA:C6'} + + self.assertRaises(sushy.exceptions.ExtensionError, + oem.get_pxe_port_macs_bios, ethernet_interfaces_mac)