Prepare for Dynamic Rule Changes

Change the name of the rules read from the file, then copy it to
“RULES” after processing. This will allow us to modify RULES on the
fly, while keeping the “original” - This is a hook to add dynamic rule
changes.
This commit is contained in:
Cort Buffington 2015-05-17 11:19:19 -05:00
parent b7f6b62993
commit d4b51fd08f

View File

@ -64,7 +64,7 @@ TS_CLEAR_TIME = .2
# but it has to exist.
#
try:
from bridge_rules import RULES
from bridge_rules import RULES as RULES_FILE
logger.info('Bridge rules file found and rules imported')
except ImportError:
sys.exit('Bridging rules file not found or invalid')
@ -73,8 +73,8 @@ except ImportError:
# we need to send in the actual data packets.
#
for _ipsc in RULES:
for _rule in RULES[_ipsc]['GROUP_VOICE']:
for _ipsc in RULES_FILE:
for _rule in RULES_FILE[_ipsc]['GROUP_VOICE']:
_rule['SRC_GROUP'] = hex_str_3(_rule['SRC_GROUP'])
_rule['DST_GROUP'] = hex_str_3(_rule['DST_GROUP'])
_rule['SRC_TS'] = _rule['SRC_TS'] - 1
@ -82,9 +82,11 @@ for _ipsc in RULES:
if _ipsc not in NETWORK:
sys.exit('ERROR: Bridge rules found for an IPSC network not configured in main configuration')
for _ipsc in NETWORK:
if _ipsc not in RULES:
if _ipsc not in RULES_FILE:
sys.exit('ERROR: Bridge rules not found for all IPSC network configured')
RULES = RULES_FILE
# Import List of Bridges
# This is how we identify known bridges. If one of these is present
# and it's mode byte is set to bridge, we don't