bb-Ricardo / check_redfish

A monitoring/inventory plugin to check components and health status of systems which support Redfish. It will also create a inventory of all components of a system.
MIT License
110 stars 30 forks source link

"TypeError: 'NoneType' object is not iterable" while reading Network Ports #118

Closed kamils85 closed 10 months ago

kamils85 commented 10 months ago

Hello,

I am having an issue with one SuperMicro server running 1.8.0 redfish version. When I run the check_redfish script I get the following

2023-08-30 09:03:20,565 - INFO: Response Time for GET to /redfish/v1/Chassis/1/NetworkAdapters/1: 0.1463190289996419 seconds.
2023-08-30 09:03:20,565 - DEBUG: HTTP RESPONSE for /redfish/v1/Chassis/1/NetworkAdapters/1:
Code: 200 OK

Headers:
        Content-Length: 718
        Content-Type: application/json
        Strict-Transport-Security: max-age=31536000; includeSubdomains
        X-XSS-Protection: 1; mode=block
        Content-Security-Policy: default-src 'self';connect-src 'self' ws: wss:;frame-src 'self' data:;img-src 'self' data:;object-src 'self';font-src 'self' data:;script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';worker-src 'self' blob:;
        X-Frame-Options: SAMEORIGIN
        X-Content-Type-Options: nosniff
        OData-Version: 4.0
        Date: Wed, 30 Aug 2023 09:03:20 GMT

Body Response of /redfish/v1/Chassis/1/NetworkAdapters/1: b'{"@odata.type":"#NetworkAdapter.v1_3_0.NetworkAdapter","@odata.id":"/redfish/v1/Chassis/1/NetworkAdapters/1","Id":"1","Name":"Network Adapter View","Manufacturer":"Supermicro","Model":"","SerialNumber":"","PartNumber":"","NetworkPorts":{"@odata.id":"/redfish/v1/Chassis/1/NetworkAdapters/1/NetworkPorts"},"NetworkDeviceFunctions":{"@odata.id":"/redfish/v1/Chassis/1/NetworkAdapters/1/NetworkDeviceFunctions"},"Controllers":[{"Links":{"PCIeDevices":[{"@odata.id":"/redfish/v1/Chassis/1/PCIeDevices/NIC1"}]},"ControllerCapabilities":{"NetworkPortCount":1819357236,"NetworkDeviceFunctionCount":111},"Location":{"PartLocation":{"ServiceLabel":"Slot 6","LocationType":"Slot","LocationOrdinalValue":6}},"PCIeInterface":{}}]}'

{'@odata.id': '/redfish/v1/Chassis/1/NetworkAdapters/1',
 '@odata.type': '#NetworkAdapter.v1_3_0.NetworkAdapter',
 'Controllers': [{'ControllerCapabilities': {'NetworkDeviceFunctionCount': 111,
                                             'NetworkPortCount': 1819357236},
                  'Links': {'PCIeDevices': [{'@odata.id': '/redfish/v1/Chassis/1/PCIeDevices/NIC1'}]},
                  'Location': {'PartLocation': {'LocationOrdinalValue': 6,
                                                'LocationType': 'Slot',
                                                'ServiceLabel': 'Slot 6'}},
                  'PCIeInterface': {}}],
 'Id': '1',
 'Manufacturer': 'Supermicro',
 'Model': '',
 'Name': 'Network Adapter View',
 'NetworkDeviceFunctions': {'@odata.id': '/redfish/v1/Chassis/1/NetworkAdapters/1/NetworkDeviceFunctions'},
 'NetworkPorts': {'@odata.id': '/redfish/v1/Chassis/1/NetworkAdapters/1/NetworkPorts'},
 'PartNumber': '',
 'SerialNumber': ''}
Traceback (most recent call last):
  File "/opt/check_redfish/./check_redfish.py", line 172, in <module>
    if any(x in args.requested_query for x in ['nic', 'all']):      get_network_interfaces(plugin)
  File "/opt/check_redfish/cr_module/nic.py", line 23, in get_network_interfaces
    get_system_nics(plugin_object, system)
  File "/opt/check_redfish/cr_module/nic.py", line 367, in get_system_nics
    network_ports.extend(
TypeError: 'NoneType' object is not iterable

All other SuperMicro servers running older version 1.0.1 seem to complete the data reading with no such error.

bb-Ricardo commented 10 months ago

Hi,

Which version of check_redfish are you using?

kamils85 commented 10 months ago

The latest I believe. Installed via git clone.

__version__ = "1.5.0"
__version_date__ = "2023-02-24"
bb-Ricardo commented 10 months ago

Just published version 1.6.0, would you be able to test this one and see if this fixes your issue?

kamils85 commented 10 months ago

Hi @bb-Ricardo ,

Many thanks for looking at this issue. Unfortunately the same error appears using 1.6.0

./check_redfish.py -H 10.8.8.204 -f _test --inventory --all -v -d -t 60

(truncated...)

Body Response of /redfish/v1/Chassis/1/NetworkAdapters/1: b'{"@odata.type":"#NetworkAdapter.v1_3_0.NetworkAdapter","@odata.id":"/redfish/v1/Chassis/1/NetworkAdapters/1","Id":"1","Name":"Network Adapter View","Manufacturer":"Supermicro","Model":"","SerialNumber":"","PartNumber":"","NetworkPorts":{"@odata.id":"/redfish/v1/Chassis/1/NetworkAdapters/1/NetworkPorts"},"NetworkDeviceFunctions":{"@odata.id":"/redfish/v1/Chassis/1/NetworkAdapters/1/NetworkDeviceFunctions"},"Controllers":[{"Links":{"PCIeDevices":[{"@odata.id":"/redfish/v1/Chassis/1/PCIeDevices/NIC1"}]},"ControllerCapabilities":{"NetworkPortCount":913009764,"NetworkDeviceFunctionCount":-65429},"Location":{"PartLocation":{"ServiceLabel":"Slot 6","LocationType":"Slot","LocationOrdinalValue":6}},"PCIeInterface":{}}]}'

{'@odata.id': '/redfish/v1/Chassis/1/NetworkAdapters/1',
 '@odata.type': '#NetworkAdapter.v1_3_0.NetworkAdapter',
 'Controllers': [{'ControllerCapabilities': {'NetworkDeviceFunctionCount': -65429,
                                             'NetworkPortCount': 913009764},
                  'Links': {'PCIeDevices': [{'@odata.id': '/redfish/v1/Chassis/1/PCIeDevices/NIC1'}]},
                  'Location': {'PartLocation': {'LocationOrdinalValue': 6,
                                                'LocationType': 'Slot',
                                                'ServiceLabel': 'Slot 6'}},
                  'PCIeInterface': {}}],
 'Id': '1',
 'Manufacturer': 'Supermicro',
 'Model': '',
 'Name': 'Network Adapter View',
 'NetworkDeviceFunctions': {'@odata.id': '/redfish/v1/Chassis/1/NetworkAdapters/1/NetworkDeviceFunctions'},
 'NetworkPorts': {'@odata.id': '/redfish/v1/Chassis/1/NetworkAdapters/1/NetworkPorts'},
 'PartNumber': '',
 'SerialNumber': ''}
Traceback (most recent call last):
  File "/opt/check_redfish/./check_redfish.py", line 170, in <module>
    if any(x in args.requested_query for x in ['nic', 'all']):      get_network_interfaces()
  File "/opt/check_redfish/cr_module/nic.py", line 26, in get_network_interfaces
    get_system_nics(system)
  File "/opt/check_redfish/cr_module/nic.py", line 376, in get_system_nics
    network_ports.extend(
TypeError: 'NoneType' object is not iterable
__version__ = "1.6.0"
__version_date__ = "2023-09-07"
__author__ = "Ricardo Bartels <ricardo.bartels@telekom.de>"
__description__ = "Check Redfish Plugin"
__license__ = "MIT"
bb-Ricardo commented 10 months ago

Hi,

ok, I can see the issue here. Another interpretation of standards :(

bb-Ricardo commented 10 months ago

Just pushed ne commit to 'next-release' branch. Would you be able to check it out and give it a go?

thank you

kamils85 commented 10 months ago

Yes sir, this seems to fix the issue.

bb-Ricardo commented 10 months ago

great, thank you for testing

bb-Ricardo commented 10 months ago

Fixed with latest version 1.6.1