fix offline config
This commit is contained in:
parent
5c73861c69
commit
e128e10dcc
53
bridge.py
53
bridge.py
@ -1343,35 +1343,6 @@ if __name__ == '__main__':
|
|||||||
# Create the name-number mapping dictionaries
|
# Create the name-number mapping dictionaries
|
||||||
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
||||||
|
|
||||||
# Import the ruiles file as a module, and create BRIDGES from it
|
|
||||||
## spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
|
|
||||||
## rules_module = importlib.util.module_from_spec(spec)
|
|
||||||
## print(download_rules(LOCAL_CONFIG, cli_args.CONFIG_FILE))
|
|
||||||
## try:
|
|
||||||
## spec.loader.exec_module(rules_module)
|
|
||||||
## logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
|
|
||||||
## except (ImportError, FileNotFoundError):
|
|
||||||
## sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
|
|
||||||
## # Attempt to use downloaded rules
|
|
||||||
## if LOCAL_CONFIG['USER_MANAGER']['REMOTE_CONFIG_ENABLED']:
|
|
||||||
##
|
|
||||||
## # Build the routing rules file
|
|
||||||
## BRIDGES = make_bridges(download_rules(LOCAL_CONFIG, cli_args.CONFIG_FILE)[1]) #make_bridges(rules_module.BRIDGES)
|
|
||||||
## # Get rule parameter for private calls
|
|
||||||
## UNIT = download_rules(LOCAL_CONFIG, cli_args.CONFIG_FILE)[0]
|
|
||||||
##
|
|
||||||
## else:
|
|
||||||
## try:
|
|
||||||
## spec.loader.exec_module(rules_module)
|
|
||||||
## logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
|
|
||||||
## except (ImportError, FileNotFoundError):
|
|
||||||
## sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
|
|
||||||
## spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
|
|
||||||
## rules_module = importlib.util.module_from_spec(spec)
|
|
||||||
## # Build the routing rules file
|
|
||||||
## BRIDGES = make_bridges(rules_module.BRIDGES)
|
|
||||||
## # Get rule parameter for private calls
|
|
||||||
## UNIT = rules_module.UNIT
|
|
||||||
|
|
||||||
# INITIALIZE THE REPORTING LOOP
|
# INITIALIZE THE REPORTING LOOP
|
||||||
if CONFIG['REPORTS']['REPORT']:
|
if CONFIG['REPORTS']['REPORT']:
|
||||||
@ -1428,11 +1399,25 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# Attempt to use downloaded rules
|
# Attempt to use downloaded rules
|
||||||
if LOCAL_CONFIG['USER_MANAGER']['REMOTE_CONFIG_ENABLED']:
|
if LOCAL_CONFIG['USER_MANAGER']['REMOTE_CONFIG_ENABLED']:
|
||||||
|
try:
|
||||||
# Build the routing rules file
|
remote_config = download_rules(LOCAL_CONFIG, cli_args.CONFIG_FILE)
|
||||||
BRIDGES = make_bridges(download_rules(LOCAL_CONFIG, cli_args.CONFIG_FILE)[1]) #make_bridges(rules_module.BRIDGES)
|
# Build the routing rules file
|
||||||
# Get rule parameter for private calls
|
BRIDGES = make_bridges(remote_config[1]) #make_bridges(rules_module.BRIDGES)
|
||||||
UNIT = download_rules(LOCAL_CONFIG, cli_args.CONFIG_FILE)[0]
|
# Get rule parameter for private calls
|
||||||
|
UNIT = remote_config[0]
|
||||||
|
except:
|
||||||
|
logger.error('Control server unreachable or other error. Using local config.')
|
||||||
|
spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
|
||||||
|
rules_module = importlib.util.module_from_spec(spec)
|
||||||
|
try:
|
||||||
|
spec.loader.exec_module(rules_module)
|
||||||
|
logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
|
||||||
|
except (ImportError, FileNotFoundError):
|
||||||
|
sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
|
||||||
|
# Build the routing rules file
|
||||||
|
BRIDGES = make_bridges(rules_module.BRIDGES)
|
||||||
|
# Get rule parameter for private calls
|
||||||
|
UNIT = rules_module.UNIT
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -1746,9 +1746,12 @@ def create_app():
|
|||||||
bl.tg = _tg
|
bl.tg = _tg
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
def bridge_delete(_name, _server):
|
def bridge_delete(_name): #, _server):
|
||||||
bl = BridgeList.query.filter_by(bridge_name=_name).first()
|
bl = BridgeList.query.filter_by(bridge_name=_name).first()
|
||||||
db.session.delete(bl)
|
db.session.delete(bl)
|
||||||
|
sl = ServerList.query.all()
|
||||||
|
for i in sl:
|
||||||
|
delete_system_bridge(_name, i.name)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
def generate_rules(_name):
|
def generate_rules(_name):
|
||||||
@ -4271,6 +4274,8 @@ def create_app():
|
|||||||
return render_template('flask_user_layout.html', markup_content = Markup(content))
|
return render_template('flask_user_layout.html', markup_content = Markup(content))
|
||||||
|
|
||||||
@app.route('/manage_rules', methods=['POST', 'GET'])
|
@app.route('/manage_rules', methods=['POST', 'GET'])
|
||||||
|
@login_required
|
||||||
|
@roles_required('Admin')
|
||||||
def manage_rules():
|
def manage_rules():
|
||||||
|
|
||||||
if request.args.get('save_bridge') == 'save':
|
if request.args.get('save_bridge') == 'save':
|
||||||
@ -4547,12 +4552,14 @@ def create_app():
|
|||||||
</table>
|
</table>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|
||||||
<table style="width: 400px; margin-left: auto; margin-right: auto;" border="1">
|
<table style="width: 600px; margin-left: auto; margin-right: auto;" border="1">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align: center;"><strong>Name</strong></td>
|
<td style="text-align: center;"><strong>Name</strong></td>
|
||||||
<td style="text-align: center;"><strong>Public</strong></td>
|
<td style="text-align: center;"><strong>Public</strong></td>
|
||||||
<td style="text-align: center;"><strong>Description</strong></td>
|
<td style="text-align: center;"><strong>Description</strong></td>
|
||||||
|
<td style="text-align: center;"><strong>TGID</strong></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
'''
|
'''
|
||||||
for i in all_b:
|
for i in all_b:
|
||||||
@ -4561,6 +4568,8 @@ def create_app():
|
|||||||
<td style="text-align: center;"><a href="manage_rules?edit_bridge=''' + str(i.bridge_name) + '''">''' + str(i.bridge_name) + '''</a>
|
<td style="text-align: center;"><a href="manage_rules?edit_bridge=''' + str(i.bridge_name) + '''">''' + str(i.bridge_name) + '''</a>
|
||||||
<td style="text-align: center;">''' + str(i.public_list) + '''</td>
|
<td style="text-align: center;">''' + str(i.public_list) + '''</td>
|
||||||
<td style="text-align: center;">''' + str(i.description) + '''</td>
|
<td style="text-align: center;">''' + str(i.description) + '''</td>
|
||||||
|
<td style="text-align: center;">''' + str(i.tg) + '''</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
'''
|
'''
|
||||||
b_list = b_list + '''</tbody></table>
|
b_list = b_list + '''</tbody></table>
|
||||||
@ -4574,14 +4583,14 @@ def create_app():
|
|||||||
<table style="width: 500px; margin-left: auto; margin-right: auto;" border="1">
|
<table style="width: 500px; margin-left: auto; margin-right: auto;" border="1">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align: center;"><strong>Add rule to <a href="manage_rules?add_rule=''' + str(i.name) + '''">''' + str(i.name) + '''</a></strong></td>
|
<td style="text-align: center;"><strong>Add a rule to server: <a href="manage_rules?add_rule=''' + str(i.name) + '''">''' + str(i.name) + '''</a></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table style="width: 500px; margin-left: auto; margin-right: auto;" border="1">
|
<table style="width: 500px; margin-left: auto; margin-right: auto;" border="1">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align: center;"><strong>Name</strong></td>
|
<td style="text-align: center;"><strong>Bridge Name</strong></td>
|
||||||
<td style="text-align: center;"><strong>-</strong></td>
|
<td style="text-align: center;"><strong>-</strong></td>
|
||||||
<td style="text-align: center;"><strong>-</strong></td>
|
<td style="text-align: center;"><strong>-</strong></td>
|
||||||
</tr>'''
|
</tr>'''
|
||||||
@ -4596,7 +4605,7 @@ def create_app():
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="text-align: center;">''' + str(x.bridge_name) + '''</td>
|
<td style="text-align: center;">''' + str(x.bridge_name) + '''</td>
|
||||||
<td style="text-align: center;"><a href="manage_rules?edit_rule=''' + str(i.name) + '''&bridge=''' + str(x.bridge_name) + '''">Edit Bridge Rules</a></td>
|
<td style="text-align: center;"><a href="manage_rules?edit_rule=''' + str(i.name) + '''&bridge=''' + str(x.bridge_name) + '''">Edit Bridge Rules</a></td>
|
||||||
<td style="text-align: center;"><a href="manage_rules?save_rule=delete&server=''' + str(i.name) + '''&bridge=''' + str(x.bridge_name) + '''">Delete Bridge Rules</a></td>
|
<td style="text-align: center;"><a href="manage_rules?save_rule=delete&server=''' + str(i.name) + '''&bridge=''' + str(x.bridge_name) + '''">Delete Bridge from this server</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
'''
|
'''
|
||||||
r_list = r_list + '''</tbody></table><p> </p>'''
|
r_list = r_list + '''</tbody></table><p> </p>'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user