Exemple #1
0
    def _connection_sync(server):
        wwpns = []
        for port in HbaPort.objects.filter(hba_card__server=server):
            wwpns.append(port.wwpn)

        port_info_list = get_connection_info(wwpns)

        if not port_info_list:
            return False

        for port_info in port_info_list:
            switch = Switch.objects.get_or_create(
                ip_addr=port_info.get('SW_IP'),
                vf_vsan=port_info.get('VSAN'))[0]
            switch.username = port_info.get('SW_USR')
            switch.password = port_info.get('SW_PSW')
            switch.vendor = port_info.get('SW_VDR')
            switch_port = SwitchPort.objects.get_or_create(
                port_index=port_info.get('Port'),
                switch=switch)[0]
            switch.save()
            switch_port.save()
            hba_port = HbaPort.objects.get(wwpn=port_info.get('WWPN'))
            hba_port.connection = switch_port
            hba_port.save()

        return True
Exemple #2
0
    def _connection_sync(server):
        wwpns = []
        for port in HbaPort.objects.filter(hba_card__server=server):
            wwpns.append(port.wwpn)

        port_info_list = get_connection_info(*wwpns)

        if not port_info_list:
            return False

        for port_info in port_info_list:

            if port_info.get('SW_VDR') == 'cisco':
                switch = Switch.objects.get_or_create(
                    ip_addr=port_info.get('SW_IP'))[0]
            elif port_info.get('SW_VDR') == 'brocade':
                switch = Switch.objects.get_or_create(
                    ip_addr=port_info.get('SW_IP'),
                    vf=port_info.get('VF'))[0]

            if switch.access is not True:
                """
                means this switch is auto detected by this system and added to
                the database
                """
                switch.vendor = port_info.get('SW_VDR')
                switch.username = port_info.get('SW_USR')
                switch.password = port_info.get('SW_PSW')
                switch.save()

            switch_port = SwitchPort.objects.get_or_create(
                port_index=port_info.get('Port'),
                switch=switch)[0]

            if port_info.get('SW_VDR') == 'cisco':
                switch_port.vsan = port_info.get('VSAN')
            switch_port.save()
            hba_port = HbaPort.objects.get(wwpn=port_info.get('WWPN'))
            hba_port.connection = switch_port
            hba_port.save()

        return True