def exclude(): """Excludes applications from being configured.""" ex = props.commandline.exclude for e in ex.split(): app = appstrategy.get_app(e) if app and not app.strategy == 'openvpn': app.configure = False
def list_configurations(): """Prints a list of installed OpenVPN configurations.""" lis = properties.get_default_hosts_list(names_only=True) configs = dict() # Checks if configuration is installed for a given config_id for c in sorted(lis): config = {'host': re.sub('_', ' ', c), 'openvpn': '', 'apps': ''} for app_name in appstrategy.get_supported_apps(): app = appstrategy.get_app(app_name) if app.configure and app.find_config(c): logger.debug('Configuring %s for %s' % (c, app.strategy)) if app_name == 'openvpn': config['openvpn'] = '*' else: config['apps'] += '[' + app_name + ']' configs[c] = config print("List of OpenVPN configurations") for c in configs: if configs[c]['openvpn']: print(' {openvpn} {host} {apps}'.format(**configs[c])) else: print(' {host} {apps}'.format(**configs[c])) sys.exit()
def auto_configure(): """Auto configures applications""" for config in properties.props.hosts: for app_name in appstrategy.get_supported_apps(): app = appstrategy.get_app(app_name) if app.configure: logger.debug("Configuring configurations for %s" % app_name) app.config(config)
def remove_configurations(): """Removes configurations based on openvpn.configs""" logger.debug("Removing configurations!") for app_name in appstrategy.get_supported_apps(): app = appstrategy.get_app(app_name) app.remove_configs()