lenovo / python-redfish-lenovo

Sample Python scripts and Ansible playbooks for using the Redfish API on Lenovo servers
Apache License 2.0
86 stars 49 forks source link

How to get Mac Address of an network adapter #368

Open jasmeer opened 2 months ago

jasmeer commented 2 months ago

Hi Usually MAC address is available in NetworkDeviceFunction object. However, in my system NetworkDeviceFunction collection has no members:

curl -k https:/redfish/v1/Chassis/1/NetworkAdapters/slot-1/NetworkDeviceFunctions { "Name": "NetworkDeviceFunctionCollection", "Description": "A collection of NetworkDeviceFunction resource instances.", "@odata.etag": "\"33e203339f0e2428c37\"", "@odata.id": "/redfish/v1/Chassis/1/NetworkAdapters/slot-1/NetworkDeviceFunctions", "Members@odata.count": 0, "Members": [], "@odata.type": "#NetworkDeviceFunctionCollection.NetworkDeviceFunctionCollection", "@odata.context": "/redfish/v1/$metadata#NetworkDeviceFunctionCollection.NetworkDeviceFunctionCollection" }

Why is it so? Is there any other way to find the Mac address set to a network port?

Thanks Jasmeer

jixj5 commented 2 months ago

Hi Jasmeer, Some network cards do not provide NetworkDeviceFunction. You can find the Mac address of network port in Ports Object. such as: /redfish/v1/Chassis/1/NetworkAdapters/slot6_0x170000/Ports/0 image

jasmeer commented 2 months ago

Thank you for the reply. In my system, ports and NetworkPorts collections are empty as well.

 https://localhost:17443/redfish/v1/Chassis/1/NetworkAdapters/slot-1

{
  "Id": "slot-1",
  "Description": "A NetworkAdapter represents the physical network adapter capable of connecting to a computer network.",
  "@odata.type": "#NetworkAdapter.v1_9_0.NetworkAdapter",
  "@odata.id": "/redfish/v1/Chassis/1/NetworkAdapters/slot-1",
  "Model": "ConnectX-6 Dx EN adapter card, 1",
  "SerialNumber": "MT2134X16430",
  "Oem": {
    "Lenovo": {
      "@odata.type": "#LenovoDeviceInfo.v1_0_0.LenovoDeviceInfo",
      "UUID": ""
    }
  },
  "@odata.context": "/redfish/v1/$metadata#NetworkAdapter.NetworkAdapter",
  "SKU": "MCX623106AN-CDAT",
  "Ports": {
    "@odata.id": "/redfish/v1/Chassis/1/NetworkAdapters/slot-1/Ports"
  },
  "Status": {
    "Health": "OK",
    "State": "Enabled"
  },
  "@odata.etag": "\"a8794521551034a43afa6\"",
  "Manufacturer": "MLNX",
  "NetworkPorts": {
    "@odata.id": "/redfish/v1/Chassis/1/NetworkAdapters/slot-1/NetworkPorts"
  },
  "Name": "NetworkAdapter",
  "PartNumber": "MCX623106AN-CDAT",
  "Controllers": [
    {
      "ControllerCapabilities": {
        "NetworkPortCount": 0,
        "NetworkDeviceFunctionCount": -2
      },
      "Links": {
        "PCIeDevices": [
          {
            "@odata.id": "/redfish/v1/Chassis/1/PCIeDevices/slot_1"
          }
        ],
        "NetworkDeviceFunctions": [],
        "NetworkPorts": [],
        "Ports": []
      },
      "FirmwarePackageVersion": "22.30.1004",
      "Location": {
        "Info": "Slot 1",
        "PartLocation": {
          "ServiceLabel": "PCIe 1",
          "LocationType": "Slot",
          "LocationOrdinalValue": 1
        },
        "InfoFormat@Redfish.Deprecated": "The property is deprecated. Please use PartLocation instead.",
        "InfoFormat": "Slot X",
        "Info@Redfish.Deprecated": "The property is deprecated. Please use PartLocation instead."
      },
      "PCIeInterface": {
        "MaxPCIeType": "Gen4",
        "MaxLanes": 16,
        "PCIeType": "Gen4",
        "LanesInUse": 16
      }
    }
  ],
  "NetworkDeviceFunctions": {
    "@odata.id": "/redfish/v1/Chassis/1/NetworkAdapters/slot-1/NetworkDeviceFunctions"
  }
}

 curl -k https://localhost:17443/redfish/v1/Chassis/1/NetworkAdapters/slot-1/Ports |  jq

{
  "Name": "PortCollection",
  "Description": "A collection of Port resource instances.",
  "@odata.type": "#PortCollection.PortCollection",
  "@odata.id": "/redfish/v1/Chassis/1/NetworkAdapters/slot-1/Ports",
  "Members@odata.count": 0,
  "Members": [],
  "@odata.etag": "\"22d2779d205f24e4a34\"",
  "@odata.context": "/redfish/v1/$metadata#PortCollection.PortCollection"
}

curl  https://localhost:17443/redfish/v1/Chassis/1/NetworkAdapters/slot-1/NetworkPorts| jq

{
  "Name": "NetworkPortCollection",
  "Description": "A collection of NetworkPort resource instances.",
  "@odata.type": "#NetworkPortCollection.NetworkPortCollection",
  "@odata.id": "/redfish/v1/Chassis/1/NetworkAdapters/slot-1/NetworkPorts",
  "Members@odata.count": 0,
  "Members": [],
  "@odata.etag": "\"277748d09c7724231a0\"",
  "@odata.context": "/redfish/v1/$metadata#NetworkPortCollection.NetworkPortCollection"
} 

Why ports, networkports and netrworkdevicefunctions all are empty?

Thanks Jasmeer

jixj5 commented 2 months ago

Could you give me your server's products model (such as SR650), XCC/UEFI firmware versions and FFDC log? Can you see the port and mac on web,such as image

Thanks.