From 6cff03ffae0d8cf0164a97dfd3121ec23df8b045 Mon Sep 17 00:00:00 2001
From: Patrick Godwin <patrick.godwin@ligo.org>
Date: Thu, 23 May 2019 17:28:01 -0700
Subject: [PATCH] add options to enable auth, https for inspiral aggregators

---
 gstlal-inspiral/bin/gstlal_ll_inspiral_pipe   | 12 ++++++++++++
 gstlal-ugly/bin/gstlal_ll_dq                  |  4 +++-
 gstlal-ugly/bin/gstlal_ll_inspiral_aggregator |  4 +++-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe b/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe
index 1539fd4198..b6ddc91f5d 100755
--- a/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe
+++ b/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe
@@ -200,6 +200,8 @@ def parse_command_line():
 	parser.add_option("--influx-hostname", help = "Specify the hostname for the influxDB database. Required if --data-backend = influx.")
 	parser.add_option("--influx-port", help = "Specify the port for the influxDB database. Required if --data-backend = influx.")
 	parser.add_option("--influx-database-name", help = "Specify the database name for the influxDB database. Required if --data-backend = influx.")
+	parser.add_option("--enable-auth", action = "store_true", default=False, help = "If set, enables authentication for the influx aggregator.")
+	parser.add_option("--enable-https", action = "store_true", default=False, help = "If set, enables HTTPS connections for the influx aggregator.")
 
 	options, filenames = parser.parse_args()
 
@@ -356,7 +358,13 @@ for ifo in channel_dict:
 			"influx-database-name": options.influx_database_name,
 			"influx-hostname": options.influx_hostname,
 			"influx-port": options.influx_port,
+			"enable-auth": options.enable_auth,
+			"enable-https": options.enable_https,
 		})
+		if options.enable_auth:
+			common_opts.update({"enable-auth": ""})
+		if options.enable_https:
+			common_opts.update({"enable-https": ""})
 
 	dagparts.DAGNode(dqJob, dag, [], opts = common_opts)
 
@@ -536,6 +544,10 @@ if options.agg_data_backend == 'influx':
 		"influx-hostname": options.influx_hostname,
 		"influx-port": options.influx_port,
 	})
+	if options.enable_auth:
+		agg_options.update({"enable-auth": ""})
+	if options.enable_https:
+		agg_options.update({"enable-https": ""})
 
 # define routes used for aggregation jobs
 snr_routes = ["%s_snr_history" % ifo for ifo in channel_dict]
diff --git a/gstlal-ugly/bin/gstlal_ll_dq b/gstlal-ugly/bin/gstlal_ll_dq
index 8b73342341..70597cf6e3 100755
--- a/gstlal-ugly/bin/gstlal_ll_dq
+++ b/gstlal-ugly/bin/gstlal_ll_dq
@@ -65,6 +65,8 @@ def parse_command_line():
 	parser.add_option("--influx-hostname", help = "Specify the hostname for the influxDB database. Required if --data-backend = influx.")
 	parser.add_option("--influx-port", help = "Specify the port for the influxDB database. Required if --data-backend = influx.")
 	parser.add_option("--influx-database-name", help = "Specify the database name for the influxDB database. Required if --data-backend = influx.")
+	parser.add_option("--enable-auth", action = "store_true", default=False, help = "If set, enables authentication for the influx aggregator.")
+	parser.add_option("--enable-https", action = "store_true", default=False, help = "If set, enables HTTPS connections for the influx aggregator.")
 
 	options, filenames = parser.parse_args()
 
@@ -178,7 +180,7 @@ if __name__ == '__main__':
 
 	# set up aggregator sink
 	if options.data_backend == 'influx':
-		agg_sink = io.influx.Aggregator(hostname=options.influx_hostname, port=options.influx_port, db=options.influx_database_name)
+		agg_sink = io.influx.Aggregator(hostname=options.influx_hostname, port=options.influx_port, db=options.influx_database_name, auth=options.enable_auth, https=options.enable_https)
 	else: ### hdf5 data backend
 		agg_sink = io.hdf5.Aggregator(rootdir=options.out_path, num_processes=options.num_threads)
 
diff --git a/gstlal-ugly/bin/gstlal_ll_inspiral_aggregator b/gstlal-ugly/bin/gstlal_ll_inspiral_aggregator
index 5e962952d6..adcc2d6db5 100755
--- a/gstlal-ugly/bin/gstlal_ll_inspiral_aggregator
+++ b/gstlal-ugly/bin/gstlal_ll_inspiral_aggregator
@@ -60,6 +60,8 @@ def parse_command_line():
 	parser.add_argument("--influx-hostname", help = "Specify the hostname for the influxDB database. Required if --data-backend = influx.")
 	parser.add_argument("--influx-port", help = "Specify the port for the influxDB database. Required if --data-backend = influx.")
 	parser.add_argument("--influx-database-name", help = "Specify the database name for the influxDB database. Required if --data-backend = influx.")
+	parser.add_argument("--enable-auth", action = "store_true", help = "If set, enables authentication for the influx aggregator.")
+	parser.add_argument("--enable-https", action = "store_true", help = "If set, enables HTTPS connections for the influx aggregator.")
 
 	args = parser.parse_args()
 
@@ -100,7 +102,7 @@ if __name__ == '__main__':
 
 	# set up aggregator sink
 	if options.data_backend == 'influx':
-		agg_sink = io.influx.Aggregator(hostname=options.influx_hostname, port=options.influx_port, db=options.influx_database_name)
+		agg_sink = io.influx.Aggregator(hostname=options.influx_hostname, port=options.influx_port, db=options.influx_database_name, auth=options.enable_auth, https=options.enable_https)
 	else: ### hdf5 data backend
 		agg_sink = io.hdf5.Aggregator(rootdir=options.base_dir, num_processes=options.num_threads)
 
-- 
GitLab