Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
},
{
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces/NIC.Integrated.1-2-1"
},
{
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces/NIC.Slot.2-1-1"
},
{
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces/NIC.Slot.2-2-1"
}
],
"Members@odata.count": 10,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces/NIC.Embedded.1-1-1",
"@odata.type": "#EthernetInterface.v1_10_0.EthernetInterface",
"AutoNeg": false,
"Description": "Embedded NIC 1 Port 1 Partition 1",
"EthernetInterfaceType": "Physical",
"FQDN": null,
"FullDuplex": false,
"HostName": null,
"IPv4Addresses": [],
"IPv4Addresses@odata.count": 0,
"IPv6AddressPolicyTable": [],
"IPv6AddressPolicyTable@odata.count": 0,
"IPv6Addresses": [],
"IPv6Addresses@odata.count": 0,
"IPv6DefaultGateway": null,
"IPv6StaticAddresses": [],
"IPv6StaticAddresses@odata.count": 0,
"Id": "NIC.Embedded.1-1-1",
"InterfaceEnabled": true,
"LinkStatus": "LinkDown",
"Links": {
"Chassis": {
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
}
},
"MACAddress": "C4:CB:E1:BF:8A:62",
"MTUSize": null,
"MaxIPv6StaticAddresses": null,
"Name": "System Ethernet Interface",
"NameServers": [],
"NameServers@odata.count": 0,
"PermanentMACAddress": "C4:CB:E1:BF:8A:62",
"SpeedMbps": 0,
"Status": {
"Health": "OK",
"State": "Enabled"
},
"UefiDevicePath": "PciRoot(0x3)/Pci(0x5,0x3)/Pci(0x0,0x0)",
"VLAN": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces/NIC.Embedded.2-1-1",
"@odata.type": "#EthernetInterface.v1_10_0.EthernetInterface",
"AutoNeg": false,
"Description": "Embedded NIC 1 Port 2 Partition 1",
"EthernetInterfaceType": "Physical",
"FQDN": null,
"FullDuplex": false,
"HostName": null,
"IPv4Addresses": [],
"IPv4Addresses@odata.count": 0,
"IPv6AddressPolicyTable": [],
"IPv6AddressPolicyTable@odata.count": 0,
"IPv6Addresses": [],
"IPv6Addresses@odata.count": 0,
"IPv6DefaultGateway": null,
"IPv6StaticAddresses": [],
"IPv6StaticAddresses@odata.count": 0,
"Id": "NIC.Embedded.2-1-1",
"InterfaceEnabled": true,
"LinkStatus": "LinkDown",
"Links": {
"Chassis": {
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
}
},
"MACAddress": "C4:CB:E1:BF:8A:63",
"MTUSize": null,
"MaxIPv6StaticAddresses": null,
"Name": "System Ethernet Interface",
"NameServers": [],
"NameServers@odata.count": 0,
"PermanentMACAddress": "C4:CB:E1:BF:8A:63",
"SpeedMbps": 0,
"Status": {
"Health": "OK",
"State": "Enabled"
},
"UefiDevicePath": "PciRoot(0x3)/Pci(0x5,0x3)/Pci(0x0,0x1)",
"VLAN": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces/NIC.Slot.2-1-1",
"@odata.type": "#EthernetInterface.v1_10_0.EthernetInterface",
"AutoNeg": true,
"Description": "NIC in Slot 2 Port 1 Partition 1",
"EthernetInterfaceType": "Physical",
"FQDN": null,
"FullDuplex": true,
"HostName": null,
"IPv4Addresses": [],
"IPv4Addresses@odata.count": 0,
"IPv6AddressPolicyTable": [],
"IPv6AddressPolicyTable@odata.count": 0,
"IPv6Addresses": [],
"IPv6Addresses@odata.count": 0,
"IPv6DefaultGateway": null,
"IPv6StaticAddresses": [],
"IPv6StaticAddresses@odata.count": 0,
"Id": "NIC.Slot.2-1-1",
"InterfaceEnabled": true,
"LinkStatus": "LinkUp",
"Links": {
"Chassis": {
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
}
},
"MACAddress": "9C:63:C0:24:B0:C0",
"MTUSize": null,
"MaxIPv6StaticAddresses": null,
"Name": "System Ethernet Interface",
"NameServers": [],
"NameServers@odata.count": 0,
"PermanentMACAddress": "9C:63:C0:24:B0:C0",
"SpeedMbps": 100000,
"Status": {
"Health": "OK",
"State": "Enabled"
},
"UefiDevicePath": "PciRoot(0x3)/Pci(0x1,0x1)/Pci(0x0,0x0)/MAC(9C63C024B0C0,0x1)",
"VLAN": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces/NIC.Slot.2-2-1",
"@odata.type": "#EthernetInterface.v1_10_0.EthernetInterface",
"AutoNeg": true,
"Description": "NIC in Slot 2 Port 2 Partition 1",
"EthernetInterfaceType": "Physical",
"FQDN": null,
"FullDuplex": true,
"HostName": null,
"IPv4Addresses": [],
"IPv4Addresses@odata.count": 0,
"IPv6AddressPolicyTable": [],
"IPv6AddressPolicyTable@odata.count": 0,
"IPv6Addresses": [],
"IPv6Addresses@odata.count": 0,
"IPv6DefaultGateway": null,
"IPv6StaticAddresses": [],
"IPv6StaticAddresses@odata.count": 0,
"Id": "NIC.Slot.2-2-1",
"InterfaceEnabled": true,
"LinkStatus": "LinkUp",
"Links": {
"Chassis": {
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
}
},
"MACAddress": "9C:63:C0:24:B0:C1",
"MTUSize": null,
"MaxIPv6StaticAddresses": null,
"Name": "System Ethernet Interface",
"NameServers": [],
"NameServers@odata.count": 0,
"PermanentMACAddress": "9C:63:C0:24:B0:C1",
"SpeedMbps": 100000,
"Status": {
"Health": "OK",
"State": "Enabled"
},
"UefiDevicePath": "PciRoot(0x3)/Pci(0x1,0x1)/Pci(0x0,0x1)/MAC(9C63C024B0C1,0x1)",
"VLAN": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,32 @@
"StaleData": "NotStale",
"SwitchConnectionID": "c4:7e:e0:e4:10:7f",
"SwitchPortConnectionID": "Ethernet1/6"
},
{
"@odata.context": "/redfish/v1/$metadata#DellSwitchConnection.DellSwitchConnection",
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkPorts/Oem/Dell/DellSwitchConnections/NIC.Slot.2-1-1",
"@odata.type": "#DellSwitchConnection.v1_1_0.DellSwitchConnection",
"Description": "An instance of DellSwitchConnection will have the switch connection view information of all the ports.",
"FQDD": "NIC.Slot.2-1-1",
"Id": "NIC.Slot.2-1-1",
"InstanceID": "NIC.Slot.2-1-1",
"Name": "DellSwitchConnection",
"StaleData": "NotStale",
"SwitchConnectionID": "c4:7e:e0:e4:10:7f",
"SwitchPortConnectionID": "Ethernet1/8"
},
{
"@odata.context": "/redfish/v1/$metadata#DellSwitchConnection.DellSwitchConnection",
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkPorts/Oem/Dell/DellSwitchConnections/NIC.Slot.2-2-1",
"@odata.type": "#DellSwitchConnection.v1_1_0.DellSwitchConnection",
"Description": "An instance of DellSwitchConnection will have the switch connection view information of all the ports.",
"FQDD": "NIC.Slot.2-2-1",
"Id": "NIC.Slot.2-2-1",
"InstanceID": "NIC.Slot.2-2-1",
"Name": "DellSwitchConnection",
"StaleData": "NotStale",
"SwitchConnectionID": "c4:7e:e0:e4:10:7f",
"SwitchPortConnectionID": "Ethernet1/7"
}
],
"Members@odata.count": 7,
Expand Down
40 changes: 40 additions & 0 deletions python/understack-workflows/tests/test_bmc_chassis_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ def test_chassis_info_R7615():
remote_switch_mac_address="C4:7E:E0:E4:32:DF",
remote_switch_port_name="Ethernet1/5",
),
bmc_chassis_info.InterfaceInfo(
name="NIC.Embedded.1-1-1",
description="Embedded NIC 1 Port 1 Partition 1",
mac_address="C4:CB:E1:BF:8A:62",
ipv4_address=None,
ipv4_gateway=None,
dhcp=False,
remote_switch_mac_address=None,
remote_switch_port_name=None,
),
bmc_chassis_info.InterfaceInfo(
description="NIC in Slot 1 Port 1",
mac_address="14:23:F3:F5:25:F0",
Expand All @@ -86,5 +96,35 @@ def test_chassis_info_R7615():
remote_switch_mac_address="C4:7E:E0:E4:10:7F",
remote_switch_port_name="Ethernet1/6",
),
bmc_chassis_info.InterfaceInfo(
name="NIC.Embedded.2-1-1",
description="Embedded NIC 1 Port 2 Partition 1",
mac_address="C4:CB:E1:BF:8A:63",
ipv4_address=None,
ipv4_gateway=None,
dhcp=False,
remote_switch_mac_address=None,
remote_switch_port_name=None,
),
bmc_chassis_info.InterfaceInfo(
name="NIC.Slot.2-1-1",
description="NIC in Slot 2 Port 1 Partition 1",
mac_address="9C:63:C0:24:B0:C0",
ipv4_address=None,
ipv4_gateway=None,
dhcp=False,
remote_switch_mac_address="C4:7E:E0:E4:10:7F",
remote_switch_port_name="Ethernet1/8",
),
bmc_chassis_info.InterfaceInfo(
name="NIC.Slot.2-2-1",
description="NIC in Slot 2 Port 2 Partition 1",
mac_address="9C:63:C0:24:B0:C1",
ipv4_address=None,
ipv4_gateway=None,
dhcp=False,
remote_switch_mac_address="C4:7E:E0:E4:10:7F",
remote_switch_port_name="Ethernet1/7",
),
],
)
7 changes: 5 additions & 2 deletions python/understack-workflows/tests/test_bmc_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def mock_redfish(mocker):
@pytest.fixture
def mock_success_auth(mocker):
mock = mocker.patch("understack_workflows.bmc_credentials._verify_auth")
mock.return_value = "tOkEn"
mock.return_value = "tOkEn", "/path/to/session/1234"
return mock


Expand All @@ -26,7 +26,10 @@ def mock_fail_auth(mocker):

def test_set_bmc_password_noop(mock_success_auth, mock_redfish):
set_bmc_password("1.2.3.4", "qwertyuiop")
assert not mock_redfish.called
assert mock_redfish.call_count == 1
mock_redfish.assert_called_with(
"1.2.3.4", "/path/to/session/1234", "tOkEn", "DELETE"
)


def test_set_bmc_password_failed(mock_fail_auth, mock_redfish):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ def interface_data(bmc: Bmc) -> list[InterfaceInfo]:

def combine_lldp(lldp, interface) -> InterfaceInfo:
name = interface["name"]
lldp_entry = lldp.get(name, {})
alternate_name = f"{name}-1"
lldp_entry = lldp.get(name, lldp.get(alternate_name))
if not lldp_entry:
logger.info(
f"LLDP info from BMC is missing for {name}, we only "
f"have LLDP info for {list(lldp.keys())}"
f"LLDP info from BMC is missing for {name} or {alternate_name}, "
f"we only have LLDP info for {list(lldp.keys())}"
)
return InterfaceInfo(**interface, **lldp_entry)

Expand Down Expand Up @@ -128,11 +129,22 @@ def parse_ipv4(


def in_band_interfaces(bmc: Bmc) -> list[dict]:
"""A Collection of Ethernet Interfaces for this System."""
"""A Collection of Ethernet Interfaces for this System.

If the redfish list of Ethernet Interfaces includes "foo" as well as "foo-1"
then we disregard the latter. The -1 suffix is used for "partitions" of a
physical interface. It seems to vary by device whether these are included
in redfish output at all, and if they are, whether the mac address
information is present in the base interface, the partition, or both.
"""
index_data = bmc.redfish_request(REDFISH_ETHERNET_ENDPOINT)
urls = [member["@odata.id"] for member in index_data["Members"]]

return [interface_detail(bmc, url) for url in urls if interface_is_relevant(url)]
return [
interface_detail(bmc, url)
for url in urls
if re.sub(r"-\d$", "", url) not in urls
]


def interface_detail(bmc, path) -> dict:
Expand Down Expand Up @@ -198,7 +210,7 @@ def parse_lldp_port(port_data: dict[str, str]) -> dict:
mac = str(port_data["SwitchConnectionID"]).upper()
port_name = normalize_interface_name(port_data["SwitchPortConnectionID"])

if mac in ["NOT AVAILABLE", "NO LINK"]:
if mac in ["NOT AVAILABLE", "NO LINK", "NOT SUPPORTED"]:
return {
"remote_switch_mac_address": None,
"remote_switch_port_name": None,
Expand All @@ -210,18 +222,5 @@ def parse_lldp_port(port_data: dict[str, str]) -> dict:
}


def interface_is_relevant(url: str) -> bool:
return bool(re.match(r".*(iDRAC.Embedded.*|NIC.(Integrated|Slot).\d-\d)$", url))


def server_interface_name(name: str) -> str:
if name.startswith("iDRAC.Embedded"):
return "iDRAC"

# remove the "-1" partition number from dell NIC ports
slot_regexp = re.compile(r"(.*\.\d-\d)-\d")
match = slot_regexp.match(name)
if match:
return match.group(1)

return name
return "iDRAC" if name.startswith("iDRAC.Embedded") else name
Loading
Loading