Skip to content

Commit 46afeaf

Browse files
committed
Add ssl and verify_ssl arguments to support HTTPS
1 parent 9eb837f commit 46afeaf

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

docs/agents/influxdb_publisher.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Add an InfluxDBAgent to your OCS configuration file::
3434
'--port', 8086,
3535
'--protocol', 'line',
3636
'--gzip', True,
37+
'--ssl', False,
38+
'--verify-ssl', False,
3739
'--database', 'ocs_feeds']},
3840

3941
Docker Compose

ocs/agents/influxdb_publisher/agent.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def record(self, session: ocs_agent.OpSession, params):
9595
self.incoming_data,
9696
port=self.args.port,
9797
protocol=self.args.protocol,
98+
ssl=self.args.ssl,
99+
verify_ssl=self.args.verify_ssl,
98100
gzip=self.args.gzip,
99101
operate_callback=lambda: self.aggregate,
100102
)
@@ -145,6 +147,14 @@ def make_parser(parser=None):
145147
choices=['json', 'line'],
146148
help="Protocol for writing data. Either 'line' or "
147149
"'json'.")
150+
pgroup.add_argument('--ssl',
151+
type=bool,
152+
default=False,
153+
help="Use https instead of http to connect to InfluxDB, defaults to False.")
154+
pgroup.add_argument('--verify-ssl',
155+
type=bool,
156+
default=False,
157+
help="Verify SSL certificates for HTTPS requests, defaults to False.")
148158
pgroup.add_argument('--gzip',
149159
type=bool,
150160
default=False,

ocs/agents/influxdb_publisher/drivers.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class _InfluxDBClientArgs:
6060
port: int
6161
username: str
6262
password: str
63+
ssl: bool
64+
verify_ssl: bool
6365
gzip: bool
6466

6567

@@ -81,6 +83,10 @@ class Publisher:
8183
port for InfluxDB instance, defaults to 8086.
8284
protocol (str, optional):
8385
Protocol for writing data. Either 'line' or 'json'.
86+
ssl (bool, optional):
87+
Use https instead of http to connect to InfluxDB, defaults to False.
88+
verify_ssl (bool, optional):
89+
Verify SSL certificates for HTTPS requests, defaults to False.
8490
gzip (bool, optional):
8591
compress influxdb requsts with gzip
8692
operate_callback (callable, optional):
@@ -101,8 +107,16 @@ class Publisher:
101107
102108
"""
103109

104-
def __init__(self, host, database, incoming_data, port=8086, protocol='line',
105-
gzip=False, operate_callback=None):
110+
def __init__(self,
111+
host,
112+
database,
113+
incoming_data,
114+
port=8086,
115+
protocol='line',
116+
ssl=False,
117+
verify_ssl=False,
118+
gzip=False,
119+
operate_callback=None):
106120
self.db = database
107121
self.incoming_data = incoming_data
108122
self.protocol = protocol
@@ -117,6 +131,8 @@ def __init__(self, host, database, incoming_data, port=8086, protocol='line',
117131
port=port,
118132
username=username,
119133
password=password,
134+
ssl=ssl,
135+
verify_ssl=verify_ssl,
120136
gzip=gzip)
121137
self.client = InfluxDBClient(**asdict(self.client_args))
122138

0 commit comments

Comments
 (0)