Merge "Allow to clean VIPs from plugins" into stable/8.0

This commit is contained in:
Jenkins 2016-02-02 14:17:15 +00:00 committed by Gerrit Code Review
commit c363c742bf
2 changed files with 18 additions and 0 deletions

View File

@ -51,6 +51,14 @@ class NetworkRoleMergePolicy(MergePolicy):
:return: the patched VIPs
"""
seen = dict((vip['name'], vip) for vip in target)
# This is a workaround for 8.0 release to allow
# moving controllers to different racks. Will be
# replaced by a different solution in 9.0
if len(patch) == 0:
return []
# END OF WORKAROUND
for vip in patch:
if vip['name'] in seen:
if vip != seen[vip['name']]:

View File

@ -66,6 +66,16 @@ class TestNetworkRoleMergePolicy(BaseUnitTest):
target['properties']['vip']
)
def test_apply_patch_vips_reset(self):
target = self._make_plugin_network_role(
vip=[{'name': 'test_vip_a'}, {'name': 'test_vip_b'}]
)
patch = self._make_plugin_network_role(vip=[])
self.policy.apply_patch(target, patch)
self.assertItemsEqual([], target['properties']['vip'])
def test_apply_patch_fail_if_conflict(self):
with self.assertRaisesRegexp(errors.UnresolvableConflict, 'subnet'):
self.policy.apply_patch(