Example #1
0
    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 ]
Example #2
0
 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
Example #3
0
 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
Example #4
0
  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 ]
Example #5
0
    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]
Example #6
0
    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]
Example #7
0
    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])
Example #8
0
    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] )
Example #9
0
    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()
Example #10
0
 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]
Example #11
0
 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])
Example #12
0
 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 ]
Example #13
0
 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] )
Example #14
0
 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 ]
Example #15
0
 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] )
Example #16
0
 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])
Example #17
0
 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] )
Example #18
0
 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])
Example #19
0
 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]