Skip to content

Conversation

aaron-sierra
Copy link

@aaron-sierra aaron-sierra commented Apr 3, 2025

Fix DNS driver API inconsistencies

Description

Implement #2065

Summary

In general, commit messages provide necessary background regarding the changes made and why.

  • Drop Zerigo DNS
  • Deprecate outdated DNSimple DNS driver
  • Deprecate outdated RcodeZero DNS driver
  • Ignore AuroraDNS (see Remove unavailable cloud vendors: auroracompute; InternetSolutions; dimension data #2057)
  • Add unittest API request checking to remaining drivers
  • Add and leverage common code for domain/host name manipulation
  • Add and leverage common code for <type>[:<name>]-style record IDs
  • Change Record.id format for NS1 and Zonomi providers
  • Change Record.id interpretation for World Wide DNS

Status

  • Ready for review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

Aaron Sierra added 3 commits March 26, 2025 18:31
The Zerigo DNS service was permanently shut down on April 30, 2017.
The RcodeZero v1 API has been shutdown:
    https://my.rcodezero.at/openapi/
@aaron-sierra aaron-sierra force-pushed the dns-consistent-api branch 2 times, most recently from 0fe8ec0 to 46c0e4f Compare April 3, 2025 19:34
@aaron-sierra
Copy link
Author

The latest batch of updates includes changes from black and isort.

Aaron Sierra added 24 commits April 3, 2025 15:04
Enable unit tests to verify HTTP requests they submit.
* Fix test_create_zone_success
* Fix test_get_record_success
* Fix test_update_zone
Leverage the existing get_record.json for this test.
Previously, test_get_record_success() succeeded when receiving a record
completely unrelated to the originating .get_record() request. Update
the request to align with the expected response.
Previously, test_list_records_success() succeeded when receiving records
completely unrelated to the originating .list_records() request. Update
the request to align with the expected response.
Make NSOneResponse.errors and NSOneResponse.objects instance variables,
rather than class variables.

This was found due to errors in NSOneDNSDriver unit testing that only
appeared when tests were run together, not when tests were run
individually.
Add .hostname(), .fqdn(), and .prefix() helpers to the Zone class. Each
of these functions accepts a host prefix, complete name (unrooted
hostname), or FQDN (rooted hostname) associated with the Zone object and
returns the format implied by the function name.
Add .to_default_id() and .from_default_id() functions to the DNSDriver
class. These functions support the <type>[:<name>] (e.g. "A:www") record
ID format used by many of the drivers.
Previously, our NsOneDNSDriver.get_record() function performed lookups
using a `record_id` format that differed from the ID embedded within the
returned Record instance, so the driver leveraged two independent
record ID concepts simultaneously.

The NS1 API returns an ID when records are created, but that ID has no
local relevance. For example, it cannot be used to request the record
from the NS1 API.

Make the Record class .id value consistent between create_record() and
get_record(z.id, r.id).

	 |  zone_id |   z.id   |     r.id      |   record_id   |
---------|----------|----------|---------------|---------------|
previous | z.domain |  random* |    random*    |     r.type    |
    next | z.domain | z.domain | r.type:r.name | r.type:r.name |

* no meaning, effectively random
* Fix TTL in test_create_record_success() request
* Align record update with parent zone in test_update_record_success()
* Fix record_id in test_get_record_success() request
DNS AAAA records are associated with IPv6 addresses.
* Fix "ttle" typo in test_update_record()
Aaron Sierra added 25 commits April 3, 2025 15:04
The update_record() and delete_record() functions require a Record
instance in their respective argument lists to identify the DNS record
to manipulate. Record objects instantiated by this driver contain the
assocated "slot" ID within the .id field, so:

1. There is no need for the user to specify the "slot" ID via
   .update_record(..., extra={"entry": ID}). However, since it was
   previously required, an "entry" key will be accepted as long as it is
   consistent with the Record instance.
2. There is no need for .delete_record() to search the Record's zone for
   the "slot" ID of the Record.
The API key is automatically inserted into the request by the
ZonomiConnection class.
The MockHttp function was defined, but the corresponding test was not.
The v3 API became completely unsupported by Linode on July 31, 2023.

https://www.linode.com/community/questions/25142/status-of-v3-api-eol
The v1 API became completely unsupported by Vultr on August 14, 2023.

https://docs.vultr.com/vultr-api-v1-to-v2-transition-strategies
Previously, the Zonomi DNS driver could only return the first record
for a given host, because it used the name of the host as Record.id.

Now, use the new default, <type>[:<name>], format to allow various
records to be differentiated for a given host.
DNS drivers share the need to manipulate host/domain names, so let's add
utility functions to the common Record and Zone classes to allow
redundant code scattered throughout the various drivers to be
consolidated into common and consistent implementations.

  * Record.name - no longer driver-dependent, now the host prefix or ""
  * Record.hostname - the complete host name, including domain part
  * Record.fqdn - the fully qualified domain name, including root dot

  * Zone.domain - no longer driver-dependent, now the unrooted domain
  * Zone.rooted() - format a (un)rooted domain as a rooted domain
  * Zone.rooted() - format a (un)rooted domain as an unrooted domain
Update testing inputs to conform to spec'ed usage.
Leverage common code from DNSDriver, Record, and Zone classes for host
name and record ID handling.
Drop RackspaceDNSDriver._to_partial_record_name() and
RackspaceDNSDriver._to_full_record_name() in favor of the common
support provided by the Record and Zone classes.
@aaron-sierra
Copy link
Author

The latest changes have been through black, isort, lint, and pylint.

@aaron-sierra aaron-sierra marked this pull request as ready for review April 3, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant