コード例 #1
0
    def setUpTestData(cls):

        vlan_groups = (
            VLANGroup(name='VLAN Group 1', slug='vlan-group-1'),
            VLANGroup(name='VLAN Group 2', slug='vlan-group-2'),
        )
        VLANGroup.objects.bulk_create(vlan_groups)

        vlans = (
            VLAN(name='VLAN 1', vid=1, group=vlan_groups[0]),
            VLAN(name='VLAN 2', vid=2, group=vlan_groups[0]),
            VLAN(name='VLAN 3', vid=3, group=vlan_groups[0]),
        )
        VLAN.objects.bulk_create(vlans)

        cls.create_data = [
            {
                'vid': 4,
                'name': 'VLAN 4',
                'group': vlan_groups[1].pk,
            },
            {
                'vid': 5,
                'name': 'VLAN 5',
                'group': vlan_groups[1].pk,
            },
            {
                'vid': 6,
                'name': 'VLAN 6',
                'group': vlan_groups[1].pk,
            },
        ]
コード例 #2
0
ファイル: test_views.py プロジェクト: stobib/netbox-1
    def setUpTestData(cls):

        sites = (
            Site(name='Site 1', slug='site-1'),
            Site(name='Site 2', slug='site-2'),
        )
        Site.objects.bulk_create(sites)

        vlangroups = (
            VLANGroup(name='VLAN Group 1', slug='vlan-group-1', site=sites[0]),
            VLANGroup(name='VLAN Group 2', slug='vlan-group-2', site=sites[1]),
        )
        VLANGroup.objects.bulk_create(vlangroups)

        roles = (
            Role(name='Role 1', slug='role-1'),
            Role(name='Role 2', slug='role-2'),
        )
        Role.objects.bulk_create(roles)

        VLAN.objects.bulk_create([
            VLAN(group=vlangroups[0], vid=101, name='VLAN101', site=sites[0], role=roles[0]),
            VLAN(group=vlangroups[0], vid=102, name='VLAN102', site=sites[0], role=roles[0]),
            VLAN(group=vlangroups[0], vid=103, name='VLAN103', site=sites[0], role=roles[0]),
        ])

        cls.form_data = {
            'site': sites[1].pk,
            'group': vlangroups[1].pk,
            'vid': 999,
            'name': 'VLAN999',
            'tenant': None,
            'status': VLANStatusChoices.STATUS_RESERVED,
            'role': roles[1].pk,
            'description': 'A new VLAN',
            'tags': 'Alpha,Bravo,Charlie',
        }

        cls.csv_data = (
            "vid,name,status",
            "104,VLAN104,Active",
            "105,VLAN105,Active",
            "106,VLAN106,Active",
        )

        cls.bulk_edit_data = {
            'site': sites[1].pk,
            'group': vlangroups[1].pk,
            'tenant': None,
            'status': VLANStatusChoices.STATUS_RESERVED,
            'role': roles[1].pk,
            'description': 'New description',
        }
コード例 #3
0
ファイル: test_filters.py プロジェクト: yuta2/netbox
    def setUpTestData(cls):

        regions = (
            Region(name='Test Region 1', slug='test-region-1'),
            Region(name='Test Region 2', slug='test-region-2'),
            Region(name='Test Region 3', slug='test-region-3'),
        )
        # Can't use bulk_create for models with MPTT fields
        for r in regions:
            r.save()

        sites = (
            Site(name='Test Site 1', slug='test-site-1', region=regions[0]),
            Site(name='Test Site 2', slug='test-site-2', region=regions[1]),
            Site(name='Test Site 3', slug='test-site-3', region=regions[2]),
        )
        Site.objects.bulk_create(sites)

        vrfs = (
            VRF(name='VRF 1', rd='65000:100'),
            VRF(name='VRF 2', rd='65000:200'),
            VRF(name='VRF 3', rd='65000:300'),
        )
        VRF.objects.bulk_create(vrfs)

        vlans = (
            VLAN(vid=1, name='VLAN 1'),
            VLAN(vid=2, name='VLAN 2'),
            VLAN(vid=3, name='VLAN 3'),
        )
        VLAN.objects.bulk_create(vlans)

        roles = (
            Role(name='Role 1', slug='role-1'),
            Role(name='Role 2', slug='role-2'),
            Role(name='Role 3', slug='role-3'),
        )
        Role.objects.bulk_create(roles)

        prefixes = (
            Prefix(family=4, prefix='10.0.0.0/24', site=None, vrf=None, vlan=None, role=None, is_pool=True),
            Prefix(family=4, prefix='10.0.1.0/24', site=sites[0], vrf=vrfs[0], vlan=vlans[0], role=roles[0]),
            Prefix(family=4, prefix='10.0.2.0/24', site=sites[1], vrf=vrfs[1], vlan=vlans[1], role=roles[1], status=PrefixStatusChoices.STATUS_DEPRECATED),
            Prefix(family=4, prefix='10.0.3.0/24', site=sites[2], vrf=vrfs[2], vlan=vlans[2], role=roles[2], status=PrefixStatusChoices.STATUS_RESERVED),
            Prefix(family=6, prefix='2001:db8::/64', site=None, vrf=None, vlan=None, role=None, is_pool=True),
            Prefix(family=6, prefix='2001:db8:0:1::/64', site=sites[0], vrf=vrfs[0], vlan=vlans[0], role=roles[0]),
            Prefix(family=6, prefix='2001:db8:0:2::/64', site=sites[1], vrf=vrfs[1], vlan=vlans[1], role=roles[1], status=PrefixStatusChoices.STATUS_DEPRECATED),
            Prefix(family=6, prefix='2001:db8:0:3::/64', site=sites[2], vrf=vrfs[2], vlan=vlans[2], role=roles[2], status=PrefixStatusChoices.STATUS_RESERVED),
            Prefix(family=4, prefix='10.0.0.0/16'),
            Prefix(family=6, prefix='2001:db8::/32'),
        )
        Prefix.objects.bulk_create(prefixes)
コード例 #4
0
    def setUp(self):
        user = create_test_user(permissions=['ipam.view_vlan'])
        self.client = Client()
        self.client.force_login(user)

        vlangroup = VLANGroup(name='VLAN Group 1', slug='vlan-group-1')
        vlangroup.save()

        VLAN.objects.bulk_create([
            VLAN(group=vlangroup, vid=101, name='VLAN101'),
            VLAN(group=vlangroup, vid=102, name='VLAN102'),
            VLAN(group=vlangroup, vid=103, name='VLAN103'),
        ])
コード例 #5
0
    def test_get_next_available_vid(self):

        vlangroup = VLANGroup.objects.create(name='VLAN Group 1',
                                             slug='vlan-group-1')
        VLAN.objects.bulk_create((
            VLAN(name='VLAN 1', vid=1, group=vlangroup),
            VLAN(name='VLAN 2', vid=2, group=vlangroup),
            VLAN(name='VLAN 3', vid=3, group=vlangroup),
            VLAN(name='VLAN 5', vid=5, group=vlangroup),
        ))
        self.assertEqual(vlangroup.get_next_available_vid(), 4)

        VLAN.objects.bulk_create((VLAN(name='VLAN 4', vid=4,
                                       group=vlangroup), ))
        self.assertEqual(vlangroup.get_next_available_vid(), 6)
コード例 #6
0
ファイル: test_api.py プロジェクト: JonathonReinhart/netbox
    def setUpTestData(cls):

        clustertype = ClusterType.objects.create(name='Test Cluster Type 1',
                                                 slug='test-cluster-type-1')
        cluster = Cluster.objects.create(name='Test Cluster 1',
                                         type=clustertype)
        virtualmachine = VirtualMachine.objects.create(cluster=cluster,
                                                       name='Test VM 1')

        interfaces = (
            VMInterface(virtual_machine=virtualmachine, name='Interface 1'),
            VMInterface(virtual_machine=virtualmachine, name='Interface 2'),
            VMInterface(virtual_machine=virtualmachine, name='Interface 3'),
        )
        VMInterface.objects.bulk_create(interfaces)

        vlans = (
            VLAN(name='VLAN 1', vid=1),
            VLAN(name='VLAN 2', vid=2),
            VLAN(name='VLAN 3', vid=3),
        )
        VLAN.objects.bulk_create(vlans)

        cls.create_data = [
            {
                'virtual_machine': virtualmachine.pk,
                'name': 'Interface 4',
                'mode': InterfaceModeChoices.MODE_TAGGED,
                'tagged_vlans': [vlans[0].pk, vlans[1].pk],
                'untagged_vlan': vlans[2].pk,
            },
            {
                'virtual_machine': virtualmachine.pk,
                'name': 'Interface 5',
                'mode': InterfaceModeChoices.MODE_TAGGED,
                'bridge': interfaces[0].pk,
                'tagged_vlans': [vlans[0].pk, vlans[1].pk],
                'untagged_vlan': vlans[2].pk,
            },
            {
                'virtual_machine': virtualmachine.pk,
                'name': 'Interface 6',
                'mode': InterfaceModeChoices.MODE_TAGGED,
                'parent': interfaces[1].pk,
                'tagged_vlans': [vlans[0].pk, vlans[1].pk],
                'untagged_vlan': vlans[2].pk,
            },
        ]
コード例 #7
0
    def setUpTestData(cls):
        device = create_test_device('Device 1')

        Interface.objects.bulk_create([
            Interface(device=device, name='Interface 1'),
            Interface(device=device, name='Interface 2'),
            Interface(device=device, name='Interface 3'),
        ])

        vlans = (
            VLAN(vid=1, name='VLAN1', site=device.site),
            VLAN(vid=101, name='VLAN101', site=device.site),
            VLAN(vid=102, name='VLAN102', site=device.site),
            VLAN(vid=103, name='VLAN103', site=device.site),
        )
        VLAN.objects.bulk_create(vlans)

        cls.form_data = {
            'device': device.pk,
            'virtual_machine': None,
            'name': 'Interface X',
            'type': InterfaceTypeChoices.TYPE_1GE_GBIC,
            'enabled': False,
            'lag': None,
            'mac_address': EUI('01:02:03:04:05:06'),
            'mtu': 2000,
            'mgmt_only': True,
            'description': 'New description',
            'mode': InterfaceModeChoices.MODE_TAGGED,
            'untagged_vlan': vlans[0].pk,
            'tagged_vlans': [v.pk for v in vlans[1:4]],
            'tags': 'Alpha,Bravo,Charlie',

            # Extraneous model fields
            'cable': None,
            'connection_status': None,
        }

        cls.csv_data = (
            "device,name,type",
            "Device 1,Interface 4,1000BASE-T (1GE)",
            "Device 1,Interface 5,1000BASE-T (1GE)",
            "Device 1,Interface 6,1000BASE-T (1GE)",
        )
コード例 #8
0
    def create_mgmt_vlan(self, site, site_no):
        vlan_id = 3000 + int(site_no)
        try:
            vlan = VLAN.objects.get(site=site, vid=vlan_id)
            self.log_info("Mgmt vlan %s already present, carrying on." % vlan)

            return vlan
        except VLAN.DoesNotExist:
            pass

        vlan = VLAN(site=site,
                    name="Mgmt %s" % site.name,
                    vid=vlan_id,
                    role=Role.objects.get(name='Mgmt'))

        vlan.save()
        self.log_success("Created mgmt VLAN %s" % vlan)

        return vlan
コード例 #9
0
    def setUpTestData(cls):

        groups = (
            WirelessLANGroup(name='Wireless LAN Group 1',
                             slug='wireless-lan-group-1'),
            WirelessLANGroup(name='Wireless LAN Group 2',
                             slug='wireless-lan-group-2'),
            WirelessLANGroup(name='Wireless LAN Group 3',
                             slug='wireless-lan-group-3'),
        )
        for group in groups:
            group.save()

        vlans = (
            VLAN(name='VLAN1', vid=1),
            VLAN(name='VLAN2', vid=2),
            VLAN(name='VLAN3', vid=3),
        )
        VLAN.objects.bulk_create(vlans)

        wireless_lans = (
            WirelessLAN(ssid='WLAN1',
                        group=groups[0],
                        vlan=vlans[0],
                        auth_type=WirelessAuthTypeChoices.TYPE_OPEN,
                        auth_cipher=WirelessAuthCipherChoices.CIPHER_AUTO,
                        auth_psk='PSK1'),
            WirelessLAN(ssid='WLAN2',
                        group=groups[1],
                        vlan=vlans[1],
                        auth_type=WirelessAuthTypeChoices.TYPE_WEP,
                        auth_cipher=WirelessAuthCipherChoices.CIPHER_TKIP,
                        auth_psk='PSK2'),
            WirelessLAN(ssid='WLAN3',
                        group=groups[2],
                        vlan=vlans[2],
                        auth_type=WirelessAuthTypeChoices.TYPE_WPA_PERSONAL,
                        auth_cipher=WirelessAuthCipherChoices.CIPHER_AES,
                        auth_psk='PSK3'),
        )
        WirelessLAN.objects.bulk_create(wireless_lans)
コード例 #10
0
ファイル: test_filters.py プロジェクト: fireman0865/allbox
    def setUpTestData(cls):

        regions = (
            Region(name='Test Region 1', slug='test-region-1'),
            Region(name='Test Region 2', slug='test-region-2'),
            Region(name='Test Region 3', slug='test-region-3'),
        )
        # Can't use bulk_create for models with MPTT fields
        for r in regions:
            r.save()

        sites = (
            Site(name='Test Site 1', slug='test-site-1', region=regions[0]),
            Site(name='Test Site 2', slug='test-site-2', region=regions[1]),
            Site(name='Test Site 3', slug='test-site-3', region=regions[2]),
        )
        Site.objects.bulk_create(sites)

        roles = (
            Role(name='Role 1', slug='role-1'),
            Role(name='Role 2', slug='role-2'),
            Role(name='Role 3', slug='role-3'),
        )
        Role.objects.bulk_create(roles)

        groups = (
            VLANGroup(name='VLAN Group 1', slug='vlan-group-1', site=sites[0]),
            VLANGroup(name='VLAN Group 2', slug='vlan-group-2', site=sites[1]),
            VLANGroup(name='VLAN Group 3', slug='vlan-group-3', site=None),
        )
        VLANGroup.objects.bulk_create(groups)

        tenant_groups = (
            TenantGroup(name='Tenant group 1', slug='tenant-group-1'),
            TenantGroup(name='Tenant group 2', slug='tenant-group-2'),
            TenantGroup(name='Tenant group 3', slug='tenant-group-3'),
        )
        for tenantgroup in tenant_groups:
            tenantgroup.save()

        tenants = (
            Tenant(name='Tenant 1', slug='tenant-1', group=tenant_groups[0]),
            Tenant(name='Tenant 2', slug='tenant-2', group=tenant_groups[1]),
            Tenant(name='Tenant 3', slug='tenant-3', group=tenant_groups[2]),
        )
        Tenant.objects.bulk_create(tenants)

        vlans = (
            VLAN(vid=101, name='VLAN 101', site=sites[0], group=groups[0], role=roles[0], tenant=tenants[0], status=VLANStatusChoices.STATUS_ACTIVE),
            VLAN(vid=102, name='VLAN 102', site=sites[0], group=groups[0], role=roles[0], tenant=tenants[0], status=VLANStatusChoices.STATUS_ACTIVE),
            VLAN(vid=201, name='VLAN 201', site=sites[1], group=groups[1], role=roles[1], tenant=tenants[1], status=VLANStatusChoices.STATUS_DEPRECATED),
            VLAN(vid=202, name='VLAN 202', site=sites[1], group=groups[1], role=roles[1], tenant=tenants[1], status=VLANStatusChoices.STATUS_DEPRECATED),
            VLAN(vid=301, name='VLAN 301', site=sites[2], group=groups[2], role=roles[2], tenant=tenants[2], status=VLANStatusChoices.STATUS_RESERVED),
            VLAN(vid=302, name='VLAN 302', site=sites[2], group=groups[2], role=roles[2], tenant=tenants[2], status=VLANStatusChoices.STATUS_RESERVED),
        )
        VLAN.objects.bulk_create(vlans)
コード例 #11
0
    def mutate_and_get_payload(cls, input, context, info):
        site = input.get('site')
        group = input.get('group')
        tenant = input.get('tenant')
        role = input.get('role')

        temp = VLAN()

        if not_none(site):
            temp.site = Site.objects.get(pk=from_global_id(site)[1])

        if not_none(group):
            temp.group = VLANGroup.objects.get(pk=from_global_id(group)[1])

        if not_none(tenant):
            temp.tenant = Tenant.objects.get(pk=from_global_id(tenant)[1])

        if not_none(role):
            temp.role = Role.objects.get(pk=from_global_id(role)[1])

        fields = ['name', 'vid', 'name', 'description']
        return NewVLAN(vlan=set_and_save(fields, input, temp))
コード例 #12
0
ファイル: test_views.py プロジェクト: zhyh329/netbox
    def setUpTestData(cls):

        site = Site.objects.create(name='Site 1', slug='site-1')
        devicerole = DeviceRole.objects.create(name='Device Role 1',
                                               slug='device-role-1')
        clustertype = ClusterType.objects.create(name='Cluster Type 1',
                                                 slug='cluster-type-1')
        cluster = Cluster.objects.create(name='Cluster 1',
                                         type=clustertype,
                                         site=site)
        virtualmachines = (
            VirtualMachine(name='Virtual Machine 1',
                           cluster=cluster,
                           role=devicerole),
            VirtualMachine(name='Virtual Machine 2',
                           cluster=cluster,
                           role=devicerole),
        )
        VirtualMachine.objects.bulk_create(virtualmachines)

        VMInterface.objects.bulk_create([
            VMInterface(virtual_machine=virtualmachines[0],
                        name='Interface 1'),
            VMInterface(virtual_machine=virtualmachines[0],
                        name='Interface 2'),
            VMInterface(virtual_machine=virtualmachines[0],
                        name='Interface 3'),
        ])

        vlans = (
            VLAN(vid=1, name='VLAN1', site=site),
            VLAN(vid=101, name='VLAN101', site=site),
            VLAN(vid=102, name='VLAN102', site=site),
            VLAN(vid=103, name='VLAN103', site=site),
        )
        VLAN.objects.bulk_create(vlans)

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

        cls.form_data = {
            'virtual_machine': virtualmachines[1].pk,
            'name': 'Interface X',
            'enabled': False,
            'mac_address': EUI('01-02-03-04-05-06'),
            'mtu': 2000,
            'description': 'New description',
            'mode': InterfaceModeChoices.MODE_TAGGED,
            'untagged_vlan': vlans[0].pk,
            'tagged_vlans': [v.pk for v in vlans[1:4]],
            'tags': [t.pk for t in tags],
        }

        cls.bulk_create_data = {
            'virtual_machine': virtualmachines[1].pk,
            'name_pattern': 'Interface [4-6]',
            'enabled': False,
            'mac_address': EUI('01-02-03-04-05-06'),
            'mtu': 2000,
            'description': 'New description',
            'mode': InterfaceModeChoices.MODE_TAGGED,
            'untagged_vlan': vlans[0].pk,
            'tagged_vlans': [v.pk for v in vlans[1:4]],
            'tags': [t.pk for t in tags],
        }

        cls.csv_data = (
            "virtual_machine,name",
            "Virtual Machine 2,Interface 4",
            "Virtual Machine 2,Interface 5",
            "Virtual Machine 2,Interface 6",
        )

        cls.bulk_edit_data = {
            'enabled': False,
            'mtu': 2000,
            'description': 'New description',
            'mode': InterfaceModeChoices.MODE_TAGGED,
            'untagged_vlan': vlans[0].pk,
            'tagged_vlans': [v.pk for v in vlans[1:4]],
        }
コード例 #13
0
ファイル: test_views.py プロジェクト: stobib/netbox-1
    def setUpTestData(cls):

        site = Site.objects.create(name='Site 1', slug='site-1')
        devicerole = DeviceRole.objects.create(name='Device Role 1',
                                               slug='device-role-1')
        clustertype = ClusterType.objects.create(name='Cluster Type 1',
                                                 slug='cluster-type-1')
        cluster = Cluster.objects.create(name='Cluster 1',
                                         type=clustertype,
                                         site=site)
        virtualmachines = (
            VirtualMachine(name='Virtual Machine 1',
                           cluster=cluster,
                           role=devicerole),
            VirtualMachine(name='Virtual Machine 2',
                           cluster=cluster,
                           role=devicerole),
        )
        VirtualMachine.objects.bulk_create(virtualmachines)

        Interface.objects.bulk_create([
            Interface(virtual_machine=virtualmachines[0],
                      name='Interface 1',
                      type=InterfaceTypeChoices.TYPE_VIRTUAL),
            Interface(virtual_machine=virtualmachines[0],
                      name='Interface 2',
                      type=InterfaceTypeChoices.TYPE_VIRTUAL),
            Interface(virtual_machine=virtualmachines[0],
                      name='Interface 3',
                      type=InterfaceTypeChoices.TYPE_VIRTUAL),
        ])

        vlans = (
            VLAN(vid=1, name='VLAN1', site=site),
            VLAN(vid=101, name='VLAN101', site=site),
            VLAN(vid=102, name='VLAN102', site=site),
            VLAN(vid=103, name='VLAN103', site=site),
        )
        VLAN.objects.bulk_create(vlans)

        cls.form_data = {
            'virtual_machine': virtualmachines[1].pk,
            'name': 'Interface X',
            'type': InterfaceTypeChoices.TYPE_VIRTUAL,
            'enabled': False,
            'mgmt_only': False,
            'mac_address': EUI('01-02-03-04-05-06'),
            'mtu': 2000,
            'description': 'New description',
            'mode': InterfaceModeChoices.MODE_TAGGED,
            'untagged_vlan': vlans[0].pk,
            'tagged_vlans': [v.pk for v in vlans[1:4]],
            'tags': 'Alpha,Bravo,Charlie',
        }

        cls.bulk_create_data = {
            'virtual_machine': virtualmachines[1].pk,
            'name_pattern': 'Interface [4-6]',
            'type': InterfaceTypeChoices.TYPE_VIRTUAL,
            'enabled': False,
            'mgmt_only': False,
            'mac_address': EUI('01-02-03-04-05-06'),
            'mtu': 2000,
            'description': 'New description',
            'mode': InterfaceModeChoices.MODE_TAGGED,
            'untagged_vlan': vlans[0].pk,
            'tagged_vlans': [v.pk for v in vlans[1:4]],
            'tags': 'Alpha,Bravo,Charlie',
        }

        cls.bulk_edit_data = {
            'virtual_machine': virtualmachines[1].pk,
            'enabled': False,
            'mtu': 2000,
            'description': 'New description',
            'mode': InterfaceModeChoices.MODE_TAGGED,
            # 'untagged_vlan': vlans[0].pk,
            # 'tagged_vlans': [v.pk for v in vlans[1:4]],
        }

        cls.csv_data = (
            "device,name,type",
            "Device 1,Interface 4,1000BASE-T (1GE)",
            "Device 1,Interface 5,1000BASE-T (1GE)",
            "Device 1,Interface 6,1000BASE-T (1GE)",
        )
コード例 #14
0
ファイル: test_filters.py プロジェクト: stuntguy3000/netbox
    def setUpTestData(cls):

        regions = (
            Region(name='Test Region 1', slug='test-region-1'),
            Region(name='Test Region 2', slug='test-region-2'),
            Region(name='Test Region 3', slug='test-region-3'),
        )
        # Can't use bulk_create for models with MPTT fields
        for r in regions:
            r.save()

        sites = (
            Site(name='Test Site 1', slug='test-site-1', region=regions[0]),
            Site(name='Test Site 2', slug='test-site-2', region=regions[1]),
            Site(name='Test Site 3', slug='test-site-3', region=regions[2]),
        )
        Site.objects.bulk_create(sites)

        route_targets = (
            RouteTarget(name='65000:100'),
            RouteTarget(name='65000:200'),
            RouteTarget(name='65000:300'),
        )
        RouteTarget.objects.bulk_create(route_targets)

        vrfs = (
            VRF(name='VRF 1', rd='65000:100'),
            VRF(name='VRF 2', rd='65000:200'),
            VRF(name='VRF 3', rd='65000:300'),
        )
        VRF.objects.bulk_create(vrfs)
        vrfs[0].import_targets.add(route_targets[0], route_targets[1],
                                   route_targets[2])
        vrfs[1].export_targets.add(route_targets[1])
        vrfs[2].export_targets.add(route_targets[2])

        vlans = (
            VLAN(vid=1, name='VLAN 1'),
            VLAN(vid=2, name='VLAN 2'),
            VLAN(vid=3, name='VLAN 3'),
        )
        VLAN.objects.bulk_create(vlans)

        roles = (
            Role(name='Role 1', slug='role-1'),
            Role(name='Role 2', slug='role-2'),
            Role(name='Role 3', slug='role-3'),
        )
        Role.objects.bulk_create(roles)

        tenant_groups = (
            TenantGroup(name='Tenant group 1', slug='tenant-group-1'),
            TenantGroup(name='Tenant group 2', slug='tenant-group-2'),
            TenantGroup(name='Tenant group 3', slug='tenant-group-3'),
        )
        for tenantgroup in tenant_groups:
            tenantgroup.save()

        tenants = (
            Tenant(name='Tenant 1', slug='tenant-1', group=tenant_groups[0]),
            Tenant(name='Tenant 2', slug='tenant-2', group=tenant_groups[1]),
            Tenant(name='Tenant 3', slug='tenant-3', group=tenant_groups[2]),
        )
        Tenant.objects.bulk_create(tenants)

        prefixes = (
            Prefix(prefix='10.0.0.0/24',
                   tenant=None,
                   site=None,
                   vrf=None,
                   vlan=None,
                   role=None,
                   is_pool=True),
            Prefix(prefix='10.0.1.0/24',
                   tenant=tenants[0],
                   site=sites[0],
                   vrf=vrfs[0],
                   vlan=vlans[0],
                   role=roles[0]),
            Prefix(prefix='10.0.2.0/24',
                   tenant=tenants[1],
                   site=sites[1],
                   vrf=vrfs[1],
                   vlan=vlans[1],
                   role=roles[1],
                   status=PrefixStatusChoices.STATUS_DEPRECATED),
            Prefix(prefix='10.0.3.0/24',
                   tenant=tenants[2],
                   site=sites[2],
                   vrf=vrfs[2],
                   vlan=vlans[2],
                   role=roles[2],
                   status=PrefixStatusChoices.STATUS_RESERVED),
            Prefix(prefix='2001:db8::/64',
                   tenant=None,
                   site=None,
                   vrf=None,
                   vlan=None,
                   role=None,
                   is_pool=True),
            Prefix(prefix='2001:db8:0:1::/64',
                   tenant=tenants[0],
                   site=sites[0],
                   vrf=vrfs[0],
                   vlan=vlans[0],
                   role=roles[0]),
            Prefix(prefix='2001:db8:0:2::/64',
                   tenant=tenants[1],
                   site=sites[1],
                   vrf=vrfs[1],
                   vlan=vlans[1],
                   role=roles[1],
                   status=PrefixStatusChoices.STATUS_DEPRECATED),
            Prefix(prefix='2001:db8:0:3::/64',
                   tenant=tenants[2],
                   site=sites[2],
                   vrf=vrfs[2],
                   vlan=vlans[2],
                   role=roles[2],
                   status=PrefixStatusChoices.STATUS_RESERVED),
            Prefix(prefix='10.0.0.0/16'),
            Prefix(prefix='2001:db8::/32'),
        )
        Prefix.objects.bulk_create(prefixes)