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

check if ip is the right one, fix typo, check if resolvers are configured, refs #20581

parent b30a7143
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# Copyright 2017, Florent Thiery
'''
Checks that DNS records are provided by the customer servers
Checks that DNS records are provided by the customer servers are correctly set
'''
import subprocess
import os
......@@ -29,7 +29,7 @@ def get_result(output):
if "has address " in line:
return line.split("has address ")[1]
def check_dns(hostname):
def check_dns(hostname, expected_ip):
all_ok = True
for resolver in resolvers:
status, output = subprocess.getstatusoutput("host %s %s" % (hostname, resolver))
......@@ -37,6 +37,9 @@ def check_dns(hostname):
if success:
color = GREEN
address = get_result(output)
if address != expected_ip:
color = RED
all_ok = False
else:
color = RED
all_ok = False
......@@ -48,16 +51,32 @@ if os.path.isfile('../utils.py'):
all_ok = True
es_utils = imp.load_source('es_utils', '../utils.py')
conf = es_utils.load_conf()
servers = (
ip = conf.get('NETWORK_IP')
conf_resolvers_keys = (
'NETWORK_DNS1',
'NETWORK_DNS2',
)
for conf_resolver_key in conf_resolvers_keys:
conf_resolver = conf.get(conf_resolver_key)
if conf_resolver not in resolvers:
print('Resolver %s not configured on the system' % conf_resolver)
all_ok = False
conf_servers = (
'MS_SERVER_NAME',
'MONITOR_SERVER_NAME',
'CM_SERVER_NAME',
)
for s in servers:
hostname = conf.get('MS_SERVER_NAME')
ok = check_dns(hostname)
for s in conf_servers:
hostname = conf.get(s)
ok = check_dns(hostname, ip)
if not ok:
all_ok = False
else:
print('conf.sh not found')
sys.exit(1)
if not all_ok:
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