def setup(<EOL>hosts,<EOL>default_keyspace,<EOL>consistency=ConsistencyLevel.ONE,<EOL>lazy_connect=False,<EOL>retry_connect=False,<EOL>**kwargs):
global cluster, session, default_consistency_level, lazy_connect_args<EOL>if '<STR_LIT:username>' in kwargs or '<STR_LIT:password>' in kwargs:<EOL><INDENT>raise CQLEngineException("<STR_LIT>")<EOL><DEDENT>if not default_keyspace:<EOL><INDENT>raise UndefinedKeyspaceException()<EOL><DEDENT>from cqlengine import models<EOL>models.DEFAULT_KEYSPACE = default_keyspace<EOL>default_consistency_level = consistency<EOL>if lazy_connect:<EOL><INDENT>kwargs['<STR_LIT>'] = default_keyspace<EOL>kwargs['<STR_LIT>'] = consistency<EOL>kwargs['<STR_LIT>'] = False<EOL>kwargs['<STR_LIT>'] = retry_connect<EOL>lazy_connect_args = (hosts, kwargs)<EOL>return<EOL><DEDENT>cluster = Cluster(hosts, **kwargs)<EOL>try:<EOL><INDENT>session = cluster.connect()<EOL><DEDENT>except NoHostAvailable:<EOL><INDENT>if retry_connect:<EOL><INDENT>kwargs['<STR_LIT>'] = default_keyspace<EOL>kwargs['<STR_LIT>'] = consistency<EOL>kwargs['<STR_LIT>'] = False<EOL>kwargs['<STR_LIT>'] = retry_connect<EOL>lazy_connect_args = (hosts, kwargs)<EOL><DEDENT>raise<EOL><DEDENT>session.row_factory = dict_factory<EOL>
Records the hosts and connects to one of them

:param hosts: list of hosts, see http://datastax.github.io/python-driver/api/cassandra/cluster.html
:type hosts: list
:param default_keyspace: The default keyspace to use
:type default_keyspace: str
:param consistency: The global consistency level
:type consistency: int
:param lazy_connect: True if should not connect until first use
:type lazy_connect: bool
:param retry_connect: bool
:param retry_connect: True if we should retry to connect even if there was a connection failure initially