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

Commit 4d01aaf

Browse files
authored
feat: externalizing config for Mongo (#7)
* feat: externalizing config for Mongo * feat: externalizing config
1 parent 18bc60a commit 4d01aaf

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

config.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,15 @@ snmp:
22
mibs:
33
url:
44
- "file:///usr/share/snmp/mibs"
5-
# *TODO*: Replace below URL with MIB Server's URL returned during service discovery.
6-
# - "http://mibs.thola.io/asn1/@mib@"
7-
- "http://localhost:5000/files/asn1/@mib@"
85
dir: "/work/mibs/pysnmp"
96
# dir: "/Users/yling/snmp-project/splunk-connect-for-snmp-mib-server/mibs/pysnmp"
107
load_list: "lookups/mibs_list.csv"
118
mibs_path: "/work/mibs"
129
# mibs_path: "/Users/yling/snmp-project/splunk-connect-for-snmp-mib-server/mibs"
1310
mongo:
1411
oid:
15-
# host: "localhost"
16-
host: "mongo"
17-
port: 27017
1812
database: "snmp_traps"
1913
collection: "oids"
2014
mib:
21-
# host: "localhost"
22-
host: "mongo"
23-
port: 27017
2415
database: "files"
2516
collection: "mib_files"

splunk_connect_for_snmp_mib_server/mib_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, args, server_config):
1818
def build_flask_app(self):
1919
app = Flask(__name__)
2020

21-
ppath = self._server_config["snmp"]["mibs"]["mibs_path"]
21+
ppath = "http://" + os.environ['MONGO_SERVICE_SERVICE_HOST'] + ":" + os.environ['MONGO_SERVICE_PORT'] + "/files/asn1/@mib@"
2222

2323
files_index = AutoIndex(app, ppath, add_url_rules=False)
2424

splunk_connect_for_snmp_mib_server/mongo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self, mongo_config):
99
"""
1010
Create a collection in mongodb to store mib files
1111
"""
12-
self._client = MongoClient(host=mongo_config['host'], port=mongo_config['port'])
12+
self._client = MongoClient(os.environ['MONGO_SERVICE_SERVICE_HOST'], os.environ['MONGO_SERVICE_PORT'])
1313
self._mibs = self._client[mongo_config['database']][mongo_config['collection']]
1414

1515

@@ -62,7 +62,7 @@ def clear(self):
6262

6363
class OidsRepository:
6464
def __init__(self, mongo_config):
65-
self._client = MongoClient(host=mongo_config['host'], port=mongo_config['port'])
65+
self._client = MongoClient(os.environ['MONGO_SERVICE_SERVICE_HOST'], os.environ['MONGO_SERVICE_PORT'])
6666
self._oids = self._client[mongo_config['database']][mongo_config['collection']]
6767

6868
def contains_oid(self, oid):

0 commit comments

Comments
 (0)