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()
class ExtensionConfig:
class ExtensionConfig(ConfigBase):
def __init__(self, c):
self.num = c[0]
self._c = c[1]

@ -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

Loading…
Cancel
Save