def remote_ip(scope, local_ips): """ Given an IP address, this function calculates the remaining available IP address under the assumption that it is a /30 network. In other words, given one link net address, this function returns the other link net address. :type local_ips: string :param local_ips: An IP address, or a list of IP addresses. :rtype: string :return: The other IP address of the link address pair. """ return [ipv4.remote_ip(ip) for ip in local_ips]
def remote_ip(scope, local_ips): """ Given an IP address, this function calculates the remaining available IP address under the assumption that it is a /30 network. In other words, given one link net address, this function returns the other link net address. @type local_ips: string @param local_ips: An IP address, or a list of IP addresses. @rtype: string @return: The other IP address of the link address pair. """ return [ipv4.remote_ip(ip) for ip in local_ips]
def testRemoteIp(self): from Exscript.util.ipv4 import remote_ip self.assertEqual(remote_ip('10.0.0.0'), '10.0.0.3') self.assertEqual(remote_ip('10.0.0.1'), '10.0.0.2') self.assertEqual(remote_ip('10.0.0.2'), '10.0.0.1') self.assertEqual(remote_ip('10.0.0.3'), '10.0.0.0')