diff --git a/nailgun/nailgun/policy/merge.py b/nailgun/nailgun/policy/merge.py index 64ebef16e9..92bb739723 100644 --- a/nailgun/nailgun/policy/merge.py +++ b/nailgun/nailgun/policy/merge.py @@ -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']]: diff --git a/nailgun/nailgun/test/unit/test_policies.py b/nailgun/nailgun/test/unit/test_policies.py index f8ef41866e..bd4a44d0fe 100644 --- a/nailgun/nailgun/test/unit/test_policies.py +++ b/nailgun/nailgun/test/unit/test_policies.py @@ -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(