Logo Search packages:      
Sourcecode: virt-manager version File versions  Download package

def virtManager::IPy::IP::reverseNames (   self  ) 

Return a list with values forming the reverse lookup.

>>> IP('213.221.113.87/32').reverseNames()
['87.113.221.213.in-addr.arpa.']
>>> IP('213.221.112.224/30').reverseNames()
['224.112.221.213.in-addr.arpa.', '225.112.221.213.in-addr.arpa.', '226.112.221.213.in-addr.arpa.', '227.112.221.213.in-addr.arpa.']
>>> IP('127.0.0.0/24').reverseNames()
['0.0.127.in-addr.arpa.']
>>> IP('127.0.0.0/23').reverseNames()
['0.0.127.in-addr.arpa.', '1.0.127.in-addr.arpa.']
>>> IP('127.0.0.0/16').reverseNames()
['0.127.in-addr.arpa.']
>>> IP('127.0.0.0/15').reverseNames()
['0.127.in-addr.arpa.', '1.127.in-addr.arpa.']
>>> IP('128.0.0.0/8').reverseNames()
['128.in-addr.arpa.']
>>> IP('128.0.0.0/7').reverseNames()
['128.in-addr.arpa.', '129.in-addr.arpa.']

Definition at line 825 of file IPy.py.

00825                           :
        """Return a list with values forming the reverse lookup.

        >>> IP('213.221.113.87/32').reverseNames()
        ['87.113.221.213.in-addr.arpa.']
        >>> IP('213.221.112.224/30').reverseNames()
        ['224.112.221.213.in-addr.arpa.', '225.112.221.213.in-addr.arpa.', '226.112.221.213.in-addr.arpa.', '227.112.221.213.in-addr.arpa.']
        >>> IP('127.0.0.0/24').reverseNames()
        ['0.0.127.in-addr.arpa.']
        >>> IP('127.0.0.0/23').reverseNames()
        ['0.0.127.in-addr.arpa.', '1.0.127.in-addr.arpa.']
        >>> IP('127.0.0.0/16').reverseNames()
        ['0.127.in-addr.arpa.']
        >>> IP('127.0.0.0/15').reverseNames()
        ['0.127.in-addr.arpa.', '1.127.in-addr.arpa.']
        >>> IP('128.0.0.0/8').reverseNames()
        ['128.in-addr.arpa.']
        >>> IP('128.0.0.0/7').reverseNames()
        ['128.in-addr.arpa.', '129.in-addr.arpa.']
        
        """

        if self._ipversion == 4:
            ret =[]
            # TODO: Refactor. Add support for IPint objects
            if self.len() < 2**8:
                for x in self:
                    ret.append(x.reverseName())
            elif self.len() < 2**16L:
                for i in range(0, self.len(), 2**8):
                    ret.append(self[i].reverseName()[2:])
            elif self.len() < 2**24L:
                for i in range(0, self.len(), 2**16):
                    ret.append(self[i].reverseName()[4:])
            else:
                for i in range(0, self.len(), 2**24):
                    ret.append(self[i].reverseName()[6:])
            return ret
        elif self._ipversion == 6:
            s = hex(self.ip)[2:].lower()
            if s[-1] == 'l':
                s = s[:-1]
            if self._prefixlen % 4 != 0:
                raise NotImplementedError, "can't create IPv6 reverse names at sub nibble level"
            s = list(s)
            s.reverse()
            s = '.'.join(s)
            first_nibble_index = int(32 - (self._prefixlen / 4)) * 2
            return ["%s.ip6.int." % s[first_nibble_index:]]
        else:
            raise ValueError, "only IPv4 and IPv6 supported"
        
        

    def reverseName(self):


Generated by  Doxygen 1.6.0   Back to index