예제 #1
0
        def _is_up(self, server, server_endpoints):
            """Nodeinfo is up for server: {server}."""
            hostport, _metadata = zkclient.get(z.join_zookeeper_path(
                z.ENDPOINTS, 'root', server_endpoints[server]))

            host, port = hostport.split(':')

            url = 'http://%s:%s' % (host, port)
            print(url)
            self.assertTrue(chk.connect(host, port))
            self.assertTrue(chk.url_check(url))
예제 #2
0
def _instance_healthy(instance, endpoints):
    """helper to see if instance is healthy (connectable)
    """
    (proid, instance_name) = instance.split('.', 1)
    instance_endpoints = [
        val for val in endpoints
        if val.startswith(instance_name)
    ]

    zkclient = context.GLOBAL.zk.conn
    for endpoint in instance_endpoints:
        fullpath = z.join_zookeeper_path(z.ENDPOINTS, proid, endpoint)
        hostport, _metadata = zkclient.get(fullpath)
        (host, port) = hostport.decode().split(':')
        if not checkout.connect(host, port):
            return False

    return True
예제 #3
0
파일: ssh.py 프로젝트: GrammaB/treadmill
def _wait_for_ssh(queue, ssh, command, timeout=1, attempts=40):
    """Wait until a successful connection to the ssh endpoint can be made."""
    try:
        host, port = queue.get(timeout=timeout * attempts)
    except g_queue.Empty:
        cli.bad_exit('No SSH endpoint found.')

    for _ in six.moves.range(attempts):
        _LOGGER.debug('Checking SSH endpoint %s:%s', host, port)
        if checkout.connect(host, port):
            run_ssh(host, port, ssh, list(command))
            break  # if run_ssh doesn't end with os.execvp()...

        try:
            host, port = queue.get(timeout=timeout)
            queue.task_done()
        except g_queue.Empty:
            pass

    # Either all the connection attempts failed or we're after run_ssh
    # (not resulting in os.execvp) so let's "clear the queue" so the thread
    # can join
    queue.task_done()
예제 #4
0
 def _test_is_up(self, url, name):
     """Test {name} - {url} is up."""
     del name
     cli.out(' Server up : {}'.format(url))
     host, port = _to_hostport(url)
     self.assertTrue(chk.connect(host, port))
예제 #5
0
 def _test_is_up(self, url, name):
     """Test {name} - {url} is up."""
     del name
     print(url)
     host, port = _to_hostport(url)
     self.assertTrue(chk.connect(host, port))