Ejemplo n.º 1
0
    def open_SSL(self, ip, port, timeout, ssl_config=None):
        """open the SSL connection

        :param ip: the server ip
        :param port: the server port
        :param timeout: the timeout for connect and execute
        :ssl_config: configs for SSL
        :return: void
        """
        self._ip = ip
        self._port = port
        self._timeout = timeout
        try:
            if ssl_config is not None:
                s = TSSLSocket.TSSLSocket(
                    self._ip, self._port, ssl_config.unix_socket,
                    ssl_config.ssl_version, ssl_config.cert_reqs,
                    ssl_config.ca_certs, ssl_config.verify_name,
                    ssl_config.keyfile, ssl_config.certfile,
                    ssl_config.allow_weak_ssl_versions)
            else:
                s = TSocket.TSocket(self._ip, self._port)
            if timeout > 0:
                s.setTimeout(timeout)
            transport = TTransport.TBufferedTransport(s)
            protocol = TBinaryProtocol.TBinaryProtocol(transport)
            transport.open()
            self._connection = GraphService.Client(protocol)
            resp = self._connection.verifyClientVersion(
                VerifyClientVersionReq())
            if resp.error_code != ErrorCode.SUCCEEDED:
                self._connection._iprot.trans.close()
                raise ClientServerIncompatibleException(resp.error_msg)
        except Exception:
            raise
Ejemplo n.º 2
0
def establish_a_rare_connection(pytestconfig):
    addr = pytestconfig.getoption("address")
    host_addr = addr.split(":") if addr else ["localhost", get_ports()[0]]
    socket = TSocket.TSocket(host_addr[0], host_addr[1])
    transport = TTransport.TBufferedTransport(socket)
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    transport.open()
    return GraphService.Client(protocol)
Ejemplo n.º 3
0
 def get_connection(ip, port):
     try:
         socket = TSocket.TSocket(ip, port)
         transport = TTransport.TBufferedTransport(socket)
         protocol = TBinaryProtocol.TBinaryProtocol(transport)
         transport.open()
         connection = GraphService.Client(protocol)
     except Exception as ex:
         assert False, 'Create connection to {}:{} failed'.format(
             ip, port)
     return connection
Ejemplo n.º 4
0
 def open(self, ip, port, timeout):
     try:
         s = TSocket.TSocket(ip, port)
         if timeout > 0:
             s.setTimeout(timeout)
         transport = TTransport.TBufferedTransport(s)
         protocol = TBinaryProtocol.TBinaryProtocol(transport)
         transport.open()
         self._connection = GraphService.Client(protocol)
     except Exception:
         raise
Ejemplo n.º 5
0
    def open(self, ip, port, timeout):
        """open the connection

        :param ip: the server ip
        :param port: the server port
        :param timeout: the timeout for connect and execute
        :return: void
        """
        self._ip = ip
        self._port = port
        self._timeout = timeout
        s = TSocket.TSocket(self._ip, self._port)
        if timeout > 0:
            s.setTimeout(timeout)
        transport = TTransport.TBufferedTransport(s)
        protocol = TBinaryProtocol.TBinaryProtocol(transport)
        transport.open()
        self._connection = GraphService.Client(protocol)
        resp = self._connection.verifyClientVersion(VerifyClientVersionReq())
        if resp.error_code != ErrorCode.SUCCEEDED:
            self._connection._iprot.trans.close()
            raise ClientVersionRejectedException(resp.error_msg)