From f86d22ec54ee80cc54ae80edc0bbad8e419ba95c Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Tue, 6 Aug 2019 14:19:32 -0500 Subject: [service https] T1443: reset defaults on 'delete service https api' --- src/conf_mode/http-api.py | 13 +++++++------ src/conf_mode/https.py | 5 ++++- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/conf_mode/http-api.py b/src/conf_mode/http-api.py index 7d618dded..c1d596ea3 100755 --- a/src/conf_mode/http-api.py +++ b/src/conf_mode/http-api.py @@ -84,15 +84,16 @@ def generate(http_api): def apply(http_api): if http_api is not None: os.system('sudo systemctl restart vyos-http-api.service') - for dep in dependencies: - cmd = '{0}/{1}'.format(vyos_conf_scripts_dir, dep) - try: - subprocess.check_call(cmd, shell=True) - except subprocess.CalledProcessError as err: - raise ConfigError("{}.".format(err)) else: os.system('sudo systemctl stop vyos-http-api.service') + for dep in dependencies: + cmd = '{0}/{1}'.format(vyos_conf_scripts_dir, dep) + try: + subprocess.check_call(cmd, shell=True) + except subprocess.CalledProcessError as err: + raise ConfigError("{}.".format(err)) + if __name__ == '__main__': try: c = get_config() diff --git a/src/conf_mode/https.py b/src/conf_mode/https.py index dae51dd7d..e1e81eef1 100755 --- a/src/conf_mode/https.py +++ b/src/conf_mode/https.py @@ -55,10 +55,13 @@ server { server_name {{ l_addr }}; {% endfor %} - location / { + # proxy settings for HTTP API, if enabled; 503, if not + location ~ /(retrieve|configure) { {% if api %} proxy_pass http://localhost:{{ api.port }}; proxy_buffering off; +{% else %} + return 503; {% endif %} } -- cgit v1.2.3