From 8e32198792e5925d145808e7bd620b04006a1903 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Mon, 27 May 2019 08:08:01 +0300 Subject: [PATCH] Support updating Policy tier1 route adv together with tier0 connectivity Change-Id: I39c79316d25a18940a77dd4fc53032a25d345024 --- .../tests/unit/v3/policy/test_resources.py | 33 +++++++++++++++++++ vmware_nsxlib/v3/policy/core_resources.py | 2 ++ 2 files changed, 35 insertions(+) diff --git a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py index c5ba106b..3564641d 100644 --- a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py @@ -2558,6 +2558,39 @@ class TestPolicyTier1(NsxPolicyLibTestCase): self.assert_called_with_def( update_call, expected_def) + def test_update_route_advand_tier0(self): + obj_id = '111' + rtr_name = 'rtr111' + tier0 = 'tier0-id' + get_result = {'id': obj_id, + 'display_name': rtr_name, + 'route_advertisement_types': ['TIER1_NAT', + 'TIER1_LB_VIP']} + with mock.patch.object(self.policy_api, "get", + return_value=get_result),\ + mock.patch.object(self.policy_api, + "create_or_update") as update_call: + self.resourceApi.update_route_advertisement( + obj_id, + static_routes=True, + lb_vip=False, + lb_snat=True, + tier0=tier0, + tenant=TEST_TENANT) + + new_adv = self.resourceApi.build_route_advertisement( + nat=True, static_routes=True, lb_snat=True) + + expected_def = core_defs.Tier1Def( + tier1_id=obj_id, + name=rtr_name, + route_advertisement=new_adv, + tier0=tier0, + tenant=TEST_TENANT) + + self.assert_called_with_def( + update_call, expected_def) + def test_set_enable_standby_relocation(self): obj_id = '111' name = 'new name' diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index 7001d4b9..5ce8d256 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -947,6 +947,7 @@ class NsxPolicyTier1Api(NsxPolicyResourceBase): nat=None, lb_vip=None, lb_snat=None, + tier0=IGNORE, tenant=constants.POLICY_INFRA_TENANT): tier1_dict = self.get(tier1_id, tenant) @@ -959,6 +960,7 @@ class NsxPolicyTier1Api(NsxPolicyResourceBase): self.update(tier1_id, route_advertisement=route_adv, + tier0=tier0, tenant=tenant, current_body=tier1_dict)