From f84aeaeefe8bad73fcbc718b06c0c63357856fac Mon Sep 17 00:00:00 2001 From: Dmitry Galkin Date: Wed, 21 Feb 2018 17:06:50 +0000 Subject: [PATCH] Keep NS records for subdomains during Zone import. Change-Id: I07829822b8a50b0bff0b28370d9d6d3faacd445c Closes-Bug: 1747016 --- designate/central/service.py | 5 ++++- designate/tests/test_api/test_v2/test_import_export.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/designate/central/service.py b/designate/central/service.py index 96d7c44a9..e22ab9664 100644 --- a/designate/central/service.py +++ b/designate/central/service.py @@ -2674,7 +2674,10 @@ class Service(service.RPCService, service.Service): zone.type = 'PRIMARY' for rrset in list(zone.recordsets): - if rrset.type in ('NS', 'SOA'): + if rrset.type == 'SOA': + zone.recordsets.remove(rrset) + # subdomain NS records should be kept + elif rrset.type == 'NS' and rrset.name == zone.name: zone.recordsets.remove(rrset) except dnszone.UnknownOrigin: diff --git a/designate/tests/test_api/test_v2/test_import_export.py b/designate/tests/test_api/test_v2/test_import_export.py index 40f4e977f..203e6a9a0 100644 --- a/designate/tests/test_api/test_v2/test_import_export.py +++ b/designate/tests/test_api/test_v2/test_import_export.py @@ -130,10 +130,9 @@ class APIV2ZoneImportExportTest(ApiV2TestCase): # and dnspython considers that to be not equal. imported.delete_rdataset(imported.origin, 'SOA') exported.delete_rdataset(exported.origin, 'SOA') - # Delete NS records, since they won't be the same + # Delete NS records, except for delegated subdomains imported.delete_rdataset(imported.origin, 'NS') exported.delete_rdataset(exported.origin, 'NS') - imported.delete_rdataset('delegation', 'NS') self.assertEqual(imported, exported) # Metadata tests