summaryrefslogtreecommitdiffstats
path: root/robotframework-onap/ONAPLibrary/DNSKeywords.py
diff options
context:
space:
mode:
Diffstat (limited to 'robotframework-onap/ONAPLibrary/DNSKeywords.py')
-rw-r--r--robotframework-onap/ONAPLibrary/DNSKeywords.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/robotframework-onap/ONAPLibrary/DNSKeywords.py b/robotframework-onap/ONAPLibrary/DNSKeywords.py
new file mode 100644
index 0000000..8f4e2f3
--- /dev/null
+++ b/robotframework-onap/ONAPLibrary/DNSKeywords.py
@@ -0,0 +1,23 @@
+import dns.message
+import dns.name
+import dns.query
+from robot.api.deco import keyword
+
+
+class DNSKeywords(object):
+ """ Utilities useful for DNS requests """
+
+ def __init__(self):
+ super(DNSKeywords, self).__init__()
+
+ @keyword
+ def dns_request(self, domain, ns):
+ """ return the ip address of the given domain name from the given nameserver """
+ request = dns.message.make_query(domain, dns.rdatatype.A)
+ request.flags |= dns.flags.AD
+ request.find_rrset(request.additional, dns.name.root, 65535, dns.rdatatype.OPT, create=True, force_unique=True)
+ response = dns.query.udp(request, ns)
+
+ for answer in response.answer:
+ for item in answer.items:
+ return item