diff --git a/bridge_master.py b/bridge_master.py index 58e5bd0..6d0648e 100755 --- a/bridge_master.py +++ b/bridge_master.py @@ -565,9 +565,29 @@ def options_config(): if not _options['DEFAULT_UA_TIMER'].isdigit(): logger.debug('(OPTIONS) %s - DEFAULT_REFLECTOR is not an integer, ignoring',_system) continue + + _tmout = int(_options['DEFAULT_UA_TIMER']) + + logger.debug('(OPTIONS) %s Updating DEFAULT_UA_TIMER for existing bridges.',_system) + remove_bridge_system(_system) + for _bridge in BRIDGES: + ts1 = False + ts2 = False + for i,e in enumerate(BRIDGES[_bridge]): + if e['SYSTEM'] == _system and e['TS'] == 1: + ts1 = True + if e['SYSTEM'] == _system and e['TS'] == 2: + ts2 = True + if _bridge[0:1] != '#': + if ts1 == False: + BRIDGES[_bridge].append({'SYSTEM': _system, 'TS': 1, 'TGID': bytes_3(int(_bridge)),'ACTIVE': False,'TIMEOUT': _tmout * 60,'TO_TYPE': 'ON','OFF': [],'ON': [bytes_3(int(_bridge)),],'RESET': [], 'TIMER': time()}) + if ts2 == False: + BRIDGES[_bridge].append({'SYSTEM': _system, 'TS': 2, 'TGID': bytes_3(int(_bridge)),'ACTIVE': False,'TIMEOUT': _tmout * 60,'TO_TYPE': 'ON','OFF': [],'ON': [bytes_3(int(_bridge)),],'RESET': [], 'TIMER': time()}) + else: + if ts2 == False: + BRIDGES[_bridge].append({'SYSTEM': _system, 'TS': 2, 'TGID': bytes_3(9),'ACTIVE': False,'TIMEOUT': _tmout * 60,'TO_TYPE': 'ON','OFF': [bytes_3(4000)],'ON': [],'RESET': [], 'TIMER': time()}) if int(_options['DEFAULT_REFLECTOR']) != CONFIG['SYSTEMS'][_system]['DEFAULT_REFLECTOR']: - _tmout = int(_options['DEFAULT_UA_TIMER']) if int(_options['DEFAULT_REFLECTOR']) > 0: logger.debug('(OPTIONS) %s default reflector changed, updating',_system) reset_default_reflector(CONFIG['SYSTEMS'][_system]['DEFAULT_REFLECTOR'],_tmout,_system) @@ -778,14 +798,51 @@ def mysql_config_check(SQLGETCONFIG): if SQLCONFIG[system]['DEFAULT_UA_TIMER'] != CONFIG['SYSTEMS'][system]['DEFAULT_UA_TIMER']: if 'OPTIONS' not in CONFIG['SYSTEMS'][system]: - logger.debug('(MYSQL) %s DEFAULT_UA_TIMER changed. Killing HBP listener. Will restart in 1 minute',system) - systems[system].master_dereg() - if systems[system]._system_maintenance is not None and systems[system]._system_maintenance.running == True: - systems[system]._system_maintenance.stop() - systems[system]._system_maintenance = None + logger.debug('(MYSQL) %s DEFAULT_UA_TIMER changed. Updating bridges.',system) remove_bridge_system(system) - listeningPorts[system].stopListening() - SQLCONFIG[system]['ENABLED'] = False + for _bridge in BRIDGES: + ts1 = False + ts2 = False + for i,e in enumerate(BRIDGES[_bridge]): + if e['SYSTEM'] == system and e['TS'] == 1: + ts1 = True + if e['SYSTEM'] == system and e['TS'] == 2: + ts2 = True + if _bridge[0:1] != '#': + if ts1 == False: + BRIDGES[_bridge].append({'SYSTEM': system, 'TS': 1, 'TGID': bytes_3(int(_bridge)),'ACTIVE': False,'TIMEOUT': _tmout * 60,'TO_TYPE': 'ON','OFF': [],'ON': [bytes_3(int(_bridge)),],'RESET': [], 'TIMER': time()}) + if ts2 == False: + BRIDGES[_bridge].append({'SYSTEM': system, 'TS': 2, 'TGID': bytes_3(int(_bridge)),'ACTIVE': False,'TIMEOUT': _tmout * 60,'TO_TYPE': 'ON','OFF': [],'ON': [bytes_3(int(_bridge)),],'RESET': [], 'TIMER': time()}) + else: + if ts2 == False: + BRIDGES[_bridge].append({'SYSTEM': system, 'TS': 2, 'TGID': bytes_3(9),'ACTIVE': False,'TIMEOUT': _tmout * 60,'TO_TYPE': 'ON','OFF': [bytes_3(4000)],'ON': [],'RESET': [], 'TIMER': time()}) + + + if SQLCONFIG[system]['DEFAULT_REFLECTOR'] > 0: + # if 'OPTIONS' not in SQLCONFIG[system]: + logger.debug('(MYSQL) %s setting default reflector',system) + make_default_reflector(SQLCONFIG[system]['DEFAULT_REFLECTOR'],_tmout,system) + + if SQLCONFIG[system]['TS1_STATIC']: + # if 'OPTIONS' not in SQLCONFIG[system]: + logger.debug('(MYSQL) %s setting static TGs on TS1',system) + ts1 = SQLCONFIG[system]['TS1_STATIC'].split(',') + for tg in ts1: + if not tg: + continue + tg = int(tg) + make_static_tg(tg,1,_tmout,system) + + if SQLCONFIG[system]['TS2_STATIC']: + logger.debug('(MYSQL) %s setting static TGs on TS2',system) + ts2 = SQLCONFIG[system]['TS2_STATIC'].split(',') + for tg in ts2: + if not tg: + continue + tg = int(tg) + make_static_tg(tg,2,_tmout,system) + + if SQLCONFIG[system]['IP'] != CONFIG['SYSTEMS'][system]['IP'] and CONFIG['SYSTEMS'][system]['ENABLED'] == True: logger.debug('(MYSQL) %s IP binding changed on enabled system, killing HBP listener. Will restart in 1 minute',system)