- @classmethod
- def expand_ip(cls, ip, step_ip, count):
- if step_ip == 'random':
- # Repeatable Random will used in the stream src/dst IP pairs, but we still need
- # to expand the IP based on the number of chains and flows configured. So we use
- # "0.0.0.1" as the step to have the exact IP flow ranges for every chain.
- step_ip = '0.0.0.1'
-
- step_ip_in_int = cls.ip_to_int(step_ip)
- subnet = IPNetwork(ip)
- ip_list = []
- for _ in xrange(count):
- ip_list.append(subnet.ip.format())
- subnet = subnet.next(step_ip_in_int)
- return ip_list
+ def ip_range_overlaps(self):
+ '''Check if this device ip range is overlapping with the dst device ip range
+ '''
+ src_base_ip = Device.ip_to_int(self.ip)
+ dst_base_ip = Device.ip_to_int(self.dst.ip)
+ src_last_ip = src_base_ip + self.flow_count - 1
+ dst_last_ip = dst_base_ip + self.flow_count - 1
+ return dst_last_ip >= src_base_ip and src_last_ip >= dst_base_ip