Skip to content

Commit 9eb21bf

Browse files
author
Aaron Sierra
committed
dns: gandi_live: Leverage {to,from}_default_id()
1 parent cbd8d98 commit 9eb21bf

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

libcloud/dns/drivers/gandi_live.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,16 @@ def list_records(self, zone):
146146
"""
147147

148148
def get_record(self, zone_id, record_id):
149-
record_type, name = record_id.split(":", 1)
150-
action = "{}/domains/{}/records/{}/{}".format(API_BASE, zone_id, name, record_type)
149+
zone = self.get_zone(zone_id)
150+
rparts = self.from_default_id(zone, record_id)
151+
action = "{}/domains/{}/records/{}/{}".format(API_BASE, zone_id, rparts.name, rparts.type)
151152
try:
152153
record = self.connection.request(action=action, method="GET")
153154
except ResourceNotFoundError:
154155
raise RecordDoesNotExistError(
155156
value="", driver=self.connection.driver, record_id=record_id
156157
)
157-
return self._to_record(record.object, self.get_zone(zone_id))[0]
158+
return self._to_record(record.object, zone)[0]
158159

159160
def create_record(self, name, zone, type, data, extra=None):
160161
self._validate_record(None, name, type, data, extra)
@@ -420,7 +421,7 @@ def _to_record_sub(self, data, zone, value):
420421
priority, value = value.split()
421422
extra["priority"] = priority
422423
return Record(
423-
id="{}:{}".format(data["rrset_type"], data["rrset_name"]),
424+
id=self.to_default_id(zone, data["rrset_name"], data["rrset_type"]),
424425
name=data["rrset_name"],
425426
type=self._string_to_record_type(data["rrset_type"]),
426427
data=value,

libcloud/test/dns/test_gandi_live.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ def test_list_records(self):
169169
def test_get_record(self):
170170
record = self.driver.get_record(self.test_zone.id, "A:bob")
171171

172-
# [0] /api/v5/domains/example.com/records/bob/A
173-
# [1] /api/v5/domains/example.com
174-
sent = GandiLiveMockHttp.history.pop(0)
172+
sent = GandiLiveMockHttp.history.pop()
175173
self.assertEqual(sent.method, "GET")
176174
self.assertEqual(sent.url, "/api/v5/domains/example.com/records/bob/A")
177175

0 commit comments

Comments
 (0)