from infi.hbaapi import Port
import json
example = json.loads(""" [
    {
        "discovered_ports": [
            {
                "discovered_ports": [], 
                "driver_name": null, 
                "driver_version": null, 
                "fabric_name": "00:00:00:00:00:00:00:00", 
                "firmware_version": null, 
                "hardware_version": null, 
                "manufacturer": null, 
                "model": null, 
                "model_description": null, 
                "node_wwn": "20:03:00:1b:32:6e:61:2e", 
                "option_rom_version": null, 
                "os_device_name": "", 
                "port_fcid": 5046528, 
                "port_max_frame_size": 0, 
                "port_speed": 0, 
                "port_state": "online", 
                "port_supported_speeds": [], 
                "port_symbolic_name": "", 
                "port_type": null, 
                "port_wwn": "21:03:00:1b:32:6e:61:2e", 
                "serial_number": null, 
                "statistics": {
                    "dumped_frames": -1, 
                    "error_frames": -1, 
                    "fcp_control_requests": -1, 
                    "fcp_input_megabytes": -1, 
                    "fcp_input_requests": -1, 
                    "fcp_output_megabytes": -1, 
                    "fcp_output_requests": -1, 
                    "invalid_crc_count": -1, 
                    "invalid_tx_word_count": -1, 
                    "link_failure_count": -1, 
                    "lip_count": -1, 
                    "loss_of_signal_count": -1, 
                    "loss_of_sync_count": -1, 
                    "nos_count": -1, 
                    "primitive_seq_protocol_err_count": -1, 
                    "rx_frames": -1, 
                    "rx_words": -1, 
                    "seconds_since_last_reset": -1, 
                    "tx_frames": -1, 
                    "tx_words": -1
                }
            }, 
            {
                "discovered_ports": [], 
                "driver_name": null, 
                "driver_version": null, 
                "fabric_name": "00:00:00:00:00:00:00:00", 
                "firmware_version": null, 
                "hardware_version": null, 
                "manufacturer": null, 
                "model": null, 
                "model_description": null, 
                "node_wwn": "20:00:00:1b:32:1e:0a:80", 
                "option_rom_version": null, 
                "os_device_name": "", 
                "port_fcid": 5046784, 
                "port_max_frame_size": 0, 
                "port_speed": 0, 
                "port_state": "online", 
                "port_supported_speeds": [], 
                "port_symbolic_name": "", 
                "port_type": null, 
                "port_wwn": "21:00:00:1b:32:1e:0a:80", 
                "serial_number": null, 
                "statistics": {
                    "dumped_frames": -1, 
                    "error_frames": -1, 
                    "fcp_control_requests": -1, 
                    "fcp_input_megabytes": -1, 
                    "fcp_input_requests": -1, 
                    "fcp_output_megabytes": -1, 
                    "fcp_output_requests": -1, 
                    "invalid_crc_count": -1, 
                    "invalid_tx_word_count": -1, 
                    "link_failure_count": -1, 
                    "lip_count": -1, 
                    "loss_of_signal_count": -1, 
                    "loss_of_sync_count": -1, 
                    "nos_count": -1, 
                    "primitive_seq_protocol_err_count": -1, 
                    "rx_frames": -1, 
                    "rx_words": -1, 
                    "seconds_since_last_reset": -1, 
                    "tx_frames": -1, 
                    "tx_words": -1
                }
            }
        ], 
        "driver_name": "ql2300.sys", 
        "driver_version": "9.1.8.6", 
        "fabric_name": "20:01:00:05:73:dc:fa:81", 
        "firmware_version": "4.06.01", 
        "hardware_version": "", 
        "manufacturer": "QLogic Corporation", 
        "model": "QLE2562", 
        "model_description": "QLogic QLE2562 Fibre Channel Adapter", 
        "node_wwn": "20:00:00:24:ff:2c:4e:53", 
        "option_rom_version": "2.16", 
        "os_device_name": "\\\\\\\\.\\\\Scsi6:", 
        "port_fcid": 5047040, 
        "port_max_frame_size": 2048, 
        "port_speed": 8, 
        "port_state": "online", 
        "port_supported_speeds": [
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "", 
        "port_type": null, 
        "port_wwn": "21:00:00:24:ff:2c:4e:53", 
        "serial_number": "I07758", 
        "statistics": {
            "dumped_frames": -1, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": -1, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": -1, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 0, 
            "link_failure_count": 0, 
            "lip_count": -1, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": -1, 
            "primitive_seq_protocol_err_count": 0, 
            "rx_frames": -1, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": -1, 
            "tx_words": -1
        }
    }, 
    {
        "discovered_ports": [
            {
                "discovered_ports": [], 
                "driver_name": null, 
                "driver_version": null, 
                "fabric_name": "00:00:00:00:00:00:00:00", 
                "firmware_version": null, 
                "hardware_version": null, 
                "manufacturer": null, 
                "model": null, 
                "model_description": null, 
                "node_wwn": "20:00:00:1b:32:17:63:91", 
                "option_rom_version": null, 
                "os_device_name": "", 
                "port_fcid": 69888, 
                "port_max_frame_size": 0, 
                "port_speed": 0, 
                "port_state": "online", 
                "port_supported_speeds": [], 
                "port_symbolic_name": "", 
                "port_type": null, 
                "port_wwn": "21:00:00:1b:32:17:63:91", 
                "serial_number": null, 
                "statistics": {
                    "dumped_frames": -1, 
                    "error_frames": -1, 
                    "fcp_control_requests": -1, 
                    "fcp_input_megabytes": -1, 
                    "fcp_input_requests": -1, 
                    "fcp_output_megabytes": -1, 
                    "fcp_output_requests": -1, 
                    "invalid_crc_count": -1, 
                    "invalid_tx_word_count": -1, 
                    "link_failure_count": -1, 
                    "lip_count": -1, 
                    "loss_of_signal_count": -1, 
                    "loss_of_sync_count": -1, 
                    "nos_count": -1, 
                    "primitive_seq_protocol_err_count": -1, 
                    "rx_frames": -1, 
                    "rx_words": -1, 
                    "seconds_since_last_reset": -1, 
                    "tx_frames": -1, 
                    "tx_words": -1
                }
            }
        ], 
        "driver_name": "ql2300.sys", 
        "driver_version": "9.1.8.6", 
        "fabric_name": "10:00:00:05:33:68:30:15", 
        "firmware_version": "4.06.01", 
        "hardware_version": "", 
        "manufacturer": "QLogic Corporation", 
        "model": "QLE2562", 
        "model_description": "QLogic QLE2562 Fibre Channel Adapter", 
        "node_wwn": "20:00:00:24:ff:2c:4e:52", 
        "option_rom_version": "2.16", 
        "os_device_name": "\\\\\\\\.\\\\Scsi5:", 
        "port_fcid": 70400, 
        "port_max_frame_size": 2048, 
        "port_speed": null, 
        "port_state": "online", 
        "port_supported_speeds": [
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "", 
        "port_type": null, 
        "port_wwn": "21:00:00:24:ff:2c:4e:52", 
        "serial_number": "I07502", 
        "statistics": {
            "dumped_frames": -1, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": -1, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": -1, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 1, 
            "link_failure_count": 1, 
            "lip_count": -1, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": -1, 
            "primitive_seq_protocol_err_count": 0, 
            "rx_frames": -1, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": -1, 
            "tx_words": -1
        }
    }, 
    {
        "discovered_ports": [], 
        "driver_name": "ql2300.sys", 
        "driver_version": "9.1.8.6", 
        "fabric_name": "00:00:00:00:00:00:00:00", 
        "firmware_version": "4.06.01", 
        "hardware_version": "", 
        "manufacturer": "QLogic Corporation", 
        "model": "QLE2562", 
        "model_description": "QLogic QLE2562 Fibre Channel Adapter", 
        "node_wwn": "20:00:00:24:ff:2c:4d:f3", 
        "option_rom_version": "2.16", 
        "os_device_name": "\\\\\\\\.\\\\Scsi4:", 
        "port_fcid": 0, 
        "port_max_frame_size": 2048, 
        "port_speed": 0, 
        "port_state": "link down", 
        "port_supported_speeds": [
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "", 
        "port_type": null, 
        "port_wwn": "21:00:00:24:ff:2c:4d:f3", 
        "serial_number": "I48717", 
        "statistics": {
            "dumped_frames": -1, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": -1, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": -1, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 0, 
            "link_failure_count": 0, 
            "lip_count": -1, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": -1, 
            "primitive_seq_protocol_err_count": 0, 
            "rx_frames": -1, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": -1, 
            "tx_words": -1
        }
    }, 
    {
        "discovered_ports": [], 
        "driver_name": "ql2300.sys", 
        "driver_version": "9.1.8.6", 
        "fabric_name": "00:00:00:00:00:00:00:00", 
        "firmware_version": "4.06.01", 
        "hardware_version": "", 
        "manufacturer": "QLogic Corporation", 
        "model": "QLE2562", 
        "model_description": "QLogic QLE2562 Fibre Channel Adapter", 
        "node_wwn": "20:00:00:24:ff:2c:4d:f2", 
        "option_rom_version": "2.16", 
        "os_device_name": "\\\\\\\\.\\\\Scsi3:", 
        "port_fcid": 0, 
        "port_max_frame_size": 2048, 
        "port_speed": 0, 
        "port_state": "link down", 
        "port_supported_speeds": [
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "", 
        "port_type": null, 
        "port_wwn": "21:00:00:24:ff:2c:4d:f2", 
        "serial_number": "I48461", 
        "statistics": {
            "dumped_frames": -1, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": -1, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": -1, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 0, 
            "link_failure_count": 0, 
            "lip_count": -1, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": -1, 
            "primitive_seq_protocol_err_count": 0, 
            "rx_frames": -1, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": -1, 
            "tx_words": -1
        }
    }
]
""")
ports = [Port().update_not_none_values(item) for item in example]
