コード例 #1
0
ファイル: test_views.py プロジェクト: wuwx/netbox
    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'),
        ])
コード例 #2
0
    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'),
        ])
コード例 #3
0
ファイル: test_views.py プロジェクト: digitalocean/netbox
    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'),
        ])
コード例 #4
0
    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