Ejemplo n.º 1
0
 def create_rr_set(cls, domain, records, **kwargs):
     if isinstance(domain, str):
         domain = Domain.objects.get(name=domain)
         domain.save()
     rr_set = RRset(domain=domain, **kwargs)
     rr_set.save()
     for r in records:
         RR(content=r, rrset=rr_set).save()
     return rr_set
Ejemplo n.º 2
0
        def api_do(self):
            rr_set = RRset(
                domain=Domain.objects.get(name=self.domain_name),
                type='NS', subname='',
                ttl=settings.DEFAULT_NS_TTL,
            )
            rr_set.save()

            rrs = [RR(rrset=rr_set, content=ns) for ns in settings.DEFAULT_NS]
            RR.objects.bulk_create(rrs)  # One INSERT
Ejemplo n.º 3
0
    def update(self, instance: RRset, validated_data):
        rrs_data = validated_data.pop('records', None)
        if rrs_data is not None:
            self._set_all_record_contents(instance, rrs_data)

        ttl = validated_data.pop('ttl', None)
        if ttl and instance.ttl != ttl:
            instance.ttl = ttl
            instance.save()

        return instance
 def _create_rr_sets(cls, data, domain):
     rr_sets = []
     rrs = {}
     for (type_, subname, ttl), rr_contents in data.items():
         rr_set = RRset(domain=domain, subname=subname, type=type_, ttl=ttl)
         rr_sets.append(rr_set)
         rrs[(type_, subname)] = this_rrs = []
         rr_set.save()
         for content in rr_contents:
             rr = RR(content=content, rrset=rr_set)
             this_rrs.append(rr)
             rr.save()
     return rr_sets, rrs
Ejemplo n.º 5
0
    def update(self, instance: models.RRset, validated_data):
        rrs_data = validated_data.pop('records', None)
        if rrs_data is not None:
            self._set_all_record_contents(instance, rrs_data)

        ttl = validated_data.pop('ttl', None)
        if ttl and instance.ttl != ttl:
            instance.ttl = ttl
            instance.save()  # also updates instance.touched
        else:
            # Update instance.touched without triggering post-save signal (no pdns action required)
            models.RRset.objects.filter(pk=instance.pk).update(touched=timezone.now())

        return instance