Skip to content

Commit

Permalink
Fixed Endpoint Group UI Bug
Browse files Browse the repository at this point in the history
- Removed entries from the dispatcher table when the weight was 0
  • Loading branch information
root committed Mar 11, 2021
1 parent 3772718 commit d7d03e0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions gui/modules/api/api_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,18 +1314,18 @@ def updateEndpointGroups(gwgroupid=None):
# update the weight
DispatcherEntry = db.query(Dispatcher).filter(
(Dispatcher.setid == gwgroupid) & (Dispatcher.destination == "sip:{}".format(sip_addr))).first()
if weight is None or len(weight) == 0:
if DispatcherEntry is not None:
db.delete(DispatcherEntry)
elif weight:
if DispatcherEntry is not None:
db.query(Dispatcher).filter(
(Dispatcher.setid == gwgroupid) & (Dispatcher.destination == "sip:{}".format(sip_addr))).update(
{"attrs": "weight={}".format(weight)}, synchronize_session=False)
else:
dispatcher = Dispatcher(setid=gwgroupid, destination=sip_addr, attrs="weight={}".format(weight),
description=name)
db.add(dispatcher)
#if weight is None or len(weight) == 0:
# if DispatcherEntry is not None:
# db.delete(DispatcherEntry)
#elif weight:
if DispatcherEntry is not None:
db.query(Dispatcher).filter(
(Dispatcher.setid == gwgroupid) & (Dispatcher.destination == "sip:{}".format(sip_addr))).update(
{"attrs": "weight={}".format(weight)}, synchronize_session=False)
else:
dispatcher = Dispatcher(setid=gwgroupid, destination=sip_addr, attrs="weight={}".format(weight),
description=name)
db.add(dispatcher)

if int(fusionpbxenabled) > 0:
# update the weight for the external load balancer dispatcher set
Expand Down

0 comments on commit d7d03e0

Please sign in to comment.