<reponame>Infinidat/infi.hbaapi
from infi.hbaapi import Port
import json
example = json.loads(""" [
    {
        "discovered_ports": [], 
        "driver_name": null, 
        "driver_version": "8.03.01.05.05.06-k", 
        "fabric_name": "fc00:e968:6179::de52:7100", 
        "firmware_version": null, 
        "hardware_version": "5.03.02 (d5)", 
        "manufacturer": null, 
        "model": "QLE2562", 
        "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA", 
        "node_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "option_rom_version": "4.04.00 128", 
        "os_device_name": null, 
        "port_fcid": "0x4d0300", 
        "port_max_frame_size": null, 
        "port_speed": 4, 
        "port_state": "online", 
        "port_supported_speeds": [
            1, 
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k", 
        "port_type": "nport (fabric via point-to-point)", 
        "port_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "serial_number": "", 
        "statistics": {
            "dumped_frames": 0, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": 0, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": 0, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 0, 
            "link_failure_count": 1, 
            "lip_count": 0, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": 1, 
            "primitive_seq_protocol_err_count": -1, 
            "primitiveitive_seq_protocol_err_count": -1, 
            "rx_frames": 3475, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": 3473, 
            "tx_words": -1
        }
    }, 
    {
        "discovered_ports": [], 
        "driver_name": null, 
        "driver_version": "8.03.01.05.05.06-k", 
        "fabric_name": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "firmware_version": null, 
        "hardware_version": "5.03.02 (d5)", 
        "manufacturer": null, 
        "model": "QLE2562", 
        "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA", 
        "node_wwn": "fdf8:f53e:61e4::18", 
        "option_rom_version": "4.04.00 128", 
        "os_device_name": null, 
        "port_fcid": "0x011300", 
        "port_max_frame_size": null, 
        "port_speed": 8, 
        "port_state": "online", 
        "port_supported_speeds": [
            1, 
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k", 
        "port_type": "nport (fabric via point-to-point)", 
        "port_wwn": "fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b", 
        "serial_number": "", 
        "statistics": {
            "dumped_frames": 0, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": 0, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": 0, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 4, 
            "link_failure_count": 1, 
            "lip_count": 0, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": 1, 
            "primitive_seq_protocol_err_count": -1, 
            "primitiveitive_seq_protocol_err_count": -1, 
            "rx_frames": 3474, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": 3474, 
            "tx_words": -1
        }
    }, 
    {
        "discovered_ports": [], 
        "driver_name": null, 
        "driver_version": "8.03.01.05.05.06-k", 
        "fabric_name": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "firmware_version": null, 
        "hardware_version": "5.03.02 (d5)", 
        "manufacturer": null, 
        "model": "QLE2562", 
        "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA", 
        "node_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "option_rom_version": "4.04.00 128", 
        "os_device_name": null, 
        "port_fcid": "0x000000", 
        "port_max_frame_size": null, 
        "port_speed": 0, 
        "port_state": "online", 
        "port_supported_speeds": [
            1, 
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k", 
        "port_type": null, 
        "port_wwn": "fdf8:f53e:61e4::18", 
        "serial_number": "", 
        "statistics": {
            "dumped_frames": 0, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": 0, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": 0, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 0, 
            "link_failure_count": 0, 
            "lip_count": 0, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": 0, 
            "primitive_seq_protocol_err_count": -1, 
            "primitiveitive_seq_protocol_err_count": -1, 
            "rx_frames": 0, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": 0, 
            "tx_words": -1
        }
    }, 
    {
        "discovered_ports": [], 
        "driver_name": null, 
        "driver_version": "8.03.01.05.05.06-k", 
        "fabric_name": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "firmware_version": null, 
        "hardware_version": "5.03.02 (d5)", 
        "manufacturer": null, 
        "model": "QLE2562", 
        "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA", 
        "node_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "option_rom_version": "4.04.00 128", 
        "os_device_name": null, 
        "port_fcid": "0x000000", 
        "port_max_frame_size": null, 
        "port_speed": 0, 
        "port_state": "online", 
        "port_supported_speeds": [
            1, 
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k", 
        "port_type": null, 
        "port_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "serial_number": "", 
        "statistics": {
            "dumped_frames": 0, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": 0, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": 0, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 0, 
            "link_failure_count": 0, 
            "lip_count": 0, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": 0, 
            "primitive_seq_protocol_err_count": -1, 
            "primitiveitive_seq_protocol_err_count": -1, 
            "rx_frames": 0, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": 0, 
            "tx_words": -1
        }
    }
]
""")
ports = [Port().update_not_none_values(item) for item in example]

from infi.hbaapi import Port
import json
example = json.loads(""" [
    {
        "discovered_ports": [], 
        "driver_name": null, 
        "driver_version": "8.03.01.05.05.06-k", 
        "fabric_name": "fc00:e968:6179::de52:7100", 
        "firmware_version": null, 
        "hardware_version": "5.03.02 (d5)", 
        "manufacturer": null, 
        "model": "QLE2562", 
        "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA", 
        "node_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "option_rom_version": "4.04.00 128", 
        "os_device_name": null, 
        "port_fcid": "0x4d0300", 
        "port_max_frame_size": null, 
        "port_speed": 4, 
        "port_state": "online", 
        "port_supported_speeds": [
            1, 
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k", 
        "port_type": "nport (fabric via point-to-point)", 
        "port_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "serial_number": "", 
        "statistics": {
            "dumped_frames": 0, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": 0, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": 0, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 0, 
            "link_failure_count": 1, 
            "lip_count": 0, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": 1, 
            "primitive_seq_protocol_err_count": -1, 
            "primitiveitive_seq_protocol_err_count": -1, 
            "rx_frames": 3475, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": 3473, 
            "tx_words": -1
        }
    }, 
    {
        "discovered_ports": [], 
        "driver_name": null, 
        "driver_version": "8.03.01.05.05.06-k", 
        "fabric_name": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "firmware_version": null, 
        "hardware_version": "5.03.02 (d5)", 
        "manufacturer": null, 
        "model": "QLE2562", 
        "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA", 
        "node_wwn": "fdf8:f53e:61e4::18", 
        "option_rom_version": "4.04.00 128", 
        "os_device_name": null, 
        "port_fcid": "0x011300", 
        "port_max_frame_size": null, 
        "port_speed": 8, 
        "port_state": "online", 
        "port_supported_speeds": [
            1, 
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k", 
        "port_type": "nport (fabric via point-to-point)", 
        "port_wwn": "fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b", 
        "serial_number": "", 
        "statistics": {
            "dumped_frames": 0, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": 0, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": 0, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 4, 
            "link_failure_count": 1, 
            "lip_count": 0, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": 1, 
            "primitive_seq_protocol_err_count": -1, 
            "primitiveitive_seq_protocol_err_count": -1, 
            "rx_frames": 3474, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": 3474, 
            "tx_words": -1
        }
    }, 
    {
        "discovered_ports": [], 
        "driver_name": null, 
        "driver_version": "8.03.01.05.05.06-k", 
        "fabric_name": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "firmware_version": null, 
        "hardware_version": "5.03.02 (d5)", 
        "manufacturer": null, 
        "model": "QLE2562", 
        "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA", 
        "node_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "option_rom_version": "4.04.00 128", 
        "os_device_name": null, 
        "port_fcid": "0x000000", 
        "port_max_frame_size": null, 
        "port_speed": 0, 
        "port_state": "online", 
        "port_supported_speeds": [
            1, 
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k", 
        "port_type": null, 
        "port_wwn": "fdf8:f53e:61e4::18", 
        "serial_number": "", 
        "statistics": {
            "dumped_frames": 0, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": 0, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": 0, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 0, 
            "link_failure_count": 0, 
            "lip_count": 0, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": 0, 
            "primitive_seq_protocol_err_count": -1, 
            "primitiveitive_seq_protocol_err_count": -1, 
            "rx_frames": 0, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": 0, 
            "tx_words": -1
        }
    }, 
    {
        "discovered_ports": [], 
        "driver_name": null, 
        "driver_version": "8.03.01.05.05.06-k", 
        "fabric_name": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "firmware_version": null, 
        "hardware_version": "5.03.02 (d5)", 
        "manufacturer": null, 
        "model": "QLE2562", 
        "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA", 
        "node_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "option_rom_version": "4.04.00 128", 
        "os_device_name": null, 
        "port_fcid": "0x000000", 
        "port_max_frame_size": null, 
        "port_speed": 0, 
        "port_state": "online", 
        "port_supported_speeds": [
            1, 
            2, 
            4, 
            8
        ], 
        "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k", 
        "port_type": null, 
        "port_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b", 
        "serial_number": "", 
        "statistics": {
            "dumped_frames": 0, 
            "error_frames": -1, 
            "fcp_control_requests": -1, 
            "fcp_input_megabytes": 0, 
            "fcp_input_requests": -1, 
            "fcp_output_megabytes": 0, 
            "fcp_output_requests": -1, 
            "invalid_crc_count": 0, 
            "invalid_tx_word_count": 0, 
            "link_failure_count": 0, 
            "lip_count": 0, 
            "loss_of_signal_count": 0, 
            "loss_of_sync_count": 0, 
            "nos_count": 0, 
            "primitive_seq_protocol_err_count": -1, 
            "primitiveitive_seq_protocol_err_count": -1, 
            "rx_frames": 0, 
            "rx_words": -1, 
            "seconds_since_last_reset": -1, 
            "tx_frames": 0, 
            "tx_words": -1
        }
    }
]
""")
ports = [Port().update_not_none_values(item) for item in example]
[     {         "discovered_ports": [],          "driver_name": null,          "driver_version": "8.03.01.05.05.06-k",          "fabric_name": "fc00:e968:6179::de52:7100",          "firmware_version": null,          "hardware_version": "5.03.02 (d5)",          "manufacturer": null,          "model": "QLE2562",          "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA",          "node_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b",          "option_rom_version": "4.04.00 128",          "os_device_name": null,          "port_fcid": "0x4d0300",          "port_max_frame_size": null,          "port_speed": 4,          "port_state": "online",          "port_supported_speeds": [             1,              2,              4,              8         ],          "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k",          "port_type": "nport (fabric via point-to-point)",          "port_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b",          "serial_number": "",          "statistics": {             "dumped_frames": 0,              "error_frames": -1,              "fcp_control_requests": -1,              "fcp_input_megabytes": 0,              "fcp_input_requests": -1,              "fcp_output_megabytes": 0,              "fcp_output_requests": -1,              "invalid_crc_count": 0,              "invalid_tx_word_count": 0,              "link_failure_count": 1,              "lip_count": 0,              "loss_of_signal_count": 0,              "loss_of_sync_count": 0,              "nos_count": 1,              "primitive_seq_protocol_err_count": -1,              "primitiveitive_seq_protocol_err_count": -1,              "rx_frames": 3475,              "rx_words": -1,              "seconds_since_last_reset": -1,              "tx_frames": 3473,              "tx_words": -1         }     },      {         "discovered_ports": [],          "driver_name": null,          "driver_version": "8.03.01.05.05.06-k",          "fabric_name": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b",          "firmware_version": null,          "hardware_version": "5.03.02 (d5)",          "manufacturer": null,          "model": "QLE2562",          "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA",          "node_wwn": "fdf8:f53e:61e4::18",          "option_rom_version": "4.04.00 128",          "os_device_name": null,          "port_fcid": "0x011300",          "port_max_frame_size": null,          "port_speed": 8,          "port_state": "online",          "port_supported_speeds": [             1,              2,              4,              8         ],          "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k",          "port_type": "nport (fabric via point-to-point)",          "port_wwn": "fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b",          "serial_number": "",          "statistics": {             "dumped_frames": 0,              "error_frames": -1,              "fcp_control_requests": -1,              "fcp_input_megabytes": 0,              "fcp_input_requests": -1,              "fcp_output_megabytes": 0,              "fcp_output_requests": -1,              "invalid_crc_count": 0,              "invalid_tx_word_count": 4,              "link_failure_count": 1,              "lip_count": 0,              "loss_of_signal_count": 0,              "loss_of_sync_count": 0,              "nos_count": 1,              "primitive_seq_protocol_err_count": -1,              "primitiveitive_seq_protocol_err_count": -1,              "rx_frames": 3474,              "rx_words": -1,              "seconds_since_last_reset": -1,              "tx_frames": 3474,              "tx_words": -1         }     },      {         "discovered_ports": [],          "driver_name": null,          "driver_version": "8.03.01.05.05.06-k",          "fabric_name": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b",          "firmware_version": null,          "hardware_version": "5.03.02 (d5)",          "manufacturer": null,          "model": "QLE2562",          "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA",          "node_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b",          "option_rom_version": "4.04.00 128",          "os_device_name": null,          "port_fcid": "0x000000",          "port_max_frame_size": null,          "port_speed": 0,          "port_state": "online",          "port_supported_speeds": [             1,              2,              4,              8         ],          "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k",          "port_type": null,          "port_wwn": "fdf8:f53e:61e4::18",          "serial_number": "",          "statistics": {             "dumped_frames": 0,              "error_frames": -1,              "fcp_control_requests": -1,              "fcp_input_megabytes": 0,              "fcp_input_requests": -1,              "fcp_output_megabytes": 0,              "fcp_output_requests": -1,              "invalid_crc_count": 0,              "invalid_tx_word_count": 0,              "link_failure_count": 0,              "lip_count": 0,              "loss_of_signal_count": 0,              "loss_of_sync_count": 0,              "nos_count": 0,              "primitive_seq_protocol_err_count": -1,              "primitiveitive_seq_protocol_err_count": -1,              "rx_frames": 0,              "rx_words": -1,              "seconds_since_last_reset": -1,              "tx_frames": 0,              "tx_words": -1         }     },      {         "discovered_ports": [],          "driver_name": null,          "driver_version": "8.03.01.05.05.06-k",          "fabric_name": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b",          "firmware_version": null,          "hardware_version": "5.03.02 (d5)",          "manufacturer": null,          "model": "QLE2562",          "model_description": "PCI-Express Dual Channel 8Gb Fibre Channel HBA",          "node_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b",          "option_rom_version": "4.04.00 128",          "os_device_name": null,          "port_fcid": "0x000000",          "port_max_frame_size": null,          "port_speed": 0,          "port_state": "online",          "port_supported_speeds": [             1,              2,              4,              8         ],          "port_symbolic_name": "QLE2562 FW:v5.03.02 DVR:v8.03.01.05.05.06-k",          "port_type": null,          "port_wwn": "fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b",          "serial_number": "",          "statistics": {             "dumped_frames": 0,              "error_frames": -1,              "fcp_control_requests": -1,              "fcp_input_megabytes": 0,              "fcp_input_requests": -1,              "fcp_output_megabytes": 0,              "fcp_output_requests": -1,              "invalid_crc_count": 0,              "invalid_tx_word_count": 0,              "link_failure_count": 0,              "lip_count": 0,              "loss_of_signal_count": 0,              "loss_of_sync_count": 0,              "nos_count": 0,              "primitive_seq_protocol_err_count": -1,              "primitiveitive_seq_protocol_err_count": -1,              "rx_frames": 0,              "rx_words": -1,              "seconds_since_last_reset": -1,              "tx_frames": 0,              "tx_words": -1         }     } ]