From 1bf074cab8df421c65545215624c0a8c4e8b7b8e Mon Sep 17 00:00:00 2001 From: Danting Liu Date: Thu, 22 Apr 2021 03:13:34 -0700 Subject: [PATCH] Add wait_until_realized for Tier1 Static Route Change-Id: I26cff5ee6e7942c92d1670440aa7c039c39a2425 (cherry picked from commit 378e4eac708517d9f72a4c5ffb4beb1a0979500c) --- vmware_nsxlib/tests/unit/v3/policy/test_resources.py | 10 ++++++++++ vmware_nsxlib/v3/policy/core_resources.py | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py index 43e7dc5a..acbada0d 100644 --- a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py @@ -4117,6 +4117,16 @@ class TestPolicyTier1StaticRoute(NsxPolicyLibTestCase): self.assert_called_with_def(api_call, expected_def) self.assertEqual(mock_get, result) + def test_wait_until_realized_failed(self): + tier1_id = 'tier1' + route_id = 'route1' + with mock.patch.object(self.resourceApi, "_get_realization_info", + return_value=[]): + self.assertRaises(nsxlib_exc.RealizationTimeoutError, + self.resourceApi.wait_until_realized, + tier1_id, route_id, tenant=TEST_TENANT, + max_attempts=3, sleep=0.1) + class TestPolicyTier0(NsxPolicyLibTestCase): diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index 37f44672..3d35bc74 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -2045,6 +2045,18 @@ class NsxPolicyTier1StaticRouteApi(NsxPolicyResourceBase): tags=tags, tenant=tenant) + def wait_until_realized(self, tier1_id, static_route_id, + entity_type=None, + tenant=constants.POLICY_INFRA_TENANT, + sleep=None, max_attempts=None): + static_route_def = self.entry_def(tier1_id=tier1_id, + static_route_id=static_route_id, + tenant=tenant) + return self._wait_until_realized(static_route_def, + entity_type=entity_type, + sleep=sleep, + max_attempts=max_attempts) + class NsxPolicyTier1SegmentApi(NsxPolicyResourceBase): """NSX Tier1 Segment API """