def get_valid_ip(ips): if isinstance(ips, list): for ip in ips: ip = ip.strip() if IpUtils.is_valid_public_ip(ip): return ip # No public ip found check for no loopback for ip in ips: ip = ip.strip() if not IpUtils.is_loop_back(ip): return ip ip = ips.strip() if IpUtils.is_valid_public_ip(ip): return ip if IpUtils.is_loop_back(ip): return ip
def test_is_valid_loopback_ip(self): ip = "127.0.0.1" self.assertTrue(IpUtils.is_loop_back(ip))