From a444e41787b1a217b51d9ebbe3003bfb9ff6038e Mon Sep 17 00:00:00 2001 From: Ember 'n0emis' Keske Date: Sun, 10 Jul 2022 12:40:05 +0200 Subject: [PATCH] routing: save ids when adding to database, use correct queue --- fieldpoc/config.py | 2 +- fieldpoc/routing.py | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/fieldpoc/config.py b/fieldpoc/config.py index cc63765..21a8609 100644 --- a/fieldpoc/config.py +++ b/fieldpoc/config.py @@ -42,7 +42,7 @@ class Config: return self.dect.check() -class ExtensionConfig: +class ExtensionConfig(ConfigBase): def __init__(self, c): self.num = c[0] self._c = c[1] diff --git a/fieldpoc/routing.py b/fieldpoc/routing.py index f54766e..d510f9f 100644 --- a/fieldpoc/routing.py +++ b/fieldpoc/routing.py @@ -27,11 +27,12 @@ class YwsdYateModel(YateModel): @classmethod def create(cls, diffsync, ids, attrs): with diffsync.engine.connect() as conn: - conn.execute( + result = conn.execute( Yate.table.insert().values( guru3_identifier=ids["guru3_identifier"], **attrs ) ) + attrs["yate_id"] = result.inserted_primary_key[0] return super().create(diffsync, ids=ids, attrs=attrs) def update(self, attrs): @@ -84,7 +85,7 @@ class YwsdExtensionModel(ExtensionModel): @classmethod def create(cls, diffsync, ids, attrs): with diffsync.engine.connect() as conn: - conn.execute( + result = conn.execute( Extension.table.insert().values( extension=ids["extension"], type=attrs["extension_type"], @@ -98,6 +99,7 @@ class YwsdExtensionModel(ExtensionModel): ), ) ) + attrs["extension_id"] = result.inserted_primary_key[0] return super().create(diffsync, ids=ids, attrs=attrs) def update(self, attrs): @@ -210,7 +212,7 @@ class YwsdForkRankModel(ForkRankModel): @classmethod def create(cls, diffsync, ids, attrs): with diffsync.engine.connect() as conn: - conn.execute( + result = conn.execute( ForkRank.table.insert().values( extension_id=diffsync.get( "extension", ids["extension"] @@ -219,6 +221,7 @@ class YwsdForkRankModel(ForkRankModel): **attrs, ) ) + attrs["forkrank_id"] = result.inserted_primary_key[0] return super().create(diffsync, ids=ids, attrs=attrs) def update(self, attrs): @@ -311,10 +314,10 @@ class BackendNerd(diffsync.DiffSync): top_level = ["yate", "extension", "user", "forkrank", "forkrankmember"] def load(self, data): - yate_dect = self.yate( - guru3_identifier="dect", hostname="dect", voip_listener="local" - ) - self.add(yate_dect) + #yate_dect = self.yate( + # guru3_identifier="dect", hostname="dect", voip_listener="local" + #) + #self.add(yate_dect) yate_sip = self.yate( guru3_identifier="sip", hostname="sip", voip_listener="local" ) @@ -339,6 +342,8 @@ class BackendNerd(diffsync.DiffSync): active=True, ) self.add(frm) + elif value["type"] in ["temp"]: + continue extension = self.extension( extension=key, @@ -473,8 +478,8 @@ class Routing: def run(self): while True: - msg = self.fp.queues["dect"].get() - self.fp.queues["dect"].task_done() + msg = self.fp.queues["routing"].get() + self.fp.queues["routing"].task_done() if msg.get("type") == "stop": break