mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Remove defunct geo -> dynamic case that couldn't be reached
This commit is contained in:
@@ -1258,31 +1258,33 @@ class DynProvider(BaseProvider):
|
|||||||
if new.geo:
|
if new.geo:
|
||||||
# New record is a geo record
|
# New record is a geo record
|
||||||
self.log.info('_mod_dynamic_Update: %s to geo', new.fqdn)
|
self.log.info('_mod_dynamic_Update: %s to geo', new.fqdn)
|
||||||
# Convert the TD over to a geo
|
# Convert the TD over to a geo and we're done
|
||||||
self._mod_geo_Update(dyn_zone, change)
|
self._mod_geo_Update(dyn_zone, change)
|
||||||
else:
|
else:
|
||||||
# New record doesn't have dynamic, we're going from a TD to a
|
# New record doesn't have dynamic, we're going from a TD to a
|
||||||
# regular record
|
# regular record
|
||||||
self.log.info('_mod_dynamic_Update: %s to plain', new.fqdn)
|
self.log.info('_mod_dynamic_Update: %s to plain', new.fqdn)
|
||||||
|
# Create the regular record
|
||||||
self._mod_Create(dyn_zone, change)
|
self._mod_Create(dyn_zone, change)
|
||||||
|
# Delete the dynamic
|
||||||
self._mod_dynamic_Delete(dyn_zone, change)
|
self._mod_dynamic_Delete(dyn_zone, change)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
# We'll be dynamic going forward, see if we have one already
|
||||||
td = self.traffic_directors[new.fqdn][new._type]
|
td = self.traffic_directors[new.fqdn][new._type]
|
||||||
self.log.debug('_mod_dynamic_Update: %s existing', new.fqdn)
|
if change.existing.geo:
|
||||||
|
self.log.info('_mod_dynamic_Update: %s from geo', new.fqdn)
|
||||||
|
else:
|
||||||
|
self.log.debug('_mod_dynamic_Update: %s existing', new.fqdn)
|
||||||
|
# If we're here we do, we'll just update it down below
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# There's no td, this is actually a create, we must be going from a
|
# There's no td, this is actually a create, we must be going from a
|
||||||
# non-dynamic to dynamic record
|
# non-dynamic to dynamic record
|
||||||
# First create the dynamic record
|
# First create the dynamic record
|
||||||
|
self.log.info('_mod_dynamic_Update: %s from regular', new.fqdn)
|
||||||
self._mod_dynamic_Create(dyn_zone, change)
|
self._mod_dynamic_Create(dyn_zone, change)
|
||||||
if change.existing.geo:
|
# From a generic so remove the old generic
|
||||||
# From a geo, so remove the old geo
|
self._mod_Delete(dyn_zone, change)
|
||||||
self.log.info('_mod_dynamic_Update: %s from geo', new.fqdn)
|
|
||||||
self._mod_geo_Delete(dyn_zone, change)
|
|
||||||
else:
|
|
||||||
# From a generic so remove the old generic
|
|
||||||
self.log.info('_mod_dynamic_Update: %s from plain', new.fqdn)
|
|
||||||
self._mod_Delete(dyn_zone, change)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# IF we're here it's actually an update, sync up rules
|
# IF we're here it's actually an update, sync up rules
|
||||||
|
|||||||
@@ -2411,8 +2411,8 @@ class TestDynProviderDynamic(TestCase):
|
|||||||
# mock _mod_dynamic_rulesets
|
# mock _mod_dynamic_rulesets
|
||||||
provider._mod_dynamic_rulesets = MagicMock()
|
provider._mod_dynamic_rulesets = MagicMock()
|
||||||
|
|
||||||
geo = self.dynamic_a_record
|
dyn = self.dynamic_a_record
|
||||||
change = Update(geo, geo)
|
change = Update(dyn, dyn)
|
||||||
provider._mod_dynamic_Update(None, change)
|
provider._mod_dynamic_Update(None, change)
|
||||||
# still in cache
|
# still in cache
|
||||||
self.assertTrue('A' in provider.traffic_directors['unit.tests.'])
|
self.assertTrue('A' in provider.traffic_directors['unit.tests.'])
|
||||||
@@ -2457,15 +2457,21 @@ class TestDynProviderDynamic(TestCase):
|
|||||||
|
|
||||||
# convert a geo record to a dynamic td
|
# convert a geo record to a dynamic td
|
||||||
|
|
||||||
provider._mod_dynamic_Create = MagicMock()
|
# pre-populate the cache with our mock td
|
||||||
provider._mod_geo_Delete = MagicMock()
|
provider._traffic_directors = {
|
||||||
|
'unit.tests.': {
|
||||||
|
'A': 42,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# mock _mod_dynamic_rulesets
|
||||||
|
provider._mod_dynamic_rulesets = MagicMock()
|
||||||
|
|
||||||
change = Update(self.geo_a_record, self.dynamic_a_record)
|
change = Update(self.geo_a_record, self.dynamic_a_record)
|
||||||
provider._mod_dynamic_Update(42, change)
|
provider._mod_dynamic_Update(None, change)
|
||||||
# should have seen a call to create the new geo record
|
# still in cache
|
||||||
provider._mod_dynamic_Create.assert_called_once_with(42, change)
|
self.assertTrue('A' in provider.traffic_directors['unit.tests.'])
|
||||||
# should have seen a call to delete the old geo record
|
# should have seen 1 gen call
|
||||||
provider._mod_geo_Delete.assert_called_once_with(42, change)
|
provider._mod_dynamic_rulesets.assert_called_once_with(42, change)
|
||||||
|
|
||||||
@patch('dyn.core.SessionEngine.execute')
|
@patch('dyn.core.SessionEngine.execute')
|
||||||
def test_mod_dynamic_update_regular_dynamic(self, _):
|
def test_mod_dynamic_update_regular_dynamic(self, _):
|
||||||
|
|||||||
Reference in New Issue
Block a user