diff --git a/vmware_nsxlib/tests/unit/v3/test_constants.py b/vmware_nsxlib/tests/unit/v3/test_constants.py index 337d89d1..049a112c 100644 --- a/vmware_nsxlib/tests/unit/v3/test_constants.py +++ b/vmware_nsxlib/tests/unit/v3/test_constants.py @@ -579,6 +579,7 @@ FAKE_TIERO_ROUTER = { "target_id": "c3d80576-e340-403d-a2d0-f4a72a1db6e3" }], "advanced_config": { + "transport_zone_id": FAKE_TZ_UUID, "external_transit_networks": ["100.64.0.0/16"], "internal_transit_network": "169.254.0.0/28" }, diff --git a/vmware_nsxlib/tests/unit/v3/test_router.py b/vmware_nsxlib/tests/unit/v3/test_router.py index 2fbd8372..238e6784 100644 --- a/vmware_nsxlib/tests/unit/v3/test_router.py +++ b/vmware_nsxlib/tests/unit/v3/test_router.py @@ -161,6 +161,13 @@ class TestRouter(nsxlib_testcase.NsxClientTestCase): tz = self.nsxlib.router.get_tier0_router_overlay_tz(tier0_uuid) self.assertEqual(tz, test_constants.FAKE_TZ_UUID) + def test_get_tier0_router_overlay_tz_via_advanced_config(self): + tier0_uuid = uuidutils.generate_uuid() + with mock.patch.object(self.nsxlib.router._router_client, 'get', + return_value=test_constants.FAKE_TIERO_ROUTER): + tz = self.nsxlib.router.get_tier0_router_overlay_tz(tier0_uuid) + self.assertEqual(tz, test_constants.FAKE_TZ_UUID) + def test_get_connected_t0_transit_net(self): t1_uuid = uuidutils.generate_uuid() transit_net = '1.1.1.0' diff --git a/vmware_nsxlib/v3/router.py b/vmware_nsxlib/v3/router.py index 08a12c8a..a5fc7b2e 100644 --- a/vmware_nsxlib/v3/router.py +++ b/vmware_nsxlib/v3/router.py @@ -293,6 +293,10 @@ class RouterLib(object): return tier0_tzs def get_tier0_router_overlay_tz(self, tier0_uuid): + lrouter = self._router_client.get(tier0_uuid) + tz_uuid = lrouter.get('advanced_config', {}).get('transport_zone_id') + if tz_uuid: + return tz_uuid tz_uuids = self.get_tier0_router_tz(tier0_uuid) for tz_uuid in tz_uuids: # look for the overlay tz