Example #1
0
class TimeProfile(models.Model):
    name = models.CharField(max_length=128, unique=True)
    description = models.TextField(blank=True)
    max_connections = models.PositiveIntegerField(default='5')
    connect_timeout = NormalizedDecimalField(
        default='0.30',
        decimal_places=2,
        max_digits=4,
        verbose_name='Connect timeout (s)')
    first_byte_timeout = NormalizedDecimalField(
        default='5',
        decimal_places=2,
        max_digits=5,
        verbose_name='First byte timeout (s)')
    between_bytes_timeout = NormalizedDecimalField(
        default='1',
        decimal_places=2,
        max_digits=5,
        verbose_name='Between bytes timeout (s)')
    service_mesh_timeout = NormalizedDecimalField(
        default='300',
        decimal_places=2,
        max_digits=5,
        verbose_name='Service mesh timeout (s)')

    @property
    def service_mesh_timeout_ms(self):
        return int(1000 * self.service_mesh_timeout)

    def __str__(self):
        return self.name
Example #2
0
class Backend(models.Model):
    address = models.GenericIPAddressField(protocol='IPv4')
    port = models.PositiveIntegerField(
        default='80',
        validators=[MinValueValidator(1), MaxValueValidator(65535)]
    )
    weight = models.PositiveIntegerField(
        default='1',
        choices=[(x, x) for x in range(0, 101)]
    )
    dc = models.ForeignKey(Dc, on_delete=models.PROTECT)
    max_connections = models.PositiveIntegerField(
        default='5',
        choices=[(x, x) for x in range(1, 101)]
    )
    connect_timeout = NormalizedDecimalField(
        default='0.30',
        decimal_places=2,
        max_digits=4,
        choices=generate_choices(1, 101, 100),
        verbose_name=u'Connect timeout (s)'
    )
    first_byte_timeout = NormalizedDecimalField(
        default='5',
        decimal_places=2,
        max_digits=5,
        choices=generate_choices(1, 8001, 100),
        verbose_name=u'First byte timeout (s)'
    )
    between_bytes_timeout = NormalizedDecimalField(
        default='1',
        decimal_places=2,
        max_digits=5,
        choices=generate_choices(1, 8001, 100),
        verbose_name=u'Between bytes timeout (s)'
    )
    director = models.ForeignKey(
        Director,
        related_name='backends',
        on_delete=models.PROTECT
    )
    enabled = models.BooleanField(default=True)
    tags = TaggableManager(blank=True)
    inherit_time_profile = models.BooleanField(default=False)

    def __unicode__(self):
        return make_backend_name(self)

    class Meta:
        unique_together = (('address', 'port', 'director'),)
Example #3
0
class TimeProfile(models.Model):
    name = models.CharField(max_length=128, unique=True)
    description = models.TextField(blank=True)
    max_connections = models.PositiveIntegerField(default='5')
    connect_timeout = NormalizedDecimalField(
        default='0.30', decimal_places=2, max_digits=4, verbose_name=u'Connect timeout (s)'
    )
    first_byte_timeout = NormalizedDecimalField(
        default='5', decimal_places=2, max_digits=5, verbose_name=u'First byte timeout (s)'
    )
    between_bytes_timeout = NormalizedDecimalField(
        default='1', decimal_places=2, max_digits=5, verbose_name=u'Between bytes timeout (s)'
    )

    def __unicode__(self):
        return self.name
Example #4
0
class Probe(models.Model):
    name = models.CharField(max_length=30, validators=[vcl_name_validator], unique=True)
    url = models.CharField(max_length=50)
    expected_response = models.PositiveIntegerField(default='200')
    interval = models.PositiveIntegerField(
        default='3',
        choices=[(x, x) for x in range(1, 301)],
        verbose_name=u'Interval (s)'
    )
    timeout = NormalizedDecimalField(
        default='1',
        decimal_places=1,
        max_digits=4,
        choices=generate_choices(1, 51, 10, 1),
        verbose_name=u'Timeout (s)'
    )
    window = models.PositiveIntegerField(
        default='5',
        choices=[(x, x) for x in range(1, 6)],
        verbose_name=u'Window (s)'
    )
    threshold = models.PositiveIntegerField(
        default='3',
        choices=[(x, x) for x in range(1, 301)]
    )

    def __unicode__(self):
        return "%s (%s)" % (self.name, self.url)
Example #5
0
        class SampleModel(models.Model):
            normalized_field = NormalizedDecimalField(default='1',
                                                      decimal_places=2,
                                                      max_digits=4)

            class Meta:
                app_label = 'sample_model'
Example #6
0
class Probe(models.Model):
    name = models.CharField(max_length=30,
                            validators=[name_validator],
                            unique=True)
    url = models.CharField(max_length=50)
    expected_response = models.PositiveIntegerField(default='200')
    interval = models.PositiveIntegerField(default='3',
                                           choices=[(x, x)
                                                    for x in range(1, 301)],
                                           verbose_name='Interval (s)')
    timeout = NormalizedDecimalField(default='1',
                                     decimal_places=1,
                                     max_digits=4,
                                     choices=generate_choices(1, 51, 10, 1),
                                     verbose_name='Timeout (s)')
    window = models.PositiveIntegerField(default='5',
                                         choices=[(x, x) for x in range(1, 6)],
                                         verbose_name='Window (s)')
    threshold = models.PositiveIntegerField(default='3',
                                            choices=[(x, x)
                                                     for x in range(1, 301)])
    start_as_healthy = models.BooleanField(
        'Start backend as healthy',
        default=False,
        help_text=
        '<i>New backend is starting with healthy status, there is no need to initial health check pass</i>'
    )

    def __str__(self):
        return "%s (%s)" % (self.name, self.url)