sdap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eamonf...@apache.org
Subject [incubator-sdap-nexus] branch master updated: SDAP-292: Add cassandra auth support to delete_by_query.py script, and include the script in nexus-webapp docker image (#111)
Date Fri, 30 Oct 2020 21:10:05 GMT
This is an automated email from the ASF dual-hosted git repository.

eamonford pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git


The following commit(s) were added to refs/heads/master by this push:
     new f47c15a  SDAP-292: Add cassandra auth support to delete_by_query.py script, and include
the script in nexus-webapp docker image (#111)
f47c15a is described below

commit f47c15aa2b6be98c227860483b89a438fe20fdfe
Author: Eamon Ford <eamonford@gmail.com>
AuthorDate: Fri Oct 30 14:09:12 2020 -0700

    SDAP-292: Add cassandra auth support to delete_by_query.py script, and include the script
in nexus-webapp docker image (#111)
---
 docker/nexus-webapp/Dockerfile       |  2 ++
 tools/deletebyquery/deletebyquery.py | 17 ++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/docker/nexus-webapp/Dockerfile b/docker/nexus-webapp/Dockerfile
index e4f3b20..92df8d4 100644
--- a/docker/nexus-webapp/Dockerfile
+++ b/docker/nexus-webapp/Dockerfile
@@ -89,6 +89,8 @@ RUN python setup.py install
 WORKDIR /incubator-sdap-nexus/analysis
 RUN python setup.py install
 
+COPY tools /incubator-sdap-nexus/tools
+
 # Upgrade kubernetes client jar from the default version
 RUN rm /opt/spark/jars/kubernetes-client-4.1.2.jar
 ADD https://repo1.maven.org/maven2/io/fabric8/kubernetes-client/4.4.2/kubernetes-client-4.4.2.jar
/opt/spark/jars
diff --git a/tools/deletebyquery/deletebyquery.py b/tools/deletebyquery/deletebyquery.py
index f703448..6e24367 100644
--- a/tools/deletebyquery/deletebyquery.py
+++ b/tools/deletebyquery/deletebyquery.py
@@ -20,6 +20,7 @@ import logging
 import uuid
 from random import sample
 
+from cassandra.auth import PlainTextAuthProvider
 import cassandra.concurrent
 from cassandra.cluster import Cluster
 from cassandra.policies import RoundRobinPolicy, TokenAwarePolicy
@@ -52,10 +53,16 @@ def init(args):
     dc_policy = RoundRobinPolicy()
     token_policy = TokenAwarePolicy(dc_policy)
 
+    if args.cassandraUsername and args.cassandraPassword:
+        auth_provider = PlainTextAuthProvider(username=args.cassandraUsername, password=args.cassandraPassword)
+    else:
+        auth_provider = None
+
     global cassandra_cluster
     cassandra_cluster = Cluster(contact_points=args.cassandra, port=args.cassandraPort,
                                 protocol_version=int(args.cassandraProtocolVersion),
-                                load_balancing_policy=token_policy)
+                                load_balancing_policy=token_policy,
+                                auth_provider=auth_provider)
     global cassandra_session
     cassandra_session = cassandra_cluster.connect(keyspace=args.cassandraKeyspace)
 
@@ -237,6 +244,14 @@ def parse_args():
                         required=False,
                         default='9042')
 
+    parser.add_argument('--cassandraUsername',
+                        help='The username used to connect to Cassandra.',
+                        required=False)
+
+    parser.add_argument('--cassandraPassword',
+                        help='The password used to connect to Cassandra.',
+                        required=False)
+
     parser.add_argument('-pv', '--cassandraProtocolVersion',
                         help='The version of the Cassandra protocol the driver should use.',
                         required=False,


Mime
View raw message