Merge branch 'configpersist'

key
Simon 4 years ago
commit a2f361040f

@ -739,6 +739,10 @@ def ident():
def options_config():
logger.debug('(OPTIONS) Running options parser')
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:
if CONFIG['SYSTEMS'][_system]['MODE'] != 'MASTER':
continue
@ -2828,7 +2832,22 @@ if __name__ == '__main__':
if not cli_args.CONFIG_FILE:
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
# Call the external routine to build the configuration dictionary
#configP = False
#if os.path.isfile('config.pkl'):
#if os.path.getmtime('config.pkl') > (time() - 25):
#try:
#with open('config.pkl','rb') as _fh:
#CONFIG = pickle.load(_fh)
#print('(CONFIG) loaded config .pkl from previous shutdown')
#configP = True
#except:
#print('(CONFIG) Cannot load config.pkl file')
#CONFIG = config.build_config(cli_args.CONFIG_FILE)
#else:
#os.unlink("config.pkl")
#else:
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)
@ -2911,7 +2930,21 @@ if __name__ == '__main__':
except (ImportError, FileNotFoundError):
sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
# Build the routing rules file
#Load pickle of bridges if it's less than 25 seconds old
#if os.path.isfile('bridge.pkl'):
#if os.path.getmtime('config.pkl') > (time() - 25):
#try:
#with open('bridge.pkl','rb') as _fh:
#BRIDGES = pickle.load(_fh)
#logger.info('(BRIDGE) loaded bridge.pkl from previous shutdown')
#except:
#logger.warning('(BRIDGE) Cannot load bridge.pkl file')
#BRIDGES = make_bridges(rules_module.BRIDGES)
#else:
#BRIDGES = make_bridges(rules_module.BRIDGES)
#os.unlink("bridge.pkl")
#else:
BRIDGES = make_bridges(rules_module.BRIDGES)
#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]:
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]['_reset'] = True
else:
del self._CONFIG['SYSTEMS'][self._system]['OPTIONS']
w
logger.info('(%s) Deleting HBP Options',self._system)
# Aliased in __init__ to maintenance_loop if system is a peer
@ -1074,9 +1076,11 @@ class HBSYSTEM(DatagramProtocol):
if '_default_options' in self._CONFIG['SYSTEMS'][self._system]:
self._CONFIG['SYSTEMS'][self._system]['OPTIONS'] = 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]['_reset'] = True
else:
logger.info('(%s) Deleting HBP Options',self._system)
del self._CONFIG['SYSTEMS'][self._system]['OPTIONS']
self._CONFIG['SYSTEMS'][self._system]['_reset'] = True
else:
_peer_id = _data[4:8] # Configure Command

Loading…
Cancel
Save

Powered by TurnKey Linux.