Browse Source

Add api to get all MP tier0 uplink ports

Change-Id: I11b96d2be8fd8e0f240fceb42dc01e4769d51a36
changes/43/747843/1
asarfaty 1 month ago
committed by Adit Sarfaty
parent
commit
fbe1cac583
2 changed files with 16 additions and 2 deletions
  1. +7
    -0
      vmware_nsxlib/tests/unit/v3/test_resources.py
  2. +9
    -2
      vmware_nsxlib/v3/resources.py

+ 7
- 0
vmware_nsxlib/tests/unit/v3/test_resources.py View File

@@ -1430,6 +1430,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']


+ 9
- 2
vmware_nsxlib/v3/resources.py View File

@@ -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