Browse Source

Add api to get all MP tier0 uplink ports

Change-Id: I11b96d2be8fd8e0f240fceb42dc01e4769d51a36
changes/16/747816/1
asarfaty 2 years ago
parent
commit
d4c1f06339
  1. 7
      vmware_nsxlib/tests/unit/v3/test_resources.py
  2. 11
      vmware_nsxlib/v3/resources.py

7
vmware_nsxlib/tests/unit/v3/test_resources.py

@ -1499,6 +1499,13 @@ class LogicalRouterPortTestCase(BaseTestResource):
result = lrport.get_tier1_link_port(router_id)
self.assertEqual(test_constants.FAKE_ROUTER_LINKT1_PORT, result)
def test_get_tier0_uplink_ports(self):
router_id = test_constants.FAKE_ROUTER_PORT['logical_router_id']
lrport = self.get_mocked_resource(response={'results': [
test_constants.FAKE_ROUTER_PORT]})
result = lrport.get_tier0_uplink_ports(router_id)
self.assertEqual([test_constants.FAKE_ROUTER_PORT], result)
def test_get_tier0_uplink_port(self):
"""Test getting a Tier0 router uplink port by router id."""
router_id = test_constants.FAKE_ROUTER_PORT['logical_router_id']

11
vmware_nsxlib/v3/resources.py

@ -370,11 +370,18 @@ class LogicalRouterPort(utils.NsxLibApiBase):
manager=self.client.nsx_api_managers,
operation="get router link port")
def get_tier0_uplink_port(self, logical_router_id):
def get_tier0_uplink_ports(self, logical_router_id):
logical_router_ports = self.get_by_router_id(logical_router_id)
ports = []
for port in logical_router_ports:
if port['resource_type'] == nsx_constants.LROUTERPORT_UPLINK:
return port
ports.append(port)
return ports
def get_tier0_uplink_port(self, logical_router_id):
ports = self.get_tier0_uplink_ports(logical_router_id)
if ports:
return ports[0]
def get_tier0_uplink_subnets(self, logical_router_id):
port = self.get_tier0_uplink_port(logical_router_id)

Loading…
Cancel
Save