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. # but it has to exist.
# #
try: try:
from bridge_rules import RULES from bridge_rules import RULES as RULES_FILE
logger.info('Bridge rules file found and rules imported') logger.info('Bridge rules file found and rules imported')
except ImportError: except ImportError:
sys.exit('Bridging rules file not found or invalid') sys.exit('Bridging rules file not found or invalid')
@ -73,8 +73,8 @@ except ImportError:
# we need to send in the actual data packets. # we need to send in the actual data packets.
# #
for _ipsc in RULES: for _ipsc in RULES_FILE:
for _rule in RULES[_ipsc]['GROUP_VOICE']: for _rule in RULES_FILE[_ipsc]['GROUP_VOICE']:
_rule['SRC_GROUP'] = hex_str_3(_rule['SRC_GROUP']) _rule['SRC_GROUP'] = hex_str_3(_rule['SRC_GROUP'])
_rule['DST_GROUP'] = hex_str_3(_rule['DST_GROUP']) _rule['DST_GROUP'] = hex_str_3(_rule['DST_GROUP'])
_rule['SRC_TS'] = _rule['SRC_TS'] - 1 _rule['SRC_TS'] = _rule['SRC_TS'] - 1
@ -82,9 +82,11 @@ for _ipsc in RULES:
if _ipsc not in NETWORK: if _ipsc not in NETWORK:
sys.exit('ERROR: Bridge rules found for an IPSC network not configured in main configuration') sys.exit('ERROR: Bridge rules found for an IPSC network not configured in main configuration')
for _ipsc in NETWORK: 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') sys.exit('ERROR: Bridge rules not found for all IPSC network configured')
RULES = RULES_FILE
# Import List of Bridges # Import List of Bridges
# This is how we identify known bridges. If one of these is present # 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 # and it's mode byte is set to bridge, we don't
@ -106,7 +108,7 @@ class bridgeIPSC(IPSC):
else: else:
self.BRIDGE = True self.BRIDGE = True
logger.info('Initializing standard bridging') logger.info('Initializing standard bridging')
self.IPSC_STATUS = { self.IPSC_STATUS = {
'TS1': {'RX_GROUP':'\x00', 'TX_GROUP':'\x00', 'RX_TIME':0, 'TX_TIME':0, 'RX_SRC_SUB':'\x00', 'TX_SRC_SUB':'\x00'}, 'TS1': {'RX_GROUP':'\x00', 'TX_GROUP':'\x00', 'RX_TIME':0, 'TX_TIME':0, 'RX_SRC_SUB':'\x00', 'TX_SRC_SUB':'\x00'},
'TS2': {'RX_GROUP':'\x00', 'TX_GROUP':'\x00', 'RX_TIME':0, 'TX_TIME':0, 'RX_SRC_SUB':'\x00', 'TX_SRC_SUB':'\x00'} 'TS2': {'RX_GROUP':'\x00', 'TX_GROUP':'\x00', 'RX_TIME':0, 'TX_TIME':0, 'RX_SRC_SUB':'\x00', 'TX_SRC_SUB':'\x00'}