def get_connection(host='<STR_LIT:localhost>', port=<NUM_LIT>, username=None, password=None,<EOL>uri=None, mongodb=None, authdb=None, timeout=<NUM_LIT:20>, *args, **kwargs):
authdb = authdb or mongodb<EOL>if uri is None:<EOL><INDENT>if username and password:<EOL><INDENT>uri = ("<STR_LIT>"<EOL>.format(quote_plus(username), quote_plus(password), host, port, authdb))<EOL>log_uri = ("<STR_LIT>"<EOL>.format(quote_plus(username), host, port, authdb))<EOL><DEDENT>else:<EOL><INDENT>log_uri = uri = "<STR_LIT>" % (host, port)<EOL><DEDENT><DEDENT>LOG.info("<STR_LIT>" % log_uri)<EOL>try:<EOL><INDENT>client = MongoClient(uri, serverSelectionTimeoutMS=timeout)<EOL><DEDENT>except ServerSelectionTimeoutError as err:<EOL><INDENT>LOG.warning("<STR_LIT>")<EOL>raise ConnectionFailure<EOL><DEDENT>LOG.info("<STR_LIT>")<EOL>return client<EOL>
Get a client to the mongo database

        host(str): Host of database
        port(int): Port of database
        username(str)
        password(str)
        uri(str)
        authdb (str): database to use for authentication
        timeout(int): How long should the client try to connect