diff --git a/bridge.py b/bridge.py index 797c252..60b1a38 100755 --- a/bridge.py +++ b/bridge.py @@ -1343,35 +1343,6 @@ if __name__ == '__main__': # Create the name-number mapping dictionaries 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 if CONFIG['REPORTS']['REPORT']: @@ -1428,11 +1399,25 @@ if __name__ == '__main__': # 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] + try: + remote_config = download_rules(LOCAL_CONFIG, cli_args.CONFIG_FILE) + # Build the routing rules file + BRIDGES = make_bridges(remote_config[1]) #make_bridges(rules_module.BRIDGES) + # 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: try: diff --git a/user_managment/app.py b/user_managment/app.py index 7a0e837..b101c60 100644 --- a/user_managment/app.py +++ b/user_managment/app.py @@ -1746,9 +1746,12 @@ def create_app(): bl.tg = _tg db.session.commit() - def bridge_delete(_name, _server): + def bridge_delete(_name): #, _server): bl = BridgeList.query.filter_by(bridge_name=_name).first() db.session.delete(bl) + sl = ServerList.query.all() + for i in sl: + delete_system_bridge(_name, i.name) db.session.commit() def generate_rules(_name): @@ -4271,6 +4274,8 @@ def create_app(): return render_template('flask_user_layout.html', markup_content = Markup(content)) @app.route('/manage_rules', methods=['POST', 'GET']) + @login_required + @roles_required('Admin') def manage_rules(): if request.args.get('save_bridge') == 'save': @@ -4547,12 +4552,14 @@ def create_app():

 

- +
+ + ''' for i in all_b: @@ -4561,6 +4568,8 @@ def create_app(): + + ''' b_list = b_list + '''
Name Public DescriptionTGID
''' + str(i.bridge_name) + ''' ''' + str(i.public_list) + ''' ''' + str(i.description) + '''''' + str(i.tg) + '''
@@ -4574,14 +4583,14 @@ def create_app(): - +
Add rule to ''' + str(i.name) + '''Add a rule to server: ''' + str(i.name) + '''
- +''' @@ -4596,7 +4605,7 @@ def create_app(): - + ''' r_list = r_list + '''
NameBridge Name - -
''' + str(x.bridge_name) + ''' Edit Bridge RulesDelete Bridge RulesDelete Bridge from this server

 

'''