def setUp(self): self.client = Client() User = get_user_model() user = User(username='******', email='*****@*****.**') user.save() site = Site(name='Site 1', slug='site-1') site.save() rack = Rack(name='Rack 1', site=site) rack.save() RackReservation.objects.bulk_create([ RackReservation(rack=rack, user=user, units=[1, 2, 3], description='Reservation 1'), RackReservation(rack=rack, user=user, units=[4, 5, 6], description='Reservation 2'), RackReservation(rack=rack, user=user, units=[7, 8, 9], description='Reservation 3'), ])
def setUp(self): user = create_test_user(permissions=['dcim.view_rackreservation']) self.client = Client() self.client.force_login(user) site = Site(name='Site 1', slug='site-1') site.save() rack = Rack(name='Rack 1', site=site) rack.save() RackReservation.objects.bulk_create([ RackReservation(rack=rack, user=user, units=[1, 2, 3], description='Reservation 1'), RackReservation(rack=rack, user=user, units=[4, 5, 6], description='Reservation 2'), RackReservation(rack=rack, user=user, units=[7, 8, 9], description='Reservation 3'), ])
def setUpTestData(cls): sites = ( Site(name='Site 1', slug='site-1'), Site(name='Site 2', slug='site-2'), ) Site.objects.bulk_create(sites) racks = ( Rack(name='Rack 1', site=sites[0]), Rack(name='Rack 2', site=sites[1]), ) Rack.objects.bulk_create(racks) users = ( User(username='******'), User(username='******'), User(username='******'), ) User.objects.bulk_create(users) journal_entries = ( JournalEntry( assigned_object=sites[0], created_by=users[0], kind=JournalEntryKindChoices.KIND_INFO, comments='New journal entry' ), JournalEntry( assigned_object=sites[0], created_by=users[1], kind=JournalEntryKindChoices.KIND_SUCCESS, comments='New journal entry' ), JournalEntry( assigned_object=sites[1], created_by=users[2], kind=JournalEntryKindChoices.KIND_WARNING, comments='New journal entry' ), JournalEntry( assigned_object=racks[0], created_by=users[0], kind=JournalEntryKindChoices.KIND_INFO, comments='New journal entry' ), JournalEntry( assigned_object=racks[0], created_by=users[1], kind=JournalEntryKindChoices.KIND_SUCCESS, comments='New journal entry' ), JournalEntry( assigned_object=racks[1], created_by=users[2], kind=JournalEntryKindChoices.KIND_WARNING, comments='New journal entry' ), ) JournalEntry.objects.bulk_create(journal_entries)
def setUp(self): self.client = Client() site = Site(name='Site 1', slug='site-1') site.save() Rack.objects.bulk_create([ Rack(name='Rack 1', site=site), Rack(name='Rack 2', site=site), Rack(name='Rack 3', site=site), ])
def setUpTestData(cls): site_ct = ContentType.objects.get(app_label='dcim', model='site') rack_ct = ContentType.objects.get(app_label='dcim', model='rack') sites = ( Site(name='Site 1', slug='site-1'), Site(name='Site 2', slug='site-2'), ) Site.objects.bulk_create(sites) racks = ( Rack(name='Rack 1', site=sites[0]), Rack(name='Rack 2', site=sites[1]), ) Rack.objects.bulk_create(racks) image_attachments = ( ImageAttachment( content_type=site_ct, object_id=sites[0].pk, name='Image Attachment 1', image='http://example.com/image1.png', image_height=100, image_width=100 ), ImageAttachment( content_type=site_ct, object_id=sites[1].pk, name='Image Attachment 2', image='http://example.com/image2.png', image_height=100, image_width=100 ), ImageAttachment( content_type=rack_ct, object_id=racks[0].pk, name='Image Attachment 3', image='http://example.com/image3.png', image_height=100, image_width=100 ), ImageAttachment( content_type=rack_ct, object_id=racks[1].pk, name='Image Attachment 4', image='http://example.com/image4.png', image_height=100, image_width=100 ) ) ImageAttachment.objects.bulk_create(image_attachments)
def setUp(self): user = create_test_user(permissions=['dcim.view_rack']) self.client = Client() self.client.force_login(user) site = Site(name='Site 1', slug='site-1') site.save() Rack.objects.bulk_create([ Rack(name='Rack 1', site=site), Rack(name='Rack 2', site=site), Rack(name='Rack 3', site=site), ])
def setUp(self): self.client = Client() User = get_user_model() user = User(username='******', email='*****@*****.**') user.save() site = Site(name='Site 1', slug='site-1') site.save() rack = Rack(name='Rack 1', site=site) rack.save() RackReservation.objects.bulk_create([ RackReservation(rack=rack, user=user, units=[1, 2, 3], description='Reservation 1'), RackReservation(rack=rack, user=user, units=[4, 5, 6], description='Reservation 2'), RackReservation(rack=rack, user=user, units=[7, 8, 9], description='Reservation 3'), ])
def create_rack(self, site, name, units): try: rack = Rack.objects.get(name=name) self.log_info("Rack %s already present, carrying on." % rack) return rack except Rack.DoesNotExist: pass rack = Rack(role=RackRole.objects.get(name='Backbone'), type=RackTypeChoices.TYPE_WALLCABINET, width=RackWidthChoices.WIDTH_19IN, u_height=units, status=RackStatusChoices.STATUS_PLANNED, name=name, site=site) rack.save() self.log_success("Created rack {}".format(rack)) return rack
def setUpTestData(cls): manufacturers = ( Manufacturer(name='Manufacturer 1', slug='manufacturer-1'), Manufacturer(name='Manufacturer 2', slug='manufacturer-2'), Manufacturer(name='Manufacturer 3', slug='manufacturer-3'), ) Manufacturer.objects.bulk_create(manufacturers) device_types = ( DeviceType(manufacturer=manufacturers[0], model='Model 1', slug='model-1', is_full_depth=True), DeviceType(manufacturer=manufacturers[1], model='Model 2', slug='model-2', is_full_depth=True), DeviceType(manufacturer=manufacturers[2], model='Model 3', slug='model-3', is_full_depth=False), ) DeviceType.objects.bulk_create(device_types) device_roles = ( DeviceRole(name='Device Role 1', slug='device-role-1'), DeviceRole(name='Device Role 2', slug='device-role-2'), DeviceRole(name='Device Role 3', slug='device-role-3'), ) DeviceRole.objects.bulk_create(device_roles) platforms = ( Platform(name='Platform 1', slug='platform-1'), Platform(name='Platform 2', slug='platform-2'), Platform(name='Platform 3', slug='platform-3'), ) Platform.objects.bulk_create(platforms) regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = ( Site(name='Site 1', slug='abc-site-1', region=regions[0], asn=65001), Site(name='Site 2', slug='def-site-2', region=regions[1], asn=65101), Site(name='Site 3', slug='ghi-site-3', region=regions[2], asn=65201), ) Site.objects.bulk_create(sites) rir = RIR.objects.create(name='RFC 6996', is_private=True) asns = [ ASN(asn=65001, rir=rir), ASN(asn=65101, rir=rir), ASN(asn=65201, rir=rir) ] ASN.objects.bulk_create(asns) asns[0].sites.add(sites[0]) asns[1].sites.add(sites[1]) asns[2].sites.add(sites[2]) racks = ( Rack(name='Rack 1', site=sites[0]), Rack(name='Rack 2', site=sites[1]), Rack(name='Rack 3', site=sites[2]), ) Rack.objects.bulk_create(racks) devices = ( Device(name='Device 1', device_type=device_types[0], device_role=device_roles[0], platform=platforms[0], serial='ABC', asset_tag='1001', site=sites[0], rack=racks[0], position=1, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_ACTIVE, local_context_data={"foo": 123}), Device(name='Device 2', device_type=device_types[1], device_role=device_roles[1], platform=platforms[1], serial='DEF', asset_tag='1002', site=sites[1], rack=racks[1], position=2, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_STAGED), Device(name='Device 3', device_type=device_types[2], device_role=device_roles[2], platform=platforms[2], serial='GHI', asset_tag='1003', site=sites[2], rack=racks[2], position=3, face=DeviceFaceChoices.FACE_REAR, status=DeviceStatusChoices.STATUS_FAILED), ) Device.objects.bulk_create(devices) interfaces = ( Interface(device=devices[0], name='Interface 1', mac_address='00-00-00-00-00-01'), Interface(device=devices[0], name='Interface 2', mac_address='aa-00-00-00-00-01'), Interface(device=devices[1], name='Interface 3', mac_address='00-00-00-00-00-02'), Interface(device=devices[1], name='Interface 4', mac_address='bb-00-00-00-00-02'), Interface(device=devices[2], name='Interface 5', mac_address='00-00-00-00-00-03'), Interface(device=devices[2], name='Interface 6', mac_address='cc-00-00-00-00-03'), ) Interface.objects.bulk_create(interfaces)