Skip to content

Commit

Permalink
DNS Query Client - raise ValueError if provided Nameservers list is e…
Browse files Browse the repository at this point in the history
…mpty

There is no sense to "dig" not existing DNS backends, therefor
when Query Client object is being created with an empty list for
the namesrevers attribute, ValueError will be raised.

Change-Id: I156508e404dc2d2966a189941b0b4ff13412953f
  • Loading branch information
zahlabut committed Oct 3, 2022
1 parent 66b9b0c commit 6c251b4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions designate_tempest_plugin/services/dns/query/query_client.py
Expand Up @@ -24,14 +24,20 @@ class QueryClient(object):

def __init__(self, nameservers=None, query_timeout=None,
build_interval=None, build_timeout=None):
self.nameservers = nameservers or []
self.nameservers = self._nameservers_not_empty(
nameservers or CONF.dns.nameservers)
self.query_timeout = query_timeout or CONF.dns.query_timeout
self.build_interval = build_interval or CONF.dns.build_interval
self.build_timeout = build_timeout or CONF.dns.build_timeout

self.clients = [SingleQueryClient(ns, query_timeout=query_timeout)
for ns in nameservers]

def _nameservers_not_empty(self, nameservers_list):
if not nameservers_list:
raise ValueError('Nameservers list cannot be empty and it should '
'contain DNS backend IPs to "dig" for')
return nameservers_list

def query(self, zone_name, rdatatype):
return [c.query(zone_name, rdatatype) for c in self.clients]

Expand Down

0 comments on commit 6c251b4

Please sign in to comment.