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

def virtManager::IPy::IPint::overlaps (   self,
  item 
)

Check if two IP address ranges overlap.

Returns 0 if the two ranged don't overlap, 1 if the given
range overlaps at the end and -1 if it does at the beginning.

>>> IP('192.168.0.0/23').overlaps('192.168.1.0/24')
1
>>> IP('192.168.0.0/23').overlaps('192.168.1.255')
1
>>> IP('192.168.0.0/23').overlaps('192.168.2.0')
0
>>> IP('192.168.1.0/24').overlaps('192.168.0.0/23')
-1

Definition at line 672 of file IPy.py.

00672                             :
        """Check if two IP address ranges overlap.

        Returns 0 if the two ranged don't overlap, 1 if the given
        range overlaps at the end and -1 if it does at the beginning.

        >>> IP('192.168.0.0/23').overlaps('192.168.1.0/24')
        1
        >>> IP('192.168.0.0/23').overlaps('192.168.1.255')
        1
        >>> IP('192.168.0.0/23').overlaps('192.168.2.0')
        0
        >>> IP('192.168.1.0/24').overlaps('192.168.0.0/23')
        -1
        """

        item = IP(item)
        if item.ip >= self.ip and item.ip < self.ip + self.len():
            return 1
        elif self.ip >= item.ip and self.ip < item.ip + item.len():
            return -1
        else:
            return 0

    
    def __str__(self):


Generated by  Doxygen 1.6.0   Back to index