From 85dbeb05cc0c0170d16300b3a68de1b4d9995e0d Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 15 Mar 2020 17:28:17 +1100 Subject: [PATCH] Added editing subscribers with PythonAPI Interface Using the UpdateSubscriber call. Input variables are the IMSI and the subscriber data, which is the same as the outputted data of GetSubscriber. --- misc/mongodb/python/Open5GS.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/misc/mongodb/python/Open5GS.py b/misc/mongodb/python/Open5GS.py index dfdbb7c8d0..098ca2e454 100644 --- a/misc/mongodb/python/Open5GS.py +++ b/misc/mongodb/python/Open5GS.py @@ -42,6 +42,17 @@ class Open5GS: print("Added subscriber with Inserted ID : " + str(x.inserted_id)) return x.inserted_id + def UpdateSubscriber(self, imsi, sub_data): + myclient = pymongo.MongoClient("mongodb://" + str(self.server) + ":" + str(self.port) + "/") + mydb = myclient["open5gs"] + mycol = mydb["subscribers"] + print("Attempting to update IMSI " + str(imsi)) + newvalues = { "$set": sub_data } + myquery = { "imsi": str(imsi)} + x = mycol.update_one(myquery, newvalues) + print(x) + return True + def DeleteSubscriber(self, imsi): myclient = pymongo.MongoClient("mongodb://" + str(self.server) + ":" + str(self.port) + "/") @@ -51,5 +62,3 @@ class Open5GS: x = mycol.delete_many(myquery) print(x.deleted_count, " subscribers deleted.") return x.deleted_count - -