コード例 #1
0
ファイル: models.py プロジェクト: Marlburo/inventory
 def reassign(objs):
     for obj in objs:
         if ip_type == '6':
             nibz = nibbilize(obj.ip_str)
             revname = ip_to_domain_name(nibz, ip_type='6')
         else:
             revname = ip_to_domain_name(obj.ip_str, ip_type='4')
         correct_reverse_domain = name_to_domain(revname)
         if correct_reverse_domain != obj.reverse_domain:
             # TODO, is this needed? The save() function (actually the
             # clean_ip function) will assign the correct reverse domain.
             obj.reverse_domain = correct_reverse_domain
             obj.save()
 def reassign(objs):
     for obj in objs:
         if ip_type == '6':
             nibz = nibbilize(obj.ip_str)
             revname = ip_to_domain_name(nibz, ip_type='6')
         else:
             revname = ip_to_domain_name(obj.ip_str, ip_type='4')
         correct_reverse_domain = name_to_domain(revname)
         if correct_reverse_domain != obj.reverse_domain:
             # TODO, is this needed? The save() function (actually the
             # clean_ip function) will assign the correct reverse domain.
             obj.reverse_domain = correct_reverse_domain
             obj.save()
コード例 #3
0
def reassign_reverse_ptrs(reverse_domain_1, reverse_domain_2, ip_type):
    """There are some formalities that need to happen when a reverse
    domain is added and deleted. For example, when adding say we had the
    ip address 128.193.4.0 and it had the reverse_domain 128.193. If we
    add the reverse_domain 128.193.4, our 128.193.4.0 no longer belongs
    to the 128.193 domain. We need to re-asign the ip to it's correct
    reverse domain.

    :param reverse_domain_1: The domain which could possibly have
        addresses added to it.

    :type reverse_domain_1: :class:`Domain`

    :param reverse_domain_2: The domain that has ip's which might not
        belong to it anymore.

    :type reverse_domain_2: :class:`Domain`
    """

    if reverse_domain_2 is None or ip_type is None:
        return
    ptrs = reverse_domain_2.ptr_set.iterator()
    # intrs = reverse_domain_2.staticinterface_set.iterator()
    # TODO do the intr case
    for ptr in ptrs:
        if ip_type == '6':
            nibz = nibbilize(ptr.ip_str)
            revname = ip_to_domain_name(nibz, ip_type='6')
        else:
            revname = ip_to_domain_name(ptr.ip_str, ip_type='4')
        correct_reverse_domain = name_to_domain(revname)
        if correct_reverse_domain != ptr.reverse_domain:
            # TODO, is this needed? The save() function (actually the
            # clean_ip function) will assign the correct reverse domain.
            ptr.reverse_domain = correct_reverse_domain
            ptr.save()
コード例 #4
0
def _name_to_domain(fqdn):
    return name_to_domain(fqdn)
def _name_to_domain(fqdn):
    return name_to_domain(fqdn)