summaryrefslogtreecommitdiffstats
path: root/utils/functest_utils.py
diff options
context:
space:
mode:
authorboucherv <valentin.boucher@orange.com>2016-08-03 11:17:10 +0200
committerboucherv <valentin.boucher@orange.com>2016-08-03 11:34:23 +0200
commit9f7f322f30921ecdc4c2f7e4b2e7a147ed9a6712 (patch)
tree1234449068c8d809f38cb6f52d9a1c6bdc7ec152 /utils/functest_utils.py
parent560ab3f2117181dee4a6eb32b3c8a093ca46afc0 (diff)
functest utils - get_resolvconf_ns() Ensure that dns works with dns name resolution
JIRA: FUNCTEST-402 Change-Id: I5fa9204aafb13330eb810950aa7bc728f1a69162 Signed-off-by: boucherv <valentin.boucher@orange.com>
Diffstat (limited to 'utils/functest_utils.py')
-rw-r--r--utils/functest_utils.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/utils/functest_utils.py b/utils/functest_utils.py
index b0014308e..5f790a015 100644
--- a/utils/functest_utils.py
+++ b/utils/functest_utils.py
@@ -16,10 +16,10 @@ import os
import os.path
import re
import shutil
-import socket
import subprocess
import sys
import urllib2
+import dns.resolver
import functest.ci.tier_builder as tb
from git import Repo
@@ -226,13 +226,17 @@ def get_resolvconf_ns():
nameservers = []
rconf = open("/etc/resolv.conf", "r")
line = rconf.readline()
+ resolver = dns.resolver.Resolver()
while line:
ip = re.search(r"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b", line)
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if ip:
- result = sock.connect_ex((ip.group(), 53))
- if result == 0:
- nameservers.append(ip.group())
+ resolver.nameservers = [str(ip)]
+ try:
+ result = resolver.query('opnfv.org')[0]
+ if result != "":
+ nameservers.append(ip.group())
+ except dns.exception.Timeout:
+ pass
line = rconf.readline()
return nameservers