Skip to content
Snippets Groups Projects
Commit da674847 authored by Florent Thiery's avatar Florent Thiery
Browse files

detect if a ms vhost is not in the celerity conf, refs #20845

parent c12ca399
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,13 @@ resolution_ignored = conf.get('TESTER_VHOST_RESOLUTION_IGNORED', '').split(',') ...@@ -44,6 +44,13 @@ resolution_ignored = conf.get('TESTER_VHOST_RESOLUTION_IGNORED', '').split(',')
requests.packages.urllib3.disable_warnings() requests.packages.urllib3.disable_warnings()
found = False found = False
errors = 0 errors = 0
warnings = False
def check_celerity_conf(url):
with open('/etc/celerity/config.py', 'r') as f:
d = f.read()
return url in d
for name in os.listdir(nginx_dir): for name in os.listdir(nginx_dir):
path = os.path.join(nginx_dir, name) path = os.path.join(nginx_dir, name)
with open(path, 'r') as fo: with open(path, 'r') as fo:
...@@ -62,6 +69,9 @@ for name in os.listdir(nginx_dir): ...@@ -62,6 +69,9 @@ for name in os.listdir(nginx_dir):
continue # status vhost continue # status vhost
found = True found = True
url = '%s://%s' % ('https' if https else 'http', domain) url = '%s://%s' % ('https' if https else 'http', domain)
if name.startswith('mediaserver') and not check_celerity_conf(url):
sys.stdout.write('Url %s not found in celerity conf; is should also be set in the MediaWorker\n' % url)
warnings = True
sys.stdout.write('Testing url "%s":\n' % url) sys.stdout.write('Testing url "%s":\n' % url)
# test domain IP # test domain IP
ip_error = None ip_error = None
...@@ -118,8 +128,10 @@ for name in os.listdir(nginx_dir): ...@@ -118,8 +128,10 @@ for name in os.listdir(nginx_dir):
errors += 1 errors += 1
if errors: if errors:
print('%s vhost(s) did not correctly responded.' % errors) print('%s vhost(s) did not correctly respond.' % errors)
sys.exit(1) sys.exit(1)
elif warnings:
sys.exit(3)
if not found: if not found:
print('No vhost found in Nginx sites-enabled dir.') print('No vhost found in Nginx sites-enabled dir.')
sys.exit(1) sys.exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment