def _check_ssh(ip, port, timeout): running = False try: responses = tcp_communication(port, ip, receive_first=True, timeout=timeout) server_message = responses[0].decode('utf-8') if re.match('SSH-(?P<version>[0-9-. ]+)-', server_message): running = True else: LOG.debug("Server message does not match expectations {0}".format( server_message)) except IOError as e: LOG.debug("SSH service is not running: {0}".format(e)) return running
def test_sends_requests_receives_replies(self): tcp_communication(PORT, requests=[REQUEST]) calls = [call.sendall(REQUEST), call.recv(ANY), call.close()] assert_equal(calls, self.conn.method_calls)
def test_receives_before_sending_if_so_requested(self): tcp_communication(PORT, receive_first=True) calls = [call.recv(ANY), call.close()] assert_equal(calls, self.conn.method_calls)