Merge "Fix pool update with duplicate masters" into stable/victoria
This commit is contained in:
commit
7cbbd3a18f
|
@ -51,8 +51,13 @@ class PoolCommands(base.Commands):
|
||||||
masters = []
|
masters = []
|
||||||
for target in pool.targets:
|
for target in pool.targets:
|
||||||
for master in target.get("masters", []):
|
for master in target.get("masters", []):
|
||||||
masters.append({'host': master['host'],
|
master = {'host': master['host'], 'port': master['port']}
|
||||||
'port': master['port']})
|
found = False
|
||||||
|
for existing_master in masters:
|
||||||
|
if master == existing_master:
|
||||||
|
found = True
|
||||||
|
if not found:
|
||||||
|
masters.append(master)
|
||||||
return masters
|
return masters
|
||||||
|
|
||||||
policy.init()
|
policy.init()
|
||||||
|
|
|
@ -26,11 +26,11 @@ class UpdatePoolTestCase(DesignateManageTestCase):
|
||||||
self.stdlog = fixtures.StandardLogging()
|
self.stdlog = fixtures.StandardLogging()
|
||||||
self.useFixture(self.stdlog)
|
self.useFixture(self.stdlog)
|
||||||
|
|
||||||
def hydrate_pool_targets(self, targets):
|
def hydrate_pool_targets(self, target_masters):
|
||||||
pool_targets = objects.PoolTargetList()
|
pool_targets = objects.PoolTargetList()
|
||||||
masters = objects.PoolTargetMasterList()
|
masters = objects.PoolTargetMasterList()
|
||||||
for target in targets:
|
for target_master in target_masters:
|
||||||
masters.append(target)
|
masters.append(target_master)
|
||||||
target = objects.PoolTarget(masters=masters)
|
target = objects.PoolTarget(masters=masters)
|
||||||
target.masters = masters
|
target.masters = masters
|
||||||
pool_targets.append(target)
|
pool_targets.append(target)
|
||||||
|
@ -63,3 +63,38 @@ class UpdatePoolTestCase(DesignateManageTestCase):
|
||||||
"update_zone") as mock_update_zone:
|
"update_zone") as mock_update_zone:
|
||||||
command._update_zones(pool)
|
command._update_zones(pool)
|
||||||
mock_update_zone.assert_called_once()
|
mock_update_zone.assert_called_once()
|
||||||
|
|
||||||
|
def test_update_pools_zones_multiple_masters(self):
|
||||||
|
values = dict(
|
||||||
|
name='example.com.',
|
||||||
|
email='info@example.com',
|
||||||
|
type='PRIMARY'
|
||||||
|
)
|
||||||
|
|
||||||
|
zone = self.central_service.create_zone(
|
||||||
|
self.admin_context, zone=objects.Zone.from_dict(values))
|
||||||
|
|
||||||
|
# Ensure the correct NS Records are in place
|
||||||
|
pool = self.central_service.get_pool(
|
||||||
|
self.admin_context, zone.pool_id)
|
||||||
|
|
||||||
|
targets1 = self.hydrate_pool_targets([
|
||||||
|
objects.PoolTargetMaster(
|
||||||
|
pool_target_id=pool.id,
|
||||||
|
host="127.0.0.1",
|
||||||
|
port="53")
|
||||||
|
])
|
||||||
|
targets2 = self.hydrate_pool_targets([
|
||||||
|
objects.PoolTargetMaster(
|
||||||
|
pool_target_id=pool.id,
|
||||||
|
host="127.0.0.1",
|
||||||
|
port="53")
|
||||||
|
])
|
||||||
|
pool.targets = objects.PoolTargetList()
|
||||||
|
pool.targets.extend(targets1.objects + targets2.objects)
|
||||||
|
|
||||||
|
command = PoolCommands()
|
||||||
|
command.context = self.admin_context
|
||||||
|
command.central_api = self.central_service
|
||||||
|
|
||||||
|
command._update_zones(pool)
|
||||||
|
|
Loading…
Reference in New Issue