Comment out bridge and config pickle

Reset bridges on logout.
key
Simon 4 years ago
parent c2b5375729
commit fd3e94da9f

@ -757,6 +757,10 @@ def ident():
def options_config(): def options_config():
logger.debug('(OPTIONS) Running options parser') logger.debug('(OPTIONS) Running options parser')
for _system in CONFIG['SYSTEMS']: for _system in CONFIG['SYSTEMS']:
if '_reset' in CONFIG['SYSTEMS'][_system] and CONFIG['SYSTEMS'][_system]['_reset']:
logger.debug('(OPTIONS) Bridge reset for %s - no peers'._system)
remove_bridge_system(_system)
CONFIG['SYSTEMS'][_system]['_reset'] = False
try: try:
if CONFIG['SYSTEMS'][_system]['MODE'] != 'MASTER': if CONFIG['SYSTEMS'][_system]['MODE'] != 'MASTER':
continue continue
@ -2846,22 +2850,22 @@ if __name__ == '__main__':
if not cli_args.CONFIG_FILE: if not cli_args.CONFIG_FILE:
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg' cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
configP = False #configP = False
file_exists = os.path.isfile('config.pkl') == True #if os.path.isfile('config.pkl'):
if file_exists: #if os.path.getmtime('config.pkl') > (time() - 25):
if os.path.getmtime('config.pkl') > (time() - 25): #try:
try: #with open('config.pkl','rb') as _fh:
with open('config.pkl','rb') as _fh: #CONFIG = pickle.load(_fh)
CONFIG = pickle.load(_fh) #print('(CONFIG) loaded config .pkl from previous shutdown')
print('(CONFIG) loaded config .pkl from previous shutdown') #configP = True
configP = True #except:
except: #print('(CONFIG) Cannot load config.pkl file')
print('(CONFIG) Cannot load config.pkl file') #CONFIG = config.build_config(cli_args.CONFIG_FILE)
CONFIG = config.build_config(cli_args.CONFIG_FILE) #else:
else: #os.unlink("config.pkl")
os.unlink("config.pkl") #else:
else:
CONFIG = config.build_config(cli_args.CONFIG_FILE) CONFIG = config.build_config(cli_args.CONFIG_FILE)
# Ensure we have a path for the rules file, if one wasn't specified, then use the default (top of file) # Ensure we have a path for the rules file, if one wasn't specified, then use the default (top of file)
if not cli_args.RULES_FILE: if not cli_args.RULES_FILE:
@ -2948,20 +2952,21 @@ if __name__ == '__main__':
sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE)) sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
#Load pickle of bridges if it's less than 25 seconds old #Load pickle of bridges if it's less than 25 seconds old
if os.path.isfile('bridge.pkl'): #if os.path.isfile('bridge.pkl'):
if os.path.getmtime('config.pkl') > (time() - 25): #if os.path.getmtime('config.pkl') > (time() - 25):
try: #try:
with open('bridge.pkl','rb') as _fh: #with open('bridge.pkl','rb') as _fh:
BRIDGES = pickle.load(_fh) #BRIDGES = pickle.load(_fh)
logger.info('(BRIDGE) loaded bridge.pkl from previous shutdown') #logger.info('(BRIDGE) loaded bridge.pkl from previous shutdown')
except: #except:
logger.warning('(BRIDGE) Cannot load bridge.pkl file') #logger.warning('(BRIDGE) Cannot load bridge.pkl file')
BRIDGES = make_bridges(rules_module.BRIDGES) #BRIDGES = make_bridges(rules_module.BRIDGES)
else: #else:
BRIDGES = make_bridges(rules_module.BRIDGES) #BRIDGES = make_bridges(rules_module.BRIDGES)
os.unlink("bridge.pkl") #os.unlink("bridge.pkl")
else: #else:
BRIDGES = make_bridges(rules_module.BRIDGES)
BRIDGES = make_bridges(rules_module.BRIDGES)
#Subscriber map for unit calls - complete with test entry #Subscriber map for unit calls - complete with test entry

@ -776,8 +776,10 @@ class HBSYSTEM(DatagramProtocol):
if '_default_options' in self._CONFIG['SYSTEMS'][self._system]: if '_default_options' in self._CONFIG['SYSTEMS'][self._system]:
logger.info('(%s) Setting default Options: %s',self._system, self._CONFIG['SYSTEMS'][self._system]['_default_options']) logger.info('(%s) Setting default Options: %s',self._system, self._CONFIG['SYSTEMS'][self._system]['_default_options'])
self._CONFIG['SYSTEMS'][self._system]['OPTIONS'] = self._CONFIG['SYSTEMS'][self._system]['_default_options'] self._CONFIG['SYSTEMS'][self._system]['OPTIONS'] = self._CONFIG['SYSTEMS'][self._system]['_default_options']
self._CONFIG['SYSTEMS'][self._system]['_reset'] = True
else: else:
del self._CONFIG['SYSTEMS'][self._system]['OPTIONS'] del self._CONFIG['SYSTEMS'][self._system]['OPTIONS']
self._CONFIG['SYSTEMS'][self._system]['_reset'] = True
logger.info('(%s) Deleting HBP Options',self._system) logger.info('(%s) Deleting HBP Options',self._system)
# Aliased in __init__ to maintenance_loop if system is a peer # Aliased in __init__ to maintenance_loop if system is a peer

Loading…
Cancel
Save

Powered by TurnKey Linux.