Skip to content
This repository was archived by the owner on Dec 17, 2021. It is now read-only.

Commit 01949f3

Browse files
author
Ryan Faircloth
authored
feat!: Use MONGO_URI (#70)
Allow use of Mongo with replica set by using the uri connection syntax
1 parent 5225fa4 commit 01949f3

File tree

6 files changed

+266
-205
lines changed

6 files changed

+266
-205
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ cd "splunk-connect-for-snmp-mib-server"
5252

5353
#### Setup Environment for Mib Server
5454
```
55-
export MONGO_SERVICE_SERVICE_HOST=<mongo_host>
56-
export MONGO_SERVICE_SERVICE_PORT=<mongo_port>
55+
export MONGO_URI=mongodb://host:27017
5756
export MIBS_FILES_URL=http://0.0.0.0:5000/files/asn1/@mib@
5857
```
5958
#### Install Poetry

poetry.lock

Lines changed: 262 additions & 194 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ license = "APACHE-2.0"
2222

2323
[tool.poetry.dependencies]
2424
python = "^3.8"
25-
pymongo = "^3.11.3"
25+
pymongo = {version = "^3.11.3", extras = ["srv"]}
2626
pysnmp = "^4.4.12"
2727
requests = "^2.25.1"
2828
PyYAML = "^5.4.1"

splunk_connect_for_snmp_mib_server/mongo.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525

2626
class MongoRepository:
2727
def __init__(self):
28-
self._client = pymongo.MongoClient(
29-
os.environ["MONGO_SERVICE_SERVICE_HOST"],
30-
int(os.environ["MONGO_SERVICE_SERVICE_PORT"]),
31-
)
28+
self._client = pymongo.MongoClient(os.environ["MONGO_URI"])
3229
if os.environ.get("MONGO_USER"):
3330
self._client.admin.authenticate(
3431
os.environ["MONGO_USER"],

tests/test_mongo.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
def main():
2525
mongo_config = {
26-
"host": "localhost",
27-
"port": 27017,
2826
"database": "test",
2927
"collection": "mibs",
3028
}

tests/test_translator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def setUpClass(cls):
7575
os.environ,
7676
{
7777
"MIBS_FILES_URL": "http://0.0.0.0:5000/files/asn1/@mib@",
78-
"MONGO_SERVICE_SERVICE_HOST": "localhost",
79-
"MONGO_SERVICE_SERVICE_PORT": "27017",
78+
"MONGO_URI": "mongodb://localhost:27017",
8079
},
8180
)
8281
cls.env_patcher.start()

0 commit comments

Comments
 (0)