From 42342b3cfae137da416c13f290eee416ee0bbe56 Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Mon, 29 Feb 2016 11:55:43 +0200 Subject: [PATCH] Translate LBaaS TERMINATED_HTTPS to NSX equivalent When LBaaS specifies protocol as TERMINATED_HTTPS, NSX Edge should be configured with protocol-type=https. Also, as Edge supports HTTPS without termination as well, we do not need to use TCP as protocol type for HTTPS as well. Change-Id: I16ae69537706862634e1f1bda3be6ae0aeb052d3 --- vmware_nsx/services/lbaas/nsx_v/lbaas_const.py | 4 +++- vmware_nsx/services/lbaas/nsx_v/v2/listener_mgr.py | 5 +++-- .../tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/services/lbaas/nsx_v/lbaas_const.py b/vmware_nsx/services/lbaas/nsx_v/lbaas_const.py index 72c8b66f29..8a4518b712 100644 --- a/vmware_nsx/services/lbaas/nsx_v/lbaas_const.py +++ b/vmware_nsx/services/lbaas/nsx_v/lbaas_const.py @@ -25,11 +25,13 @@ BALANCE_MAP = { LB_PROTOCOL_TCP = 'TCP' LB_PROTOCOL_HTTP = 'HTTP' LB_PROTOCOL_HTTPS = 'HTTPS' +LB_PROTOCOL_TERMINATED_HTTPS = 'TERMINATED_HTTPS' PROTOCOL_MAP = { LB_PROTOCOL_TCP: 'tcp', LB_PROTOCOL_HTTP: 'http', - LB_PROTOCOL_HTTPS: 'tcp'} + LB_PROTOCOL_HTTPS: 'https', + LB_PROTOCOL_TERMINATED_HTTPS: 'https'} LB_HEALTH_MONITOR_PING = 'PING' LB_HEALTH_MONITOR_TCP = 'TCP' diff --git a/vmware_nsx/services/lbaas/nsx_v/v2/listener_mgr.py b/vmware_nsx/services/lbaas/nsx_v/v2/listener_mgr.py index 61a680f33a..7920fae28f 100644 --- a/vmware_nsx/services/lbaas/nsx_v/v2/listener_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_v/v2/listener_mgr.py @@ -38,7 +38,8 @@ def listener_to_edge_app_profile(listener, edge_cert_id): 'template': listener.protocol, } - if listener.protocol == 'HTTPS': + if (listener.protocol == lb_const.LB_PROTOCOL_HTTPS + or listener.protocol == lb_const.LB_PROTOCOL_TERMINATED_HTTPS): if edge_cert_id: edge_app_profile['clientSsl'] = { 'caCertificate': [], @@ -75,7 +76,7 @@ def listener_to_edge_vse(listener, vip_address, default_pool, app_profile_id): 'name': 'vip_' + listener.id, 'description': listener.description, 'ipAddress': vip_address, - 'protocol': listener.protocol, + 'protocol': lb_const.PROTOCOL_MAP[listener.protocol], 'port': listener.protocol_port, 'connectionLimit': max(0, listener.connection_limit), 'defaultPoolId': default_pool, diff --git a/vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py b/vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py index cd0c11dfea..2920092ce2 100644 --- a/vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py +++ b/vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py @@ -40,7 +40,7 @@ EDGE_APP_PROF_DEF = {'sslPassthrough': False, 'insertXForwardedFor': False, 'serverSslEnabled': False, 'name': LISTENER_ID, 'template': 'HTTP'} EDGE_VIP_ID = 'vip-aaa' -EDGE_VIP_DEF = {'protocol': 'HTTP', 'name': 'vip_' + LISTENER_ID, +EDGE_VIP_DEF = {'protocol': 'http', 'name': 'vip_' + LISTENER_ID, 'connectionLimit': 0, 'defaultPoolId': None, 'ipAddress': LB_VIP, 'port': 80, 'applicationProfileId': EDGE_APP_PROFILE_ID, 'description': ''}