Browse Source

NSX|P: Fix listener create & update

Use tags to find the lb service id from the loadbalancer id

Change-Id: Ic6a756aaa98c27362d34f3eff488864a4eedd036
(cherry picked from commit 4d5cbfd7a1)
tags/14.0.1
asarfaty 1 month ago
committed by Adit Sarfaty
parent
commit
13f7c3b795
2 changed files with 31 additions and 1 deletions
  1. +4
    -1
      vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py
  2. +27
    -0
      vmware_nsx/tests/unit/services/lbaas/test_nsxp_driver.py

+ 4
- 1
vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py View File

@@ -91,11 +91,14 @@ class EdgeListenerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
lb_vip_address = floating_ips[0]['floating_ip_address']
else:
lb_vip_address = listener['loadbalancer']['vip_address']
lb_service = lb_utils.get_lb_nsx_lb_service(
self.core_plugin.nsxpolicy, listener['loadbalancer_id'])

kwargs = {'virtual_server_id': listener['id'],
'ip_address': lb_vip_address,
'ports': [listener['protocol_port']],
'application_profile_id': listener['id'],
'lb_service_id': listener['loadbalancer_id'],
'lb_service_id': lb_service['id'],
'description': listener.get('description')}
if vs_name:
kwargs['name'] = vs_name


+ 27
- 0
vmware_nsx/tests/unit/services/lbaas/test_nsxp_driver.py View File

@@ -717,6 +717,9 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
mock.patch.object(self.core_plugin,
'get_waf_profile_path_and_mode',
return_value=(None, None)), \
mock.patch.object(self.core_plugin.nsxpolicy, 'search_by_tags',
return_value={'results': [
{'id': LB_SERVICE_ID}]}),\
mock.patch.object(self.vs_client, 'create_or_overwrite'
) as mock_add_virtual_server:
mock_get_floatingips.return_value = []
@@ -758,6 +761,9 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
mock.patch.object(self.core_plugin,
'get_waf_profile_path_and_mode',
return_value=(None, None)), \
mock.patch.object(self.core_plugin.nsxpolicy, 'search_by_tags',
return_value={'results': [
{'id': LB_SERVICE_ID}]}),\
mock.patch.object(self.vs_client, 'create_or_overwrite'
) as mock_add_virtual_server:
mock_get_floatingips.return_value = []
@@ -793,6 +799,9 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
mock.patch.object(self.core_plugin,
'get_waf_profile_path_and_mode',
return_value=(None, None)), \
mock.patch.object(self.core_plugin.nsxpolicy, 'search_by_tags',
return_value={'results': [
{'id': LB_SERVICE_ID}]}),\
mock.patch.object(self.vs_client, 'create_or_overwrite'
) as mock_add_virtual_server:
mock_get_floatingips.return_value = []
@@ -850,6 +859,9 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
return_value=(None, None)), \
mock.patch.object(self.vs_client, 'create_or_overwrite'
) as mock_add_virtual_server,\
mock.patch.object(self.core_plugin.nsxpolicy, 'search_by_tags',
return_value={'results': [
{'id': LB_SERVICE_ID}]}),\
mock.patch.object(self.vs_client, 'get', return_value={}),\
mock.patch.object(self.edge_driver.listener, '_get_pool_tags'),\
mock.patch.object(self.pp_cookie_client, 'create_or_overwrite'
@@ -900,6 +912,9 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
mock.patch.object(self.core_plugin,
'get_waf_profile_path_and_mode',
return_value=(None, None)), \
mock.patch.object(self.core_plugin.nsxpolicy, 'search_by_tags',
return_value={'results': [
{'id': LB_SERVICE_ID}]}),\
mock.patch.object(self.vs_client, 'create_or_overwrite'
) as mock_add_virtual_server:
mock_get_floatingips.return_value = []
@@ -935,6 +950,9 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
with mock.patch.object(self.core_plugin,
'get_waf_profile_path_and_mode',
return_value=(None, None)), \
mock.patch.object(self.core_plugin.nsxpolicy, 'search_by_tags',
return_value={'results': [
{'id': LB_SERVICE_ID}]}),\
mock.patch.object(self.core_plugin, 'get_floatingips'
) as mock_get_floatingips:
mock_get_floatingips.return_value = []
@@ -957,6 +975,9 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
with mock.patch.object(self.core_plugin,
'get_waf_profile_path_and_mode',
return_value=(None, None)), \
mock.patch.object(self.core_plugin.nsxpolicy, 'search_by_tags',
return_value={'results': [
{'id': LB_SERVICE_ID}]}),\
mock.patch.object(self.core_plugin, 'get_floatingips'
) as mock_get_floatingips:
mock_get_floatingips.return_value = []
@@ -981,6 +1002,9 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
mock.patch.object(self.core_plugin,
'get_waf_profile_path_and_mode',
return_value=(None, None)), \
mock.patch.object(self.core_plugin.nsxpolicy, 'search_by_tags',
return_value={'results': [
{'id': LB_SERVICE_ID}]}),\
mock.patch.object(self.edge_driver.listener, '_get_pool_tags'),\
mock.patch.object(self.vs_client, 'get', return_value={}),\
mock.patch.object(self.vs_client, 'update',
@@ -1030,6 +1054,9 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
) as mock_create_pp, \
mock.patch.object(self.pp_generic_client, 'delete'
) as mock_delete_pp, \
mock.patch.object(self.core_plugin.nsxpolicy, 'search_by_tags',
return_value={'results': [
{'id': LB_SERVICE_ID}]}),\
mock.patch.object(self.core_plugin, 'get_floatingips'
) as mock_get_floatingips, \
mock.patch.object(self.edge_driver.listener,


Loading…
Cancel
Save