Exemple #1
0
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))
Exemple #2
0
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))
Exemple #3
0
 def is_descendant_of(self, other):
     return is_name_descendant_of(self.name, other.name)
Exemple #4
0
 def is_descendant_of(self, other):
     return is_name_descendant_of(self.name, other.name)