Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
55531557
Commit
55531557
authored
8 years ago
by
Florent Thiery
Browse files
Options
Downloads
Patches
Plain Diff
check if ip is the right one, fix typo, check if resolvers are configured, refs
#20581
parent
b30a7143
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_dns_records.py
+25
-6
25 additions, 6 deletions
tests/test_dns_records.py
with
25 additions
and
6 deletions
tests/test_dns_records.py
+
25
−
6
View file @
55531557
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment