Add return value to add_router_link_port method

Add return value to add_router_link_port method then an API call could
be saved if client code needs the ports.

Change-Id: I5cc2f33be75888e014fda9aad3f4e0c80674ea27
This commit is contained in:
Quan Tian 2019-01-24 23:18:42 -08:00 committed by Adit Sarfaty
parent fb84d8721f
commit 837e15ed22
2 changed files with 9 additions and 3 deletions

View File

@ -63,8 +63,13 @@ class TestRouter(nsxlib_testcase.NsxClientTestCase):
tier1_uuid = uuidutils.generate_uuid()
with mock.patch.object(self.nsxlib.router._router_port_client,
'create') as port_create:
self.nsxlib.router.add_router_link_port(
tier1_uuid, tier0_uuid, tags)
tier0_link_port = mock.MagicMock()
tier1_link_port = mock.MagicMock()
port_create.side_effect = [tier0_link_port, tier1_link_port]
self.assertEqual(
(tier0_link_port, tier1_link_port),
self.nsxlib.router.add_router_link_port(
tier1_uuid, tier0_uuid, tags))
self.assertEqual(port_create.call_count, 2)
def test_remove_router_link_port(self):

View File

@ -90,11 +90,12 @@ class RouterLib(object):
# Create Tier1 logical router link port
t1_tags = copy.copy(tags)
t1_tags = utils.add_v3_tag(t1_tags, 'os-tier1-uuid', tier1_uuid)
self._router_port_client.create(
tier1_link_port = self._router_port_client.create(
tier1_uuid, display_name=TIER1_ROUTER_LINK_PORT_NAME, tags=t1_tags,
resource_type=nsx_constants.LROUTERPORT_LINKONTIER1,
logical_port_id=linked_logical_port_id,
address_groups=None)
return tier0_link_port, tier1_link_port
def remove_router_link_port(self, tier1_uuid, tier0_uuid=None):
# Note(asarfaty): tier0_uuid is not used by this method and can