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
6e666b96
Commit
6e666b96
authored
5 years ago
by
Nicolas KAROLAK
Browse files
Options
Downloads
Patches
Plain Diff
make use of nmcli when systemd-resolved is used
parent
28d05259
No related branches found
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
+10
-15
10 additions, 15 deletions
tests/test_dns_records.py
with
10 additions
and
15 deletions
tests/test_dns_records.py
+
10
−
15
View file @
6e666b96
...
...
@@ -15,21 +15,18 @@ sys.path.append(str(Path(__file__).parents[1].resolve()))
from
envsetup
import
utils
as
u
# noqa: E402
def
get_dns_servers
()
->
list
:
servers
=
list
()
def
get_dns_servers
()
->
set
:
with
open
(
"
/etc/resolv.conf
"
,
"
r
"
)
as
f
:
d
=
f
.
read
().
strip
()
for
l
in
d
.
split
(
"
\n
"
):
if
l
.
startswith
(
"
nameserver
"
):
servers
.
append
(
l
.
split
(
"
nameserver
"
)[
1
])
if
servers
==
[
"
127.0.1.1
"
]:
# NetworkManager
servers
=
[
l
.
split
()[
1
]
for
l
in
d
.
split
(
"
\n
"
)
if
l
.
startswith
(
"
nameserver
"
)]
if
len
(
servers
)
and
servers
[
0
].
startswith
(
"
127.0.
"
):
# network-manager or systemd-resolved
_
,
output
=
subprocess
.
getstatusoutput
(
"
nmcli -f all device show | grep IP4.DNS | awk
'
{ print $2 }
'"
)
servers
.
extend
(
output
.
split
(
"
\n
"
)
)
servers
=
output
.
split
(
"
\n
"
)
return
servers
return
set
(
servers
)
def
get_result
(
output
:
str
)
->
str
:
...
...
@@ -38,7 +35,7 @@ def get_result(output: str) -> str:
return
line
.
split
(
"
has address
"
)[
1
]
def
check_dns
(
hostname
:
str
,
expected_ip
:
str
,
resolvers
:
li
st
)
->
tuple
:
def
check_dns
(
hostname
:
str
,
expected_ip
:
str
,
resolvers
:
s
e
t
)
->
tuple
:
warnings
=
0
errors
=
0
...
...
@@ -50,8 +47,6 @@ def check_dns(hostname: str, expected_ip: str, resolvers: list) -> tuple:
address
=
get_result
(
output
)
if
address
==
expected_ip
:
u
.
success
(
"
dns({}): {} -> {}
"
.
format
(
resolver
,
hostname
,
address
))
elif
address
==
"
127.0.0.1
"
and
resolver
==
"
127.0.0.53
"
:
u
.
success
(
"
dns({}): {} -> {}
"
.
format
(
resolver
,
hostname
,
address
))
else
:
u
.
error
(
"
dns({}): {} -> {} (should be {})
"
.
format
(
...
...
@@ -66,7 +61,7 @@ def check_dns(hostname: str, expected_ip: str, resolvers: list) -> tuple:
return
warnings
,
errors
def
check_resolver
(
conf
:
dict
,
resolvers
:
li
st
,
ip
:
str
)
->
tuple
:
def
check_resolver
(
conf
:
dict
,
resolvers
:
s
e
t
,
ip
:
str
)
->
tuple
:
warnings
=
0
errors
=
0
...
...
@@ -74,8 +69,8 @@ def check_resolver(conf: dict, resolvers: list, ip: str) -> tuple:
for
conf_resolver_key
in
conf_resolvers_keys
:
conf_resolver
=
conf
.
get
(
conf_resolver_key
)
if
conf_resolver
and
conf_resolver
not
in
resolvers
:
u
.
error
(
"
resolver {} not configured
"
.
format
(
conf_resolver
))
error
s
+=
1
u
.
warning
(
"
resolver {} not configured
"
.
format
(
conf_resolver
))
warning
s
+=
1
if
not
ip
and
(
not
errors
):
u
.
info
(
"
no IP set in configuration , unable to test DNS
"
)
...
...
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