From df13d53903ec55cbe1e1f573f2b401b26ea9eb43 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Fri, 2 Feb 2018 13:03:36 +0200 Subject: [PATCH] Enable router interface to have 'centralized' type This is required when we have a VLAN network that needs to be attached to a router Change-Id: I34ae08841158635e10ec4bd4518db4712ba4e984 --- vmware_nsxlib/v3/nsx_constants.py | 1 + vmware_nsxlib/v3/resources.py | 3 ++- vmware_nsxlib/v3/router.py | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/vmware_nsxlib/v3/nsx_constants.py b/vmware_nsxlib/v3/nsx_constants.py index 071c5257..0e3ddebf 100644 --- a/vmware_nsxlib/v3/nsx_constants.py +++ b/vmware_nsxlib/v3/nsx_constants.py @@ -42,6 +42,7 @@ ROUTER_TYPE_TIER1 = "TIER1" LROUTERPORT_UPLINK = "LogicalRouterUplinkPort" LROUTERPORT_DOWNLINK = "LogicalRouterDownLinkPort" +LROUTERPORT_CENTRALIZED = "LogicalRouterCentralizedServicePort" LROUTERPORT_LINKONTIER0 = "LogicalRouterLinkPortOnTIER0" LROUTERPORT_LINKONTIER1 = "LogicalRouterLinkPortOnTIER1" diff --git a/vmware_nsxlib/v3/resources.py b/vmware_nsxlib/v3/resources.py index bbffdda3..ec05ab22 100644 --- a/vmware_nsxlib/v3/resources.py +++ b/vmware_nsxlib/v3/resources.py @@ -249,7 +249,8 @@ class LogicalRouterPort(utils.NsxLibApiBase): if address_groups: body['subnets'] = address_groups if resource_type in [nsx_constants.LROUTERPORT_UPLINK, - nsx_constants.LROUTERPORT_DOWNLINK]: + nsx_constants.LROUTERPORT_DOWNLINK, + nsx_constants.LROUTERPORT_CENTRALIZED]: body['linked_logical_switch_port_id'] = { 'target_id': logical_port_id} elif resource_type == nsx_constants.LROUTERPORT_LINKONTIER1: diff --git a/vmware_nsxlib/v3/router.py b/vmware_nsxlib/v3/router.py index 852e4d7f..ae0a7448 100644 --- a/vmware_nsxlib/v3/router.py +++ b/vmware_nsxlib/v3/router.py @@ -172,15 +172,18 @@ class RouterLib(object): logical_switch_port_id, address_groups, urpf_mode=None, - relay_service_uuid=None): + relay_service_uuid=None, + resource_type=None): try: port = self._router_port_client.get_by_lswitch_id(ls_id) except exceptions.ResourceNotFound: + if resource_type is None: + resource_type = nsx_constants.LROUTERPORT_DOWNLINK return self._router_port_client.create( logical_router_id, display_name, tags, - nsx_constants.LROUTERPORT_DOWNLINK, + resource_type, logical_switch_port_id, address_groups, urpf_mode=urpf_mode,