'Arranges IO ports.
Arranges the registered IO ports and puts a pingable port in the
first place as the main portal.'

def arrange_io_ports(self, reg_port_white_list, iscsi_initiator_ips):

    random.shuffle(reg_port_white_list)
    random.shuffle(iscsi_initiator_ips)
    main_portal_index = None
    for (index, port) in enumerate(reg_port_white_list):
        for initiator_ip in iscsi_initiator_ips:
            if self.client.ping_node(port, initiator_ip):
                main_portal_index = index
                break
        else:
            continue
        break
    if (main_portal_index is not None):
        reg_port_white_list.insert(0, reg_port_white_list.pop(main_portal_index))
    return reg_port_white_list
