dns¶
DNS module.
-
class
spicerack.dns.
Dns
(*, nameserver_address=None, dry_run=True)[source]¶ Bases:
object
Class to interact with the DNS.
-
static
_parse_targets
(rrset)[source]¶ Extract and return all the matching names from the given rrset without the trailing dot.
Parameters: rrset (dns.rrset.RRset) -- the RRset to parse. Returns: the list of absolute target record names as strings without the trailing dot. Return type: list Raises: spicerack.dns.DnsError
-- if a relative record is found.
-
_resolve_addresses
(name, record_type)[source]¶ Extract and return all the matching addresses for the given name and record type.
Parameters: Returns: the list of IPv4 or IPv6 addresses as strings returned by the DNS response.
Return type:
-
resolve
(qname, record_type)[source]¶ Perform a DNS lookup for the given qname and record type.
Parameters: Returns: the DNS response.
Return type: dns.resolver.Answer
Raises: spicerack.dns.DnsNotFound
-- if there are no records for the given record type but the qname has records for different record type(s).spicerack.dns.DnsError
-- on generic error.
-
resolve_cname
(name)[source]¶ Perform a DNS lookup for CNAME record for the given name.
Parameters: name (str) -- the name to resolve. Returns: the absolute target name for this CNAME, without the trailing dot. Return type: str
-
resolve_ips
(name)[source]¶ Perform a DNS lookup for A and AAAA records for the given name.
Parameters: name (str) -- the name to resolve. Returns: the list of IPv4 and IPv6 addresses as strings returned by the DNS response. Return type: list
-
resolve_ipv4
(name)[source]¶ Perform a DNS lookup for an A record for the given name.
Parameters: name (str) -- the name to resolve. Returns: the list of IPv4 addresses as strings returned by the DNS response. Return type: list
-
static
-
exception
spicerack.dns.
DnsError
[source]¶ Bases:
spicerack.exceptions.SpicerackError
Custom exception class for errors of the Dns class.
-
exception
spicerack.dns.
DnsNotFound
[source]¶ Bases:
spicerack.dns.DnsError
Custom exception class to indicate the record was not found.
One or more resource records exist for this domain but there isn’t a record matching the resource record type.