def bind_render_record(self, pk=False, **kwargs): self.rdtype_clob = kwargs.pop('rdtype', 'INTR') if kwargs.pop('reverse', False): self.template = self.ptr_template self.dns_ip = ip_to_reverse_name(self.ip_str) + '.' else: self.template = self.a_template return super(StaticInterface, self).bind_render_record(pk=pk, **kwargs)
def reassign_reverse_records(old_domain, new_domain): from cyder.cydns.ip.utils import ip_to_reverse_name up = (None, None) # from, to down = (None, None) # from, to if new_domain: if (old_domain and new_domain.is_descendant_of(old_domain) and old_domain.soa == new_domain.master_domain.soa): # new_domain is below old_domain and there is no root domain # between them, so we can take a shortcut. down = (old_domain, new_domain) else: if new_domain.master_domain: parent_root = new_domain.master_domain.zone_root_domain else: parent_root = None down = (parent_root, new_domain) if old_domain: up = (old_domain, old_domain.zone_root_domain) if all(down): from cyder.cydns.domain.utils import is_name_descendant_of for obj in chain(down[0].reverse_ptr_set.all(), down[0].reverse_staticintr_set.all()): if is_name_descendant_of(ip_to_reverse_name(obj.ip_str), down[1].name): obj.reverse_domain = down[1] obj.save(commit=False) if all(up): for obj in chain(up[0].reverse_ptr_set.all(), up[0].reverse_staticintr_set.all()): obj.reverse_domain = up[1] obj.save(commit=False) if old_domain: still_there = [ unicode(x) for x in chain(old_domain.reverse_ptr_set.all(), old_domain.reverse_staticintr_set.all()) ] if still_there: raise ValidationError( u'No reverse domain found for the following objects: ' + u', '.join(still_there))
def reassign_reverse_records(old_domain, new_domain): from cyder.cydns.ip.utils import ip_to_reverse_name up = (None, None) # from, to down = (None, None) # from, to if new_domain: if (old_domain and new_domain.is_descendant_of(old_domain) and old_domain.soa == new_domain.master_domain.soa): # new_domain is below old_domain and there is no root domain # between them, so we can take a shortcut. down = (old_domain, new_domain) else: if new_domain.master_domain: parent_root = new_domain.master_domain.zone_root_domain else: parent_root = None down = (parent_root, new_domain) if old_domain: up = (old_domain, old_domain.zone_root_domain) if all(down): from cyder.cydns.domain.utils import is_name_descendant_of for obj in chain(down[0].reverse_ptr_set.all(), down[0].reverse_staticintr_set.all()): if is_name_descendant_of( ip_to_reverse_name(obj.ip_str), down[1].name): obj.reverse_domain = down[1] obj.save(commit=False) if all(up): for obj in chain(up[0].reverse_ptr_set.all(), up[0].reverse_staticintr_set.all()): obj.reverse_domain = up[1] obj.save(commit=False) if old_domain: still_there = [unicode(x) for x in chain(old_domain.reverse_ptr_set.all(), old_domain.reverse_staticintr_set.all())] if still_there: raise ValidationError( u'No reverse domain found for the following objects: ' + u', '.join(still_there))