From db300459a5074bf6efd2d1ff4c3a85e87f1c01cb Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Tue, 12 Jan 2016 12:41:42 +0200 Subject: [PATCH] Truncate edge appliance name when too long This patch addresses an issue when a user sets a very long name to an exclusive or distributed routers. Currently we set the edge appliance name to - and this may exceed the maximum length which is allowed by NSXv. Change-Id: I9db4b5420227fe9cb4356743de86792e0440b575 --- vmware_nsx/common/nsxv_constants.py | 3 +++ vmware_nsx/plugins/nsx_v/vshield/edge_utils.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/vmware_nsx/common/nsxv_constants.py b/vmware_nsx/common/nsxv_constants.py index 1975893e37..59f329adfa 100644 --- a/vmware_nsx/common/nsxv_constants.py +++ b/vmware_nsx/common/nsxv_constants.py @@ -36,6 +36,9 @@ INTERNAL_TENANT_ID = 'a1b2c3d4-e5f6-eeff-ffee-6f5e4d3c2b1a' # L2 gateway edge name prefix L2_GATEWAY_EDGE = 'L2 bridging' +# An artificial limit for router name length - subtract 1 for the - separator +ROUTER_NAME_LENGTH = (78 - 1) + # LoadBalancer Certificate constants #NOTE(abhiraut): Number of days specify the total number of days for which the # the certificate will be active. This certificate will expire diff --git a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py index dd53f510e2..97e40bb6df 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py +++ b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py @@ -645,7 +645,10 @@ class EdgeManager(object): self, context, lrouter, lswitch=None, dist=False, appliance_size=vcns_const.SERVICE_SIZE_MAPPING['router']): """Create an edge for logical router support.""" - router_name = lrouter['name'] + '-' + lrouter['id'] + router_name = ( + lrouter['name'][:nsxv_constants.ROUTER_NAME_LENGTH - + len(lrouter['id'])] + + '-' + lrouter['id']) self._allocate_edge_appliance( context, lrouter['id'], router_name, appliance_size=appliance_size,