This is an automated email from the ASF dual-hosted git repository.
eamonford pushed a commit to branch bug_fixes
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git
The following commit(s) were added to refs/heads/bug_fixes by this push:
new f4662a4 add support for cassandra username and password
f4662a4 is described below
commit f4662a464ca1dba16e8595736807d298b2664d4e
Author: Eamon Ford <[email protected]>
AuthorDate: Thu Jul 23 12:34:18 2020 -0700
add support for cassandra username and password
---
analysis/webservice/webapp.py | 2 ++
data-access/nexustiles/config/datastores.ini.default | 4 +++-
data-access/nexustiles/dao/CassandraProxy.py | 10 +++++++++-
data-access/tests/config/datastores.ini | 9 ---------
4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/analysis/webservice/webapp.py b/analysis/webservice/webapp.py
index c8a6852..bc232b4 100644
--- a/analysis/webservice/webapp.py
+++ b/analysis/webservice/webapp.py
@@ -70,6 +70,8 @@ if __name__ == "__main__":
' when solr performances are not good this might need to be
increased')
define('solr_host', help='solr host and port')
define('cassandra_host', help='cassandra host')
+ define('cassandra_username', help='cassandra username')
+ define('cassandra_password', help='cassandra password')
parse_command_line()
algorithm_config = inject_args_in_config(options, algorithm_config)
diff --git a/data-access/nexustiles/config/datastores.ini.default
b/data-access/nexustiles/config/datastores.ini.default
index e4ab6c1..63d08af 100644
--- a/data-access/nexustiles/config/datastores.ini.default
+++ b/data-access/nexustiles/config/datastores.ini.default
@@ -1,10 +1,12 @@
[cassandra]
-host=localhost
+host=sdap-cassandra
port=9042
keyspace=nexustiles
local_datacenter=datacenter1
protocol_version=3
dc_policy=DCAwareRoundRobinPolicy
+username=
+password=
[s3]
bucket=nexus-jpl
diff --git a/data-access/nexustiles/dao/CassandraProxy.py
b/data-access/nexustiles/dao/CassandraProxy.py
index ed37c5c..2b27104 100644
--- a/data-access/nexustiles/dao/CassandraProxy.py
+++ b/data-access/nexustiles/dao/CassandraProxy.py
@@ -17,6 +17,7 @@ import uuid
from ConfigParser import NoOptionError
from multiprocessing.synchronize import Lock
+from cassandra.auth import PlainTextAuthProvider
import nexusproto.DataTile_pb2 as nexusproto
import numpy as np
from cassandra.cqlengine import columns, connection, CQLEngineException
@@ -151,6 +152,8 @@ class CassandraProxy(object):
def __init__(self, config):
self.config = config
self.__cass_url = config.get("cassandra", "host")
+ self.__cass_username = config.get("cassandra", "username")
+ self.__cass_password = config.get("cassandra", "password")
self.__cass_keyspace = config.get("cassandra", "keyspace")
self.__cass_local_DC = config.get("cassandra", "local_datacenter")
self.__cass_protocol_version = config.getint("cassandra",
"protocol_version")
@@ -174,10 +177,15 @@ class CassandraProxy(object):
elif self.__cass_dc_policy == 'WhiteListRoundRobinPolicy':
dc_policy = WhiteListRoundRobinPolicy([self.__cass_url])
+ if self.__cass_username and self.__cass_password:
+ auth_provider =
PlainTextAuthProvider(username=self.__cass_username,
password=self.__cass_password)
+ else:
+ auth_provider = None
token_policy = TokenAwarePolicy(dc_policy)
connection.setup([host for host in self.__cass_url.split(',')],
self.__cass_keyspace,
protocol_version=self.__cass_protocol_version,
load_balancing_policy=token_policy,
- port=self.__cass_port)
+ port=self.__cass_port,
+ auth_provider=auth_provider)
def fetch_nexus_tiles(self, *tile_ids):
tile_ids = [uuid.UUID(str(tile_id)) for tile_id in tile_ids if
diff --git a/data-access/tests/config/datastores.ini
b/data-access/tests/config/datastores.ini
deleted file mode 100644
index 194760c..0000000
--- a/data-access/tests/config/datastores.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[cassandra]
-host=127.0.0.1
-keyspace=nexustiles
-local_datacenter=datacenter1
-protocol_version=3
-
-[solr]
-host=localhost:8983
-core=nexustiles
\ No newline at end of file