routing: save ids when adding to database, use correct queue

main
n0emis 2 years ago
parent c2ef36c5a7
commit a444e41787
Signed by: n0emis
GPG Key ID: 00FAF748B777CF10

@ -42,7 +42,7 @@ class Config:
return self.dect.check() return self.dect.check()
class ExtensionConfig: class ExtensionConfig(ConfigBase):
def __init__(self, c): def __init__(self, c):
self.num = c[0] self.num = c[0]
self._c = c[1] self._c = c[1]

@ -27,11 +27,12 @@ class YwsdYateModel(YateModel):
@classmethod @classmethod
def create(cls, diffsync, ids, attrs): def create(cls, diffsync, ids, attrs):
with diffsync.engine.connect() as conn: with diffsync.engine.connect() as conn:
conn.execute( result = conn.execute(
Yate.table.insert().values( Yate.table.insert().values(
guru3_identifier=ids["guru3_identifier"], **attrs guru3_identifier=ids["guru3_identifier"], **attrs
) )
) )
attrs["yate_id"] = result.inserted_primary_key[0]
return super().create(diffsync, ids=ids, attrs=attrs) return super().create(diffsync, ids=ids, attrs=attrs)
def update(self, attrs): def update(self, attrs):
@ -84,7 +85,7 @@ class YwsdExtensionModel(ExtensionModel):
@classmethod @classmethod
def create(cls, diffsync, ids, attrs): def create(cls, diffsync, ids, attrs):
with diffsync.engine.connect() as conn: with diffsync.engine.connect() as conn:
conn.execute( result = conn.execute(
Extension.table.insert().values( Extension.table.insert().values(
extension=ids["extension"], extension=ids["extension"],
type=attrs["extension_type"], 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) return super().create(diffsync, ids=ids, attrs=attrs)
def update(self, attrs): def update(self, attrs):
@ -210,7 +212,7 @@ class YwsdForkRankModel(ForkRankModel):
@classmethod @classmethod
def create(cls, diffsync, ids, attrs): def create(cls, diffsync, ids, attrs):
with diffsync.engine.connect() as conn: with diffsync.engine.connect() as conn:
conn.execute( result = conn.execute(
ForkRank.table.insert().values( ForkRank.table.insert().values(
extension_id=diffsync.get( extension_id=diffsync.get(
"extension", ids["extension"] "extension", ids["extension"]
@ -219,6 +221,7 @@ class YwsdForkRankModel(ForkRankModel):
**attrs, **attrs,
) )
) )
attrs["forkrank_id"] = result.inserted_primary_key[0]
return super().create(diffsync, ids=ids, attrs=attrs) return super().create(diffsync, ids=ids, attrs=attrs)
def update(self, attrs): def update(self, attrs):
@ -311,10 +314,10 @@ class BackendNerd(diffsync.DiffSync):
top_level = ["yate", "extension", "user", "forkrank", "forkrankmember"] top_level = ["yate", "extension", "user", "forkrank", "forkrankmember"]
def load(self, data): def load(self, data):
yate_dect = self.yate( #yate_dect = self.yate(
guru3_identifier="dect", hostname="dect", voip_listener="local" # guru3_identifier="dect", hostname="dect", voip_listener="local"
) #)
self.add(yate_dect) #self.add(yate_dect)
yate_sip = self.yate( yate_sip = self.yate(
guru3_identifier="sip", hostname="sip", voip_listener="local" guru3_identifier="sip", hostname="sip", voip_listener="local"
) )
@ -339,6 +342,8 @@ class BackendNerd(diffsync.DiffSync):
active=True, active=True,
) )
self.add(frm) self.add(frm)
elif value["type"] in ["temp"]:
continue
extension = self.extension( extension = self.extension(
extension=key, extension=key,
@ -473,8 +478,8 @@ class Routing:
def run(self): def run(self):
while True: while True:
msg = self.fp.queues["dect"].get() msg = self.fp.queues["routing"].get()
self.fp.queues["dect"].task_done() self.fp.queues["routing"].task_done()
if msg.get("type") == "stop": if msg.get("type") == "stop":
break break

Loading…
Cancel
Save