Exemplo n.º 1
0
 def delete(self, *args, **kwargs):
     if self.domain_set.exists():
         raise ValidationError(
             "Domains exist in this SOA's zone. Delete "
             "those domains or remove them from this zone before "
             "deleting this SOA.")
     Task.schedule_all_dns_rebuild(self)
     super(SOA, self).delete(*args, **kwargs)
Exemplo n.º 2
0
def delete_zone_helper(domain_name):
    if not domain_name:
        return {
            'success': False,
            'message': 'Which zone do you want to delete?'
        }
    if domain_name in ('mozilla.com', 'mozilla.net', 'mozilla.org',
                       'allizom.org'):
        raise ValidationError('Go home.')

    zone_objs = compile_to_django("zone=:{0}".format(domain_name))

    rdtypes = ('CNAME', 'MX', 'A', 'SRV', 'PTR', 'SSHFP', 'NS', 'TXT')
    for rdtype in rdtypes:
        zone_objs[0][rdtype].delete()

    soa = zone_objs[0]['SOA'][0]
    root_domain = soa.root_domain

    def maybe_delete_domain(d):
        domain_status = []
        for cd in d.domain_set.all():
            if cd.soa == soa:
                domain_status.append(maybe_delete_domain(cd))
            else:
                domain_status.append(False)

        if reduce(lambda x, y: x and y, domain_status, True):
            d.delete()
            return True
        else:
            d.soa = None
            d.save()
            return False

    maybe_delete_domain(root_domain)
    # XXX Replace this when Inventory has celery
    Task.schedule_zone_rebuild(soa)
    soa.delete()
    return {'success': True, 'message': 'success'}
Exemplo n.º 3
0
 def schedule_rebuild(self, commit=True):
     Task.schedule_zone_rebuild(self)
     self.dirty = True
     if commit:
         self.save()
Exemplo n.º 4
0
 def schedule_full_rebuild(self, commit=True):
     Task.schedule_all_dns_rebuild(self)
     self.dirty = True
     if commit:
         self.save()
Exemplo n.º 5
0
 def schedule_rebuild(self, commit=True):
     Task.schedule_zone_rebuild(self)
     self.dirty = True
     if commit:
         self.save()