Exemplo n.º 1
0
    def test_trace(self):
        device = create_test_device('Device 1')

        circuittermination = CircuitTermination.objects.first()
        interface = Interface.objects.create(device=device, name='Interface 1')
        Cable(termination_a=circuittermination, termination_b=interface).save()

        response = self.client.get(
            reverse('circuits:circuittermination_trace',
                    kwargs={'pk': circuittermination.pk}))
        self.assertHttpStatus(response, 200)
Exemplo n.º 2
0
    def setUpTestData(cls):
        device = create_test_device('test-device')
        interfaces = [
            Interface(device=device,
                      name=f'radio{i}',
                      type=InterfaceTypeChoices.TYPE_80211AC,
                      rf_channel=WirelessChannelChoices.CHANNEL_5G_32,
                      rf_channel_frequency=5160,
                      rf_channel_width=20) for i in range(12)
        ]
        Interface.objects.bulk_create(interfaces)

        wireless_links = (
            WirelessLink(ssid='LINK1',
                         interface_a=interfaces[0],
                         interface_b=interfaces[1]),
            WirelessLink(ssid='LINK2',
                         interface_a=interfaces[2],
                         interface_b=interfaces[3]),
            WirelessLink(ssid='LINK3',
                         interface_a=interfaces[4],
                         interface_b=interfaces[5]),
        )
        WirelessLink.objects.bulk_create(wireless_links)

        cls.create_data = [
            {
                'interface_a': interfaces[6].pk,
                'interface_b': interfaces[7].pk,
                'ssid': 'LINK4',
            },
            {
                'interface_a': interfaces[8].pk,
                'interface_b': interfaces[9].pk,
                'ssid': 'LINK5',
            },
            {
                'interface_a': interfaces[10].pk,
                'interface_b': interfaces[11].pk,
                'ssid': 'LINK6',
            },
        ]
Exemplo n.º 3
0
    def setUpTestData(cls):
        device = create_test_device('test-device')
        interfaces = [
            Interface(device=device,
                      name=f'radio{i}',
                      type=InterfaceTypeChoices.TYPE_80211AC,
                      rf_channel=WirelessChannelChoices.CHANNEL_5G_32,
                      rf_channel_frequency=5160,
                      rf_channel_width=20) for i in range(12)
        ]
        Interface.objects.bulk_create(interfaces)

        WirelessLink(interface_a=interfaces[0],
                     interface_b=interfaces[1],
                     ssid='LINK1').save()
        WirelessLink(interface_a=interfaces[2],
                     interface_b=interfaces[3],
                     ssid='LINK2').save()
        WirelessLink(interface_a=interfaces[4],
                     interface_b=interfaces[5],
                     ssid='LINK3').save()

        tags = create_tags('Alpha', 'Bravo', 'Charlie')

        cls.form_data = {
            'interface_a': interfaces[6].pk,
            'interface_b': interfaces[7].pk,
            'status': LinkStatusChoices.STATUS_PLANNED,
            'tags': [t.pk for t in tags],
        }

        cls.csv_data = (
            "interface_a,interface_b,status",
            f"{interfaces[6].pk},{interfaces[7].pk},connected",
            f"{interfaces[8].pk},{interfaces[9].pk},connected",
            f"{interfaces[10].pk},{interfaces[11].pk},connected",
        )

        cls.bulk_edit_data = {
            'status': LinkStatusChoices.STATUS_PLANNED,
        }
Exemplo n.º 4
0
    def setUpTestData(cls):

        device1 = create_test_device('device1')
        device2 = create_test_device('device2')
        device3 = create_test_device('device3')

        interfaces = (
            Interface(device=device1, name='eth0', type='other'),
            Interface(device=device1, name='eth1', type='other'),
            Interface(device=device1, name='eth2', type='other'),
            Interface(device=device2, name='eth0', type='other'),
            Interface(device=device2, name='eth1', type='other'),
            Interface(device=device2, name='eth2', type='other'),
            Interface(device=device3, name='eth0', type='other'),
            Interface(device=device3, name='eth1', type='other'),
            Interface(device=device3, name='eth2', type='other'),
        )
        Interface.objects.bulk_create(interfaces)

        ip_addresses = (
            IPAddress(address=IPNetwork('192.168.0.2/24'), assigned_object=interfaces[0]),
            IPAddress(address=IPNetwork('192.168.1.2/24'), assigned_object=interfaces[1]),
            IPAddress(address=IPNetwork('192.168.2.2/24'), assigned_object=interfaces[2]),
            IPAddress(address=IPNetwork('192.168.0.3/24'), assigned_object=interfaces[3]),
            IPAddress(address=IPNetwork('192.168.1.3/24'), assigned_object=interfaces[4]),
            IPAddress(address=IPNetwork('192.168.2.3/24'), assigned_object=interfaces[5]),
            IPAddress(address=IPNetwork('192.168.0.4/24'), assigned_object=interfaces[6]),
            IPAddress(address=IPNetwork('192.168.1.4/24'), assigned_object=interfaces[7]),
            IPAddress(address=IPNetwork('192.168.2.4/24'), assigned_object=interfaces[8]),
        )
        IPAddress.objects.bulk_create(ip_addresses)

        fhrp_groups = (
            FHRPGroup(protocol=FHRPGroupProtocolChoices.PROTOCOL_VRRP2, group_id=10),
            FHRPGroup(protocol=FHRPGroupProtocolChoices.PROTOCOL_VRRP2, group_id=20),
            FHRPGroup(protocol=FHRPGroupProtocolChoices.PROTOCOL_VRRP2, group_id=30),
        )
        FHRPGroup.objects.bulk_create(fhrp_groups)

        fhrp_group_assignments = (
            FHRPGroupAssignment(group=fhrp_groups[0], interface=interfaces[0], priority=10),
            FHRPGroupAssignment(group=fhrp_groups[1], interface=interfaces[1], priority=10),
            FHRPGroupAssignment(group=fhrp_groups[2], interface=interfaces[2], priority=10),
            FHRPGroupAssignment(group=fhrp_groups[0], interface=interfaces[3], priority=20),
            FHRPGroupAssignment(group=fhrp_groups[1], interface=interfaces[4], priority=20),
            FHRPGroupAssignment(group=fhrp_groups[2], interface=interfaces[5], priority=20),
        )
        FHRPGroupAssignment.objects.bulk_create(fhrp_group_assignments)

        cls.create_data = [
            {
                'group': fhrp_groups[0].pk,
                'interface_type': 'dcim.interface',
                'interface_id': interfaces[6].pk,
                'priority': 30,
            },
            {
                'group': fhrp_groups[1].pk,
                'interface_type': 'dcim.interface',
                'interface_id': interfaces[7].pk,
                'priority': 30,
            },
            {
                'group': fhrp_groups[2].pk,
                'interface_type': 'dcim.interface',
                'interface_id': interfaces[8].pk,
                'priority': 30,
            },
        ]
Exemplo n.º 5
0
    def setUpTestData(cls):

        devices = (
            create_test_device('device1'),
            create_test_device('device2'),
            create_test_device('device3'),
            create_test_device('device4'),
        )

        interfaces = (
            Interface(device=devices[0],
                      name='Interface 1',
                      type=InterfaceTypeChoices.TYPE_80211AC),
            Interface(device=devices[0],
                      name='Interface 2',
                      type=InterfaceTypeChoices.TYPE_80211AC),
            Interface(device=devices[1],
                      name='Interface 3',
                      type=InterfaceTypeChoices.TYPE_80211AC),
            Interface(device=devices[1],
                      name='Interface 4',
                      type=InterfaceTypeChoices.TYPE_80211AC),
            Interface(device=devices[2],
                      name='Interface 5',
                      type=InterfaceTypeChoices.TYPE_80211AC),
            Interface(device=devices[2],
                      name='Interface 6',
                      type=InterfaceTypeChoices.TYPE_80211AC),
            Interface(device=devices[3],
                      name='Interface 7',
                      type=InterfaceTypeChoices.TYPE_80211AC),
            Interface(device=devices[3],
                      name='Interface 8',
                      type=InterfaceTypeChoices.TYPE_80211AC),
        )
        Interface.objects.bulk_create(interfaces)

        # Wireless links
        WirelessLink(interface_a=interfaces[0],
                     interface_b=interfaces[2],
                     ssid='LINK1',
                     status=LinkStatusChoices.STATUS_CONNECTED,
                     auth_type=WirelessAuthTypeChoices.TYPE_OPEN,
                     auth_cipher=WirelessAuthCipherChoices.CIPHER_AUTO,
                     auth_psk='PSK1').save()
        WirelessLink(interface_a=interfaces[1],
                     interface_b=interfaces[3],
                     ssid='LINK2',
                     status=LinkStatusChoices.STATUS_PLANNED,
                     auth_type=WirelessAuthTypeChoices.TYPE_WEP,
                     auth_cipher=WirelessAuthCipherChoices.CIPHER_TKIP,
                     auth_psk='PSK2').save()
        WirelessLink(interface_a=interfaces[4],
                     interface_b=interfaces[6],
                     ssid='LINK3',
                     status=LinkStatusChoices.STATUS_DECOMMISSIONING,
                     auth_type=WirelessAuthTypeChoices.TYPE_WPA_PERSONAL,
                     auth_cipher=WirelessAuthCipherChoices.CIPHER_AES,
                     auth_psk='PSK3').save()
        WirelessLink(interface_a=interfaces[5],
                     interface_b=interfaces[7],
                     ssid='LINK4').save()