From 0d543d9b78085b91c6bde38b82f4330ac27a3184 Mon Sep 17 00:00:00 2001 From: Viranch Mehta Date: Mon, 27 Sep 2021 22:24:13 -0700 Subject: [PATCH] compare endpoint_status in Azure profiles --- octodns/provider/azuredns.py | 5 ++++- tests/test_octodns_provider_azuredns.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/octodns/provider/azuredns.py b/octodns/provider/azuredns.py index f590776..aff7a25 100644 --- a/octodns/provider/azuredns.py +++ b/octodns/provider/azuredns.py @@ -375,8 +375,11 @@ def _profile_is_match(have, desired): desired_endpoints = desired.endpoints endpoints = zip(have_endpoints, desired_endpoints) for have_endpoint, desired_endpoint in endpoints: + have_status = have_endpoint.endpoint_status or 'Enabled' + desired_status = desired_endpoint.endpoint_status or 'Enabled' if have_endpoint.name != desired_endpoint.name or \ - have_endpoint.type != desired_endpoint.type: + have_endpoint.type != desired_endpoint.type or \ + have_status != desired_status: return false(have_endpoint, desired_endpoint, have.name) target_type = have_endpoint.type.split('/')[-1] if target_type == 'externalEndpoints': diff --git a/tests/test_octodns_provider_azuredns.py b/tests/test_octodns_provider_azuredns.py index b531ad2..708b229 100644 --- a/tests/test_octodns_provider_azuredns.py +++ b/tests/test_octodns_provider_azuredns.py @@ -473,6 +473,7 @@ class Test_ProfileIsMatch(TestCase): endpoints = 1, endpoint_name = 'name', endpoint_type = 'profile/nestedEndpoints', + endpoint_status = None, target = 'target.unit.tests', target_id = 'resource/id', geos = ['GEO-AF'], @@ -490,6 +491,7 @@ class Test_ProfileIsMatch(TestCase): endpoints=[Endpoint( name=endpoint_name, type=endpoint_type, + endpoint_status=endpoint_status, target=target, target_resource_id=target_id, geo_mapping=geos, @@ -506,6 +508,9 @@ class Test_ProfileIsMatch(TestCase): self.assertFalse(is_match(profile(), profile(monitor_proto='HTTP'))) self.assertFalse(is_match(profile(), profile(endpoint_name='a'))) self.assertFalse(is_match(profile(), profile(endpoint_type='b'))) + self.assertFalse( + is_match(profile(), profile(endpoint_status='Disabled')) + ) self.assertFalse( is_match(profile(endpoint_type='b'), profile(endpoint_type='b')) ) @@ -1760,7 +1765,7 @@ class TestAzureDnsProvider(TestCase): self.assertEqual(profiles[0].endpoints[0].endpoint_status, 'Disabled') self.assertEqual(profiles[1].endpoints[0].endpoint_status, 'Disabled') - # # test that same record gets populated back from traffic managers + # test that same record gets populated back from traffic managers tm_list = provider._tm_client.profiles.list_by_resource_group tm_list.return_value = profiles azrecord = RecordSet( @@ -1772,7 +1777,8 @@ class TestAzureDnsProvider(TestCase): record2 = provider._populate_record(zone, azrecord) self.assertEqual(record1.dynamic._data(), record2.dynamic._data()) - # _process_desired_zone shouldn't change anything when not needed + # _process_desired_zone shouldn't change anything when status value is + # supported zone1 = Zone(zone.name, sub_zones=[]) zone1.add_record(record1) zone2 = provider._process_desired_zone(zone1.copy())