コード例 #1
0
ファイル: test_util.py プロジェクト: ed00m/graphite-web
    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 ]
コード例 #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
コード例 #3
0
ファイル: remote.py プロジェクト: cbowman0/graphite-web
 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
コード例 #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 ]
コード例 #5
0
ファイル: remote.py プロジェクト: gwaldo/graphite-web
    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]
コード例 #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]
コード例 #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])
コード例 #8
0
ファイル: test_util.py プロジェクト: aihua/graphite-web
    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] )
コード例 #9
0
ファイル: storage.py プロジェクト: techonomics69/graphite-web
    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()
コード例 #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]
コード例 #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])
コード例 #12
0
ファイル: storage.py プロジェクト: 0x20h/graphite-web
 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 ]
コード例 #13
0
ファイル: test_util.py プロジェクト: aihua/graphite-web
 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] )
コード例 #14
0
ファイル: test_util.py プロジェクト: EasyPost/graphite-web
 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 ]
コード例 #15
0
ファイル: test_util.py プロジェクト: EasyPost/graphite-web
 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] )
コード例 #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])
コード例 #17
0
ファイル: test_util.py プロジェクト: BruceZu/graphite-web
 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] )
コード例 #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])
コード例 #19
0
ファイル: storage.py プロジェクト: wfarr/graphite-web
 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]