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

def virtManager::IPy::IPint::iptype (   self  ) 

Return a description of the IP type ('PRIVATE', 'RESERVERD', etc).

>>> print IP('127.0.0.1').iptype()
PRIVATE
>>> print IP('192.168.1.1').iptype()
PRIVATE
>>> print IP('195.185.1.2').iptype()
PUBLIC
>>> print IP('::1').iptype()
LOOPBACK
>>> print IP('2001:0658:022a:cafe:0200::1').iptype()
ASSIGNABLE RIPE

The type information for IPv6 is out of sync with reality.

Definition at line 520 of file IPy.py.

00520                     :
        """Return a description of the IP type ('PRIVATE', 'RESERVERD', etc).

        >>> print IP('127.0.0.1').iptype()
        PRIVATE
        >>> print IP('192.168.1.1').iptype()
        PRIVATE
        >>> print IP('195.185.1.2').iptype()
        PUBLIC
        >>> print IP('::1').iptype()
        LOOPBACK
        >>> print IP('2001:0658:022a:cafe:0200::1').iptype()
        ASSIGNABLE RIPE

        The type information for IPv6 is out of sync with reality.
        """

        # this could be greatly improved

        if self._ipversion == 4:
            iprange = IPv4ranges 
        elif self._ipversion == 6:
            iprange = IPv6ranges 
        else:
            raise ValueError, "only IPv4 and IPv6 supported"

        bits = self.strBin()
        for i in range(len(bits), 0, -1):
            if iprange.has_key(bits[:i]):
                return iprange[bits[:i]]
        return "unknown"


    def netmask(self):


Generated by  Doxygen 1.6.0   Back to index