hcpsdk.ips
— name resolution¶
hcpsdk.ips provides name resolution service and IP address caching. Used by hcpsdk internally; exposed here as it might be useful alone.
Functions¶
query¶
-
hcpsdk.ips.
query
(fqdn, cache=False)[source]¶ Submit a DNS query, using socket.getaddrinfo() if cache=True, or dns.resolver.query() if cache=False.
Parameters: - fqdn – a FQDN to query DNS -or- a Request object
- cache – if True, use the system resolver (which might do local caching), else use an internal resolver, bypassing any cache available
Returns: an hcpsdk.ips.Response object
Raises: should never raise, as Exceptions are signaled through the Response.raised attribute
Classes¶
Circle¶
-
class
hcpsdk.ips.
Circle
(fqdn, port=443, dnscache=False)[source]¶ Resolve an FQDN (using query()), cache the acquired IP addresses and yield them round-robin.
Parameters: - fqdn – the FQDN to be resolved
- port – the port to be used by the hcpsdk.Target object
- dnscache – if True, use the system resolver (which might do local caching), else use an internal resolver, bypassing any cache available
Returns: an hcpsdk.ips.Response object
Read-only class attributes:
-
_addresses
¶ List of the cached IP addresses
Class methods:
Response¶
-
class
hcpsdk.ips.
Response
(fqdn, cache)[source]¶ DNS query Response object, returned by the query() function.
Parameters: - fqdn – the FQDN for the Response
- cache – Response from a query by-passing the local DNS cache (False) or using the system resolver (True)
Read-only class attributes:
-
ips
¶ List of resolved IP addresses (as strings)
-
cache
¶ False if the local DNS cache has been by-passed, True if the system-default resolver was used.
-
raised
¶ Empty string when no Exception were raised, otherwise the Exception’s error message.