From ffa14759e9b2b070dd49f201c78cbc6657e70408 Mon Sep 17 00:00:00 2001 From: bars Date: Wed, 20 Jan 2016 13:17:41 +0100 Subject: [PATCH 1/9] simple config file for use of remote mongodb --- broker/add_user.py | 6 +++++- broker/conf.json.dist | 4 ++++ broker/dump_users.py | 6 +++++- broker/feedbroker.py | 6 ++++++ broker/get_secret.py | 6 +++++- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 broker/conf.json.dist diff --git a/broker/add_user.py b/broker/add_user.py index 541bf98..1d278f3 100644 --- a/broker/add_user.py +++ b/broker/add_user.py @@ -2,6 +2,8 @@ import pymongo import sys +import json +import os def handle_list(arg): if arg: @@ -25,7 +27,9 @@ def handle_list(arg): "subscribe":subscribe } -client = pymongo.MongoClient() +cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) + +client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) res = client.hpfeeds.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) client.fsync() client.close() diff --git a/broker/conf.json.dist b/broker/conf.json.dist new file mode 100644 index 0000000..b7605fb --- /dev/null +++ b/broker/conf.json.dist @@ -0,0 +1,4 @@ +{ + "MONGO_HOST": "localhost", + "MONGO_PORT": 27017 +} diff --git a/broker/dump_users.py b/broker/dump_users.py index 7e6ba5e..c442453 100644 --- a/broker/dump_users.py +++ b/broker/dump_users.py @@ -2,8 +2,12 @@ import pymongo import sys +import json +import os -client = pymongo.MongoClient() +cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) + +client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) for doc in client.hpfeeds.auth_key.find(): print doc diff --git a/broker/feedbroker.py b/broker/feedbroker.py index 1577440..9e682a1 100644 --- a/broker/feedbroker.py +++ b/broker/feedbroker.py @@ -6,6 +6,8 @@ import hashlib import collections import random +import json +import os import logging logging.basicConfig(level=logging.INFO) @@ -281,6 +283,10 @@ def _brokerchan(self, c, chan, ident, subscribe=0): c2.publish(ident, chan+'..broker', data) def main(): + cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) + MONGOIP = cfg["MONGO_HOST"] + MONGOPORT = cfg["MONGO_PORT"] + fb = FeedBroker() loop() diff --git a/broker/get_secret.py b/broker/get_secret.py index dc222e9..bd6f13a 100644 --- a/broker/get_secret.py +++ b/broker/get_secret.py @@ -1,8 +1,12 @@ import pymongo import sys +import json +import os + +cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) ident = sys.argv[1] -client = pymongo.MongoClient() +client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) results = client.hpfeeds.auth_key.find({'identifier': ident}) if results.count() > 0: print results[0]['secret'] From 55a07e183b52a5c40541bf2ceb8f078719a4ab2b Mon Sep 17 00:00:00 2001 From: bars Date: Wed, 20 Jan 2016 15:43:15 +0100 Subject: [PATCH 2/9] bug fix --- broker/feedbroker.py | 1 + 1 file changed, 1 insertion(+) diff --git a/broker/feedbroker.py b/broker/feedbroker.py index 9e682a1..8daa72c 100644 --- a/broker/feedbroker.py +++ b/broker/feedbroker.py @@ -283,6 +283,7 @@ def _brokerchan(self, c, chan, ident, subscribe=0): c2.publish(ident, chan+'..broker', data) def main(): + global MONGOIP, MONGOPORT cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) MONGOIP = cfg["MONGO_HOST"] MONGOPORT = cfg["MONGO_PORT"] From b508944181c7bfc73996af0273184579073cf92c Mon Sep 17 00:00:00 2001 From: bars Date: Mon, 18 Apr 2016 12:55:56 +0200 Subject: [PATCH 3/9] added support for authentication (mongodb) --- broker/add_user.py | 7 ++++++- broker/conf.json.dist | 6 +++++- broker/dump_users.py | 6 +++++- broker/feedbroker.py | 10 +++++++++- broker/get_secret.py | 6 +++++- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/broker/add_user.py b/broker/add_user.py index 1d278f3..0838ae5 100644 --- a/broker/add_user.py +++ b/broker/add_user.py @@ -30,7 +30,12 @@ def handle_list(arg): cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) -res = client.hpfeeds.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) +if cfg["MONGO_AUTH"]: + db = client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) + res = db.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) +else: + res = client.hpfeeds.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) + client.fsync() client.close() diff --git a/broker/conf.json.dist b/broker/conf.json.dist index b7605fb..4bd50fb 100644 --- a/broker/conf.json.dist +++ b/broker/conf.json.dist @@ -1,4 +1,8 @@ { "MONGO_HOST": "localhost", - "MONGO_PORT": 27017 + "MONGO_PORT": 27017, + "MONGO_AUTH": False, + "MONGO_USER": None, + "MONGO_PASSWORD": None, + "MONGO_AUTH_MECHANISM": None } diff --git a/broker/dump_users.py b/broker/dump_users.py index c442453..1d2768a 100644 --- a/broker/dump_users.py +++ b/broker/dump_users.py @@ -8,7 +8,11 @@ cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) -for doc in client.hpfeeds.auth_key.find(): +if cfg["MONGO_AUTH"]: + db = client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) +else: + db = client.hpfeeds +for doc in db.auth_key.find(): print doc diff --git a/broker/feedbroker.py b/broker/feedbroker.py index 8daa72c..6cdb1c5 100644 --- a/broker/feedbroker.py +++ b/broker/feedbroker.py @@ -20,6 +20,10 @@ FBNAME = '@hp2' MONGOIP = '127.0.0.1' MONGOPORT = 27017 +MONGOAUTH = False +MONGOUSER = None +MONGOPASSWORD = None +MONGOAUTHMECHANISM = None OP_ERROR = 0 OP_INFO = 1 @@ -283,10 +287,14 @@ def _brokerchan(self, c, chan, ident, subscribe=0): c2.publish(ident, chan+'..broker', data) def main(): - global MONGOIP, MONGOPORT + global MONGOIP, MONGOPORT, MONGOAUTH, MONGOUSER, MONGOPASSWORD, MONGOAUTHMECHANISM cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) MONGOIP = cfg["MONGO_HOST"] MONGOPORT = cfg["MONGO_PORT"] + MONGOAUTH = cfg["MONGO_AUTH"] + MONGOUSER = cfg["MONGO_USER"] + MONGOPASSWORD = cfg["MONGO_PASSWORD"] + MONGOAUTHMECHANISM = cfg["MONGO_AUTH_MECHANISM"] fb = FeedBroker() diff --git a/broker/get_secret.py b/broker/get_secret.py index bd6f13a..ab5d53b 100644 --- a/broker/get_secret.py +++ b/broker/get_secret.py @@ -7,6 +7,10 @@ ident = sys.argv[1] client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) -results = client.hpfeeds.auth_key.find({'identifier': ident}) +if cfg["MONGO_AUTH"]: + db = client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) + results = db.auth_key.find({'identifier': ident}) +else: + results = client.hpfeeds.auth_key.find({'identifier': ident}) if results.count() > 0: print results[0]['secret'] From abad39cf1f425b30868e53fb9c54287c105c28fa Mon Sep 17 00:00:00 2001 From: bars Date: Mon, 18 Apr 2016 16:36:20 +0200 Subject: [PATCH 4/9] bug fixes --- broker/add_user.py | 7 ++----- broker/dump_users.py | 6 ++---- broker/feedbroker.py | 1 + broker/get_secret.py | 6 ++---- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/broker/add_user.py b/broker/add_user.py index 0838ae5..dc2c1e6 100644 --- a/broker/add_user.py +++ b/broker/add_user.py @@ -31,11 +31,8 @@ def handle_list(arg): client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) if cfg["MONGO_AUTH"]: - db = client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) - res = db.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) -else: - res = client.hpfeeds.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) - + client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) +res = client.hpfeeds.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) client.fsync() client.close() diff --git a/broker/dump_users.py b/broker/dump_users.py index 1d2768a..322565e 100644 --- a/broker/dump_users.py +++ b/broker/dump_users.py @@ -9,10 +9,8 @@ client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) if cfg["MONGO_AUTH"]: - db = client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) -else: - db = client.hpfeeds -for doc in db.auth_key.find(): + client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) +for doc in client.hpfeeds.auth_key.find(): print doc diff --git a/broker/feedbroker.py b/broker/feedbroker.py index 6cdb1c5..a3d512b 100644 --- a/broker/feedbroker.py +++ b/broker/feedbroker.py @@ -230,6 +230,7 @@ def __init__(self): def initdb(self): self.db = MongoConn(MONGOIP, MONGOPORT) + self.db.auth("hpfeeds", MONGOUSER, MONGOPASSWORD) self.db._on('ready', self._dbready) self.db._on('close', self._dbclose) diff --git a/broker/get_secret.py b/broker/get_secret.py index ab5d53b..530acd5 100644 --- a/broker/get_secret.py +++ b/broker/get_secret.py @@ -8,9 +8,7 @@ ident = sys.argv[1] client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) if cfg["MONGO_AUTH"]: - db = client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) - results = db.auth_key.find({'identifier': ident}) -else: - results = client.hpfeeds.auth_key.find({'identifier': ident}) + client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) +results = client.hpfeeds.auth_key.find({'identifier': ident}) if results.count() > 0: print results[0]['secret'] From 53e0b0bf2c233d31353211dacdecad185ef0d882 Mon Sep 17 00:00:00 2001 From: bars Date: Fri, 29 Apr 2016 12:58:02 +0200 Subject: [PATCH 5/9] edited conf file --- broker/conf.json.dist | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/broker/conf.json.dist b/broker/conf.json.dist index 4bd50fb..4efe652 100644 --- a/broker/conf.json.dist +++ b/broker/conf.json.dist @@ -1,8 +1,8 @@ { "MONGO_HOST": "localhost", "MONGO_PORT": 27017, - "MONGO_AUTH": False, - "MONGO_USER": None, - "MONGO_PASSWORD": None, - "MONGO_AUTH_MECHANISM": None + "MONGO_AUTH": false, + "MONGO_USER": null, + "MONGO_PASSWORD": null, + "MONGO_AUTH_MECHANISM": null } From 0a9079c4252c9daed7654b49215813053d9260dd Mon Sep 17 00:00:00 2001 From: bars Date: Wed, 25 May 2016 12:06:05 +0200 Subject: [PATCH 6/9] commented client.fsync --- broker/add_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/broker/add_user.py b/broker/add_user.py index dc2c1e6..3da3ada 100644 --- a/broker/add_user.py +++ b/broker/add_user.py @@ -33,7 +33,7 @@ def handle_list(arg): if cfg["MONGO_AUTH"]: client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) res = client.hpfeeds.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) -client.fsync() +#client.fsync() client.close() if res['updatedExisting']: From 60e83c8ba227bd0e9d41dbaeb5b2112193f69b5b Mon Sep 17 00:00:00 2001 From: bars Date: Wed, 24 Aug 2016 10:35:31 +0200 Subject: [PATCH 7/9] using env variables instead of using config file --- broker/add_user.py | 10 ++++------ broker/conf.json.dist | 8 -------- broker/dump_users.py | 8 +++----- broker/feedbroker.py | 13 ++++++------- broker/get_secret.py | 8 +++----- 5 files changed, 16 insertions(+), 31 deletions(-) delete mode 100644 broker/conf.json.dist diff --git a/broker/add_user.py b/broker/add_user.py index 3da3ada..42e57f3 100644 --- a/broker/add_user.py +++ b/broker/add_user.py @@ -27,13 +27,11 @@ def handle_list(arg): "subscribe":subscribe } -cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) - -client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) -if cfg["MONGO_AUTH"]: - client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) +client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=os.getenv("MONGO_PORT")) +if os.getenv("MONGO_AUTH"): + client.hpfeeds.authenticate(os.getenv("MONGO_USER"), os.getenv("MONGO_PASSWORD"), mechanism=os.getenv("MONGO_AUTH_MECHANISM")) res = client.hpfeeds.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) -#client.fsync() +client.fsync() client.close() if res['updatedExisting']: diff --git a/broker/conf.json.dist b/broker/conf.json.dist deleted file mode 100644 index 4efe652..0000000 --- a/broker/conf.json.dist +++ /dev/null @@ -1,8 +0,0 @@ -{ - "MONGO_HOST": "localhost", - "MONGO_PORT": 27017, - "MONGO_AUTH": false, - "MONGO_USER": null, - "MONGO_PASSWORD": null, - "MONGO_AUTH_MECHANISM": null -} diff --git a/broker/dump_users.py b/broker/dump_users.py index 322565e..6eb53a0 100644 --- a/broker/dump_users.py +++ b/broker/dump_users.py @@ -5,11 +5,9 @@ import json import os -cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) - -client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) -if cfg["MONGO_AUTH"]: - client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) +client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=os.getenv("MONGO_PORT")) +if os.getenv("MONGO_AUTH"): + client.hpfeeds.authenticate(os.getenv("MONGO_USER"), os.getenv("MONGO_PASSWORD"), mechanism=os.getenv("MONGO_AUTH_MECHANISM")) for doc in client.hpfeeds.auth_key.find(): print doc diff --git a/broker/feedbroker.py b/broker/feedbroker.py index a3d512b..3a35360 100644 --- a/broker/feedbroker.py +++ b/broker/feedbroker.py @@ -289,13 +289,12 @@ def _brokerchan(self, c, chan, ident, subscribe=0): def main(): global MONGOIP, MONGOPORT, MONGOAUTH, MONGOUSER, MONGOPASSWORD, MONGOAUTHMECHANISM - cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) - MONGOIP = cfg["MONGO_HOST"] - MONGOPORT = cfg["MONGO_PORT"] - MONGOAUTH = cfg["MONGO_AUTH"] - MONGOUSER = cfg["MONGO_USER"] - MONGOPASSWORD = cfg["MONGO_PASSWORD"] - MONGOAUTHMECHANISM = cfg["MONGO_AUTH_MECHANISM"] + MONGOIP = os.getenv("MONGO_HOST") + MONGOPORT = os.getenv("MONGO_PORT") + MONGOAUTH = os.getenv("MONGO_AUTH") + MONGOUSER = os.getenv("MONGO_USER") + MONGOPASSWORD = os.getenv("MONGO_PASSWORD") + MONGOAUTHMECHANISM = os.getenv("MONGO_AUTH_MECHANISM") fb = FeedBroker() diff --git a/broker/get_secret.py b/broker/get_secret.py index 530acd5..98c8c3e 100644 --- a/broker/get_secret.py +++ b/broker/get_secret.py @@ -3,12 +3,10 @@ import json import os -cfg = json.load(file(os.path.join(os.path.dirname(__file__), "conf.json"))) - ident = sys.argv[1] -client = pymongo.MongoClient(host=cfg["MONGO_HOST"], port=cfg["MONGO_PORT"]) -if cfg["MONGO_AUTH"]: - client.hpfeeds.authenticate(cfg["MONGO_USER"], cfg["MONGO_PASSWORD"], mechanism=cfg["MONGO_AUTH_MECHANISM"]) +client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=os.getenv("MONGO_PORT")) +if os.getenv("MONGO_AUTH"): + client.hpfeeds.authenticate(os.getenv("MONGO_USER"), os.getenv("MONGO_PASSWORD"), mechanism=os.getenv("MONGO_AUTH_MECHANISM")) results = client.hpfeeds.auth_key.find({'identifier': ident}) if results.count() > 0: print results[0]['secret'] From 9725619feb1ea68b02e2bfcaafa242b754632a57 Mon Sep 17 00:00:00 2001 From: bars Date: Thu, 1 Sep 2016 14:33:47 +0200 Subject: [PATCH 8/9] bug fix --- broker/add_user.py | 2 +- broker/dump_users.py | 2 +- broker/feedbroker.py | 5 ++++- broker/get_secret.py | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/broker/add_user.py b/broker/add_user.py index 42e57f3..618cba8 100644 --- a/broker/add_user.py +++ b/broker/add_user.py @@ -28,7 +28,7 @@ def handle_list(arg): } client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=os.getenv("MONGO_PORT")) -if os.getenv("MONGO_AUTH"): +if os.getenv("MONGO_AUTH") == "true": client.hpfeeds.authenticate(os.getenv("MONGO_USER"), os.getenv("MONGO_PASSWORD"), mechanism=os.getenv("MONGO_AUTH_MECHANISM")) res = client.hpfeeds.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) client.fsync() diff --git a/broker/dump_users.py b/broker/dump_users.py index 6eb53a0..848559b 100644 --- a/broker/dump_users.py +++ b/broker/dump_users.py @@ -6,7 +6,7 @@ import os client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=os.getenv("MONGO_PORT")) -if os.getenv("MONGO_AUTH"): +if os.getenv("MONGO_AUTH") == "true": client.hpfeeds.authenticate(os.getenv("MONGO_USER"), os.getenv("MONGO_PASSWORD"), mechanism=os.getenv("MONGO_AUTH_MECHANISM")) for doc in client.hpfeeds.auth_key.find(): print doc diff --git a/broker/feedbroker.py b/broker/feedbroker.py index 3a35360..033bc52 100644 --- a/broker/feedbroker.py +++ b/broker/feedbroker.py @@ -291,7 +291,10 @@ def main(): global MONGOIP, MONGOPORT, MONGOAUTH, MONGOUSER, MONGOPASSWORD, MONGOAUTHMECHANISM MONGOIP = os.getenv("MONGO_HOST") MONGOPORT = os.getenv("MONGO_PORT") - MONGOAUTH = os.getenv("MONGO_AUTH") + if os.getenv("MONGO_AUTH") == "true": + MONGOAUTH = True + else: + MONGOAUTH = False MONGOUSER = os.getenv("MONGO_USER") MONGOPASSWORD = os.getenv("MONGO_PASSWORD") MONGOAUTHMECHANISM = os.getenv("MONGO_AUTH_MECHANISM") diff --git a/broker/get_secret.py b/broker/get_secret.py index 98c8c3e..9ba4b5f 100644 --- a/broker/get_secret.py +++ b/broker/get_secret.py @@ -5,7 +5,7 @@ ident = sys.argv[1] client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=os.getenv("MONGO_PORT")) -if os.getenv("MONGO_AUTH"): +if os.getenv("MONGO_AUTH") == "true": client.hpfeeds.authenticate(os.getenv("MONGO_USER"), os.getenv("MONGO_PASSWORD"), mechanism=os.getenv("MONGO_AUTH_MECHANISM")) results = client.hpfeeds.auth_key.find({'identifier': ident}) if results.count() > 0: From 5d9cf851de00ac2cb265d8d8d0603a3b2f36bdc1 Mon Sep 17 00:00:00 2001 From: bars Date: Thu, 1 Sep 2016 17:06:01 +0200 Subject: [PATCH 9/9] convert MONGO_PORT variable to int value --- broker/add_user.py | 2 +- broker/dump_users.py | 2 +- broker/feedbroker.py | 2 +- broker/get_secret.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/broker/add_user.py b/broker/add_user.py index 618cba8..ab505f4 100644 --- a/broker/add_user.py +++ b/broker/add_user.py @@ -27,7 +27,7 @@ def handle_list(arg): "subscribe":subscribe } -client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=os.getenv("MONGO_PORT")) +client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=int(os.getenv("MONGO_PORT"))) if os.getenv("MONGO_AUTH") == "true": client.hpfeeds.authenticate(os.getenv("MONGO_USER"), os.getenv("MONGO_PASSWORD"), mechanism=os.getenv("MONGO_AUTH_MECHANISM")) res = client.hpfeeds.auth_key.update({"identifier": ident}, {"$set": rec}, upsert=True) diff --git a/broker/dump_users.py b/broker/dump_users.py index 848559b..6260d39 100644 --- a/broker/dump_users.py +++ b/broker/dump_users.py @@ -5,7 +5,7 @@ import json import os -client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=os.getenv("MONGO_PORT")) +client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=int(os.getenv("MONGO_PORT"))) if os.getenv("MONGO_AUTH") == "true": client.hpfeeds.authenticate(os.getenv("MONGO_USER"), os.getenv("MONGO_PASSWORD"), mechanism=os.getenv("MONGO_AUTH_MECHANISM")) for doc in client.hpfeeds.auth_key.find(): diff --git a/broker/feedbroker.py b/broker/feedbroker.py index 033bc52..ae6548b 100644 --- a/broker/feedbroker.py +++ b/broker/feedbroker.py @@ -290,7 +290,7 @@ def _brokerchan(self, c, chan, ident, subscribe=0): def main(): global MONGOIP, MONGOPORT, MONGOAUTH, MONGOUSER, MONGOPASSWORD, MONGOAUTHMECHANISM MONGOIP = os.getenv("MONGO_HOST") - MONGOPORT = os.getenv("MONGO_PORT") + MONGOPORT = int(os.getenv("MONGO_PORT")) if os.getenv("MONGO_AUTH") == "true": MONGOAUTH = True else: diff --git a/broker/get_secret.py b/broker/get_secret.py index 9ba4b5f..e102ff4 100644 --- a/broker/get_secret.py +++ b/broker/get_secret.py @@ -4,7 +4,7 @@ import os ident = sys.argv[1] -client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=os.getenv("MONGO_PORT")) +client = pymongo.MongoClient(host=os.getenv("MONGO_HOST"), port=int(os.getenv("MONGO_PORT"))) if os.getenv("MONGO_AUTH") == "true": client.hpfeeds.authenticate(os.getenv("MONGO_USER"), os.getenv("MONGO_PASSWORD"), mechanism=os.getenv("MONGO_AUTH_MECHANISM")) results = client.hpfeeds.auth_key.find({'identifier': ident})