Skip to content

Commit

Permalink
Add SSL Support to InfluxDB Connection (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradippatil authored Jul 30, 2024
1 parent b492d35 commit 457d03b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ within that YAML file that corresponds to the scenario you wish to run. Defaults
you must specify a host.
E.g. `1.1.1.1`. Defaults to None.
- `--influx_port`: Port for your `influx_host` in the case where it is non-default.
- `--influx_ssl`: If your influxdb is using SSL, set this to True. Defaults to False.
- `--influx_verify_ssl`: If your influxdb is using SSL, set this to True. Defaults to
False.
- `--influx_user`: Username for your `influx_host`, if you have one.
- `--influx_pwd`: Password for your `influx_host`, if you have one.
- `--grafana_host`: If your grafana is a separate URL from the influxdb, you can
Expand Down
21 changes: 21 additions & 0 deletions src/grasshopper/lib/configuration/gh_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ class ConfigurationConstants:
"help": "Password to connect to the influx host.",
},
},
"influx_ssl": {
"opts": ["--influx_ssl"],
"attrs": {
"action": "store",
"type": bool,
"help": "Enable SSL for InfluxDB connection.",
},
"typecast": typecast_bool,
"default": False,
},

"influx_verify_ssl": {
"opts": ["--influx_verify_ssl"],
"attrs": {
"action": "store",
"type": bool,
"help": "Enable SSL certificate verification for InfluxDB connection.",
},
"typecast": typecast_bool,
"default": False,
},
"grafana_host": {
"opts": ["--grafana_host"],
"attrs": {
Expand Down
2 changes: 2 additions & 0 deletions src/grasshopper/lib/fixtures/grasshopper_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class GrasshopperConstants:
"influx_port",
"influx_user",
"influx_pwd",
"influx_ssl",
"influx_verify_ssl",
"grafana_host",
"shape_instance",
"scenario_delay",
Expand Down
7 changes: 6 additions & 1 deletion src/grasshopper/lib/grasshopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def log(self) -> None:
logger.info("--- /Grasshopper configuration ---")

@property
def influx_configuration(self) -> dict[str, Optional[str]]:
def influx_configuration(self) -> dict[str, Optional[Union[bool, str]]]:

"""Extract the influx related configuration items.
The InfluxDbSettings object should only get keys if there is a
Expand All @@ -67,6 +68,10 @@ def influx_configuration(self) -> dict[str, Optional[str]]:
if pwd:
configuration["pwd"] = pwd

configuration["ssl"] = self.global_configuration.get("influx_ssl", False)

configuration["verify_ssl"] = self.global_configuration.get("influx_verify_ssl", False)

return configuration

@property
Expand Down

0 comments on commit 457d03b

Please sign in to comment.