@@ -231,7 +231,15 @@ def zones(self):
231
231
else :
232
232
page = None
233
233
234
- self ._zones = IdnaDict ({f'{ z ["name" ]} .' : z ['id' ] for z in zones })
234
+ self ._zones = IdnaDict (
235
+ {
236
+ f'{ z ["name" ]} .' : {
237
+ 'id' : z ['id' ],
238
+ 'name_servers' : z ['name_servers' ],
239
+ }
240
+ for z in zones
241
+ }
242
+ )
235
243
236
244
return self ._zones
237
245
@@ -485,7 +493,7 @@ def _data_for_SSHFP(self, _type, records):
485
493
486
494
def zone_records (self , zone ):
487
495
if zone .name not in self ._zone_records :
488
- zone_id = self .zones .get (zone .name , False )
496
+ zone_id = self .zones .get (zone .name , {}). get ( 'id' , False )
489
497
if not zone_id :
490
498
return []
491
499
@@ -1033,7 +1041,7 @@ def _gen_key(self, data):
1033
1041
1034
1042
def _apply_Create (self , change ):
1035
1043
new = change .new
1036
- zone_id = self .zones [new .zone .name ]
1044
+ zone_id = self .zones [new .zone .name ][ 'id' ]
1037
1045
if new ._type == 'URLFWD' :
1038
1046
path = f'/zones/{ zone_id } /pagerules'
1039
1047
else :
@@ -1043,7 +1051,7 @@ def _apply_Create(self, change):
1043
1051
1044
1052
def _apply_Update (self , change ):
1045
1053
zone = change .new .zone
1046
- zone_id = self .zones [zone .name ]
1054
+ zone_id = self .zones [zone .name ][ 'id' ]
1047
1055
hostname = zone .hostname_from_fqdn (change .new .fqdn [:- 1 ])
1048
1056
_type = change .new ._type
1049
1057
@@ -1176,7 +1184,7 @@ def _apply_Delete(self, change):
1176
1184
existing_name = existing .fqdn [:- 1 ]
1177
1185
# Make sure to map ALIAS to CNAME when looking for the target to delete
1178
1186
existing_type = 'CNAME' if existing ._type == 'ALIAS' else existing ._type
1179
- zone_id = self .zones [ existing .zone .name ]
1187
+ zone_id = self .zones . get ( existing .zone .name , {}). get ( 'id' , False )
1180
1188
for record in self .zone_records (existing .zone ):
1181
1189
if 'targets' in record and self .pagerules :
1182
1190
uri = record ['targets' ][0 ]['constraint' ]['value' ]
@@ -1224,9 +1232,17 @@ def _apply(self, plan):
1224
1232
data ['account' ] = {'id' : self .account_id }
1225
1233
resp = self ._try_request ('POST' , '/zones' , data = data )
1226
1234
zone_id = resp ['result' ]['id' ]
1227
- self .zones [name ] = zone_id
1235
+ name_servers = resp ['result' ]['name_servers' ]
1236
+ self .zones [name ] = {'id' : zone_id , 'name_servers' : name_servers }
1228
1237
self ._zone_records [name ] = {}
1229
1238
1239
+ self .log .info (
1240
+ 'zone %s (id %s) name servers: %s' ,
1241
+ name ,
1242
+ self .zones [name ]['id' ],
1243
+ self .zones [name ]['name_servers' ],
1244
+ )
1245
+
1230
1246
# Force the operation order to be Delete() -> Create() -> Update()
1231
1247
# This will help avoid problems in updating a CNAME record into an
1232
1248
# A record and vice-versa
0 commit comments