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

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

Return netmask as an string. Mostly useful for IPv6.

>>> print IP('195.185.0.0/16').strNetmask()
255.255.0.0
>>> print IP('2001:0658:022a:cafe::0/64').strNetmask()
/64

Definition at line 571 of file IPy.py.

00571                         :
        """Return netmask as an string. Mostly useful for IPv6.

        >>> print IP('195.185.0.0/16').strNetmask()
        255.255.0.0
        >>> print IP('2001:0658:022a:cafe::0/64').strNetmask()
        /64
        """

        # TODO: unify with prefixlenToNetmask?
        if self._ipversion == 4:
            locallen = 32 - self._prefixlen
            return intToIp(((2L ** self._prefixlen) - 1) << locallen, 4)
        elif self._ipversion == 6:
            locallen = 128 - self._prefixlen
            return "/%d" % self._prefixlen
        else:
            raise ValueError, "only IPv4 and IPv6 supported"

    def len(self):


Generated by  Doxygen 1.6.0   Back to index