Skip to content

Commit 2330fa7

Browse files
author
Aaron Sierra
committed
dns: worldwidedns: Leverage "slot" ID from Record.id
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.
1 parent 7a420e1 commit 2330fa7

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

libcloud/dns/drivers/worldwidedns.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,15 @@ def update_record(self, record, name, type, data, extra=None):
262262
:param data: Data for the record (depends on the record type).
263263
:type data: ``str``
264264
265-
:param extra: Contains 'entry' Entry position (1 thru 40)
265+
:param extra: Extra attributes (driver specific). (optional).
266266
:type extra: ``dict``
267267
268268
:rtype: :class:`Record`
269269
"""
270270

271-
if (extra is None) or ("entry" not in extra):
272-
raise WorldWideDNSError(value="You must enter 'entry' parameter", driver=self)
273-
record_id = extra.get("entry")
271+
record_id = record.id
272+
if "entry" in extra and str(extra["entry"]) != record_id:
273+
raise WorldWideDNSError(value="Inconsistent 'entry' parameter", driver=self)
274274

275275
if name == "":
276276
name = "@"
@@ -437,13 +437,7 @@ def delete_record(self, record):
437437
:rtype: ``bool``
438438
"""
439439
zone = record.zone
440-
441-
for index in range(MAX_RECORD_ENTRIES):
442-
if record.name == zone.extra["S%s" % (index + 1)]:
443-
entry = index + 1
444-
445-
break
446-
extra = {"S%s" % entry: "", "T%s" % entry: "NONE", "D%s" % entry: ""}
440+
extra = {"S%s" % record.id: "", "T%s" % record.id: "NONE", "D%s" % record.id: ""}
447441
self.update_zone(zone, zone.domain, extra=extra)
448442

449443
return True

0 commit comments

Comments
 (0)