On-the-fly generation of static bridges
This commit is contained in:
parent
ee042c0fd9
commit
4682ad2228
@ -45,6 +45,7 @@ REG_ACL: PERMIT:ALL
|
|||||||
SUB_ACL: DENY:1
|
SUB_ACL: DENY:1
|
||||||
TGID_TS1_ACL: PERMIT:ALL
|
TGID_TS1_ACL: PERMIT:ALL
|
||||||
TGID_TS2_ACL: PERMIT:ALL
|
TGID_TS2_ACL: PERMIT:ALL
|
||||||
|
GEN_STAT_BRIDGES: False
|
||||||
|
|
||||||
|
|
||||||
# NOT YET WORKING: NETWORK REPORTING CONFIGURATION
|
# NOT YET WORKING: NETWORK REPORTING CONFIGURATION
|
||||||
|
@ -183,6 +183,23 @@ def make_single_bridge(_tgid,_sourcesystem,_slot,_tmout):
|
|||||||
|
|
||||||
BRIDGE_SEMA.release()
|
BRIDGE_SEMA.release()
|
||||||
|
|
||||||
|
#Make static bridge - used for on-the-fly relay bridges
|
||||||
|
def make_stat_bridge(_tgid):
|
||||||
|
BRIDGE_SEMA.acquire(blocking = True)
|
||||||
|
_tgid_s = str(int_id(_tgid))
|
||||||
|
BRIDGES[_tgid_s] = []
|
||||||
|
for _system in CONFIG['SYSTEMS']:
|
||||||
|
if _system[0:3] != 'OBP':
|
||||||
|
if CONFIG['SYSTEMS'][_system]['MODE'] == 'MASTER':
|
||||||
|
_tmout = CONFIG['SYSTEMS'][_system]['DEFAULT_UA_TIMER']
|
||||||
|
BRIDGES[_tgid_s].append({'SYSTEM': _system, 'TS': 1, 'TGID': _tgid,'ACTIVE': False,'TIMEOUT': _tmout * 60,'TO_TYPE': 'ON','OFF': [],'ON': [_tgid,],'RESET': [], 'TIMER': time()})
|
||||||
|
BRIDGES[_tgid_s].append({'SYSTEM': _system, 'TS': 2, 'TGID': _tgid,'ACTIVE': False,'TIMEOUT': _tmout * 60,'TO_TYPE': 'ON','OFF': [],'ON': [_tgid,],'RESET': [], 'TIMER': time()})
|
||||||
|
|
||||||
|
if _system[0:3] == 'OBP':
|
||||||
|
BRIDGES[_tgid_s].append({'SYSTEM': _system, 'TS': 1, 'TGID': _tgid,'ACTIVE': True,'TIMEOUT': '','TO_TYPE': 'STAT','OFF': [],'ON': [],'RESET': [], 'TIMER': time()})
|
||||||
|
|
||||||
|
BRIDGE_SEMA.release()
|
||||||
|
|
||||||
|
|
||||||
def make_default_reflector(reflector,_tmout,system):
|
def make_default_reflector(reflector,_tmout,system):
|
||||||
bridge = '#'+str(reflector)
|
bridge = '#'+str(reflector)
|
||||||
@ -333,6 +350,20 @@ def rule_timer_loop():
|
|||||||
if CONFIG['REPORTS']['REPORT']:
|
if CONFIG['REPORTS']['REPORT']:
|
||||||
report_server.send_clients(b'bridge updated')
|
report_server.send_clients(b'bridge updated')
|
||||||
|
|
||||||
|
def statTrimmer():
|
||||||
|
logger.debug('(ROUTER) STAT trimmer loop started')
|
||||||
|
_remove_bridges = []
|
||||||
|
for _bridge in BRIDGES:
|
||||||
|
_bridge_stat = False
|
||||||
|
for _system in BRIDGES[_bridge]:
|
||||||
|
if _system['TO_TYPE'] == 'STAT':
|
||||||
|
_bridge_stat = True
|
||||||
|
if _bridge_stat:
|
||||||
|
_remove_bridges.append(_system)
|
||||||
|
for _bridgerem in _remove_bridges:
|
||||||
|
del BRIDGES[_bridgerem]
|
||||||
|
logger.debug('(ROUTER) STAT bridge %s removed',_bridgerem)
|
||||||
|
|
||||||
|
|
||||||
# run this every 10 seconds to trim orphaned stream ids
|
# run this every 10 seconds to trim orphaned stream ids
|
||||||
def stream_trimmer_loop():
|
def stream_trimmer_loop():
|
||||||
@ -1121,6 +1152,12 @@ class routerOBP(OPENBRIDGE):
|
|||||||
#Save this sequence number
|
#Save this sequence number
|
||||||
self._lastSeq = _seq
|
self._lastSeq = _seq
|
||||||
|
|
||||||
|
#Create STAT bridge for unknown TG
|
||||||
|
if CONFIG['GLOBAL']['GEN_STAT_BRIDGES']:
|
||||||
|
if int_id(_dst_id) >= 5 and int_id(_dst_id) != 9 and (str(int_id(_dst_id)) not in BRIDGES):
|
||||||
|
logger.info('(%s) Bridge for STAT TG %s does not exist. Creating',self._system, int_id(_dst_id))
|
||||||
|
make_stat_bridge(_dst_id)
|
||||||
|
|
||||||
_sysIgnore = []
|
_sysIgnore = []
|
||||||
for _bridge in BRIDGES:
|
for _bridge in BRIDGES:
|
||||||
#if _bridge[0:1] != '#':
|
#if _bridge[0:1] != '#':
|
||||||
@ -1857,6 +1894,12 @@ if __name__ == '__main__':
|
|||||||
mysql = mysql_task.start(30)
|
mysql = mysql_task.start(30)
|
||||||
mysql.addErrback(loopingErrHandle)
|
mysql.addErrback(loopingErrHandle)
|
||||||
|
|
||||||
|
#STAT trimmer - once every 24 hours
|
||||||
|
if CONFIG['GLOBAL']['GEN_STAT_BRIDGES']:
|
||||||
|
stat_trimmer_task = task.LoopingCall(statTrimmer)
|
||||||
|
stat_trimmer = stat_trimmer_task.start(86400)
|
||||||
|
stat_trimmer.addErrback(loopingErrHandle)
|
||||||
|
|
||||||
#more threads
|
#more threads
|
||||||
reactor.suggestThreadPoolSize(30)
|
reactor.suggestThreadPoolSize(30)
|
||||||
|
|
||||||
|
@ -121,7 +121,8 @@ def build_config(_config_file):
|
|||||||
'REG_ACL': config.get(section, 'REG_ACL'),
|
'REG_ACL': config.get(section, 'REG_ACL'),
|
||||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||||
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
||||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL')
|
'TG2_ACL': config.get(section, 'TGID_TS2_ACL'),
|
||||||
|
'GEN_STAT_BRIDGES': config.getboolean(section, 'GEN_STAT_BRIDGES')
|
||||||
})
|
})
|
||||||
|
|
||||||
elif section == 'REPORTS':
|
elif section == 'REPORTS':
|
||||||
|
Loading…
Reference in New Issue
Block a user