def test_is_local_interface(self): addresses = ['127.0.0.1', '127.0.0.1:8080', '8.8.8.8'] results = [ util.is_local_interface(a) for a in addresses ] self.assertEqual( results, [True, True, False] ) addresses = ['::1', '[::1]:8080' ] results = [ util.is_local_interface(a) for a in addresses ] self.assertEqual( results, [True, True] ) with self.assertRaises(Exception): addresses = ['::1:8080'] results = [ util.is_local_interface(a) for a in addresses ]
def factory(cls): finders = [] for host in settings.CLUSTER_SERVERS: if settings.REMOTE_EXCLUDE_LOCAL and is_local_interface(cls.parse_host(host)['host']): continue finders.append(cls(host)) return finders
def __init__(self, finders=None, hosts=None): if finders is None: finders = [get_finder(finder_path) for finder_path in settings.STORAGE_FINDERS] self.finders = finders if hosts is None: hosts = settings.CLUSTER_SERVERS remote_hosts = [host for host in hosts if not is_local_interface(host)] self.remote_stores = [ RemoteStore(host) for host in remote_hosts ]
def __init__(self, hosts=None): if hosts is None: hosts = settings.CLUSTER_SERVERS remote_hosts = [] for host in hosts: if settings.REMOTE_EXCLUDE_LOCAL and is_local_interface(host): continue remote_hosts.append(host) self.remote_stores = [RemoteStore(self, host) for host in remote_hosts]
def test_is_local_interface_ipv6(self): # we need to know whether the host provides an ipv6 callback address ipv6_support = True try: sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) sock.bind(('::1', 0)) sock.close() except Exception: ipv6_support = False addresses = ['::1', '[::1]:8080', '[::1]', '::1:8080'] results = [util.is_local_interface(a) for a in addresses] if ipv6_support: self.assertEqual(results, [True, True, True, False]) else: self.assertEqual(results, [False, False, False, False])
def test_is_local_interface_ipv6(self): # we need to know whether the host provides an ipv6 callback address ipv6_support = True try: sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) sock.bind( ('::1', 0) ) sock.close() except Exception: ipv6_support = False addresses = ['::1', '[::1]:8080', '[::1]', '::1:8080'] results = [ util.is_local_interface(a) for a in addresses ] if ipv6_support: self.assertEqual( results, [True, True, True, False] ) else: self.assertEqual( results, [False, False, False, False] )
def __init__(self, finders=None, carbon_cache_finder=None, hosts=None): if finders is None: finders = [ get_finder(finder_path) for finder_path in settings.STORAGE_FINDERS ] self.finders = finders if carbon_cache_finder is None: carbon_cache_finder = get_finder(settings.CARBON_CACHE_FINDER) self.carbon_cache_finder = carbon_cache_finder if hosts is None: hosts = settings.CLUSTER_SERVERS remote_hosts = [ host for host in hosts if not settings.REMOTE_EXCLUDE_LOCAL or not is_local_interface(host) ] self.remote_stores = [RemoteStore(host) for host in remote_hosts] # Introduce Gevent Worker Pool self.worker_pool = Pool()
def test_is_local_interface_bad_ipv6(self): with self.assertRaises(Exception): addresses = ['::1:8080'] results = [util.is_local_interface(a) for a in addresses]
def test_is_local_interface_ipv6(self): addresses = ['::1', '[::1]:8080', '[::1]'] results = [util.is_local_interface(a) for a in addresses] self.assertEqual(results, [True, True, True])
def __init__(self, finders, hosts=[]): self.finders = finders remote_hosts = [host for host in hosts if not is_local_interface(host)] self.remote_stores = [ RemoteStore(host) for host in remote_hosts ]
def test_is_local_interface_dns(self): addresses = ['localhost', socket.gethostname(), 'google.com'] results = [ util.is_local_interface(a) for a in addresses ] self.assertEqual( results, [True, True, False] )
def test_is_local_interface_bad_ipv6(self): with self.assertRaises(Exception): addresses = ['::1:8080'] results = [ util.is_local_interface(a) for a in addresses ]
def test_is_local_interface_ipv6(self): addresses = ['::1', '[::1]:8080', '[::1]'] results = [ util.is_local_interface(a) for a in addresses ] self.assertEqual( results, [True, True, True] )
def test_is_local_interface_ipv4(self): addresses = ['127.0.0.1', '127.0.0.1:8080', '8.8.8.8'] results = [util.is_local_interface(a) for a in addresses] self.assertEqual(results, [True, True, False])
def test_is_local_interface(self): addresses = ['127.0.0.1', '127.0.0.1:8080', '8.8.8.8'] results = [ util.is_local_interface(a) for a in addresses ] self.assertEqual( results, [True, True, False] )
def test_is_local_interface_dns(self): addresses = ['localhost', socket.gethostname(), 'google.com'] results = [util.is_local_interface(a) for a in addresses] self.assertEqual(results, [True, True, False])
def __init__(self, finders, hosts=[]): self.finders = finders remote_hosts = [host for host in hosts if not is_local_interface(host)] self.remote_stores = [RemoteStore(host) for host in remote_hosts]