Browse Source

Merge "NSX|V3+P: Fix listener creation when LB has no name" into stable/stein

changes/74/737174/1
Zuul 3 weeks ago
committed by Gerrit Code Review
parent
commit
edccd37a5f
5 changed files with 46 additions and 8 deletions
  1. +1
    -1
      vmware_nsx/services/lbaas/nsx_p/implementation/lb_utils.py
  2. +5
    -3
      vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py
  3. +1
    -1
      vmware_nsx/services/lbaas/nsx_v3/implementation/lb_utils.py
  4. +4
    -3
      vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py
  5. +35
    -0
      vmware_nsx/tests/unit/services/lbaas/test_nsxp_driver.py

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

@@ -167,7 +167,7 @@ def build_persistence_profile_tags(pool_tags, listener):
# With octavia loadbalancer name might not be among data passed
# down to the driver
lb_data = listener.get('loadbalancer')
if lb_data:
if lb_data and lb_data.get('name'):
tags.append({
'scope': lb_const.LB_LB_NAME,
'tag': lb_data['name'][:utils.MAX_TAG_LEN]})


+ 5
- 3
vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py View File

@@ -39,12 +39,14 @@ class EdgeListenerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
lb_const.LB_LISTENER_TYPE,
listener.get('tenant_id'),
context.project_name)
tags.append({
'scope': lb_const.LB_LB_NAME,
'tag': listener['loadbalancer']['name'][:utils.MAX_TAG_LEN]})
if listener['loadbalancer'].get('name'):
tags.append({
'scope': lb_const.LB_LB_NAME,
'tag': listener['loadbalancer']['name'][:utils.MAX_TAG_LEN]})
tags.append({
'scope': lb_const.LB_LB_TYPE,
'tag': listener['loadbalancer_id']})
LOG.error("DEBUG ADIT _get_listener_tags end")
return tags

def _upload_certificate(self, listener_id, cert_href, tags,


+ 1
- 1
vmware_nsx/services/lbaas/nsx_v3/implementation/lb_utils.py View File

@@ -256,7 +256,7 @@ def build_persistence_profile_tags(pool_tags, listener):
# With octavia loadbalancer name might not be among data passed
# down to the driver
lb_data = listener.get('loadbalancer')
if lb_data:
if lb_data and lb_data.get('name'):
tags.append({
'scope': lb_const.LB_LB_NAME,
'tag': lb_data['name'][:utils.MAX_TAG_LEN]})


+ 4
- 3
vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py View File

@@ -104,9 +104,10 @@ class EdgeListenerManagerFromDict(base_mgr.Nsxv3LoadbalancerBaseManager):
lb_const.LB_LISTENER_TYPE,
listener['tenant_id'],
context.project_name)
tags.append({
'scope': lb_const.LB_LB_NAME,
'tag': listener['loadbalancer']['name'][:utils.MAX_TAG_LEN]})
if listener['loadbalancer'].get('name'):
tags.append({
'scope': lb_const.LB_LB_NAME,
'tag': listener['loadbalancer']['name'][:utils.MAX_TAG_LEN]})
tags.append({
'scope': lb_const.LB_LB_TYPE,
'tag': listener['loadbalancer_id']})


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

@@ -13,7 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import copy

import mock

from neutron.tests import base
from neutron_lbaas.services.loadbalancer import data_models as lb_models
from neutron_lib import context
@@ -893,6 +896,38 @@ class TestEdgeLbaasV2Listener(BaseTestEdgeLbaasV2):
self.context, listener_dict,
self.completor)

def test_create_listener_lb_no_name(self, protocol='HTTP'):
self.reset_completor()
with mock.patch.object(self.core_plugin, 'get_floatingips'
) as mock_get_floatingips, \
mock.patch.object(self.core_plugin,
'get_waf_profile_path_and_mode',
return_value=(None, None)), \
mock.patch.object(self.vs_client, 'create_or_overwrite'
) as mock_add_virtual_server:
mock_get_floatingips.return_value = []
listener = copy.deepcopy(self.listener_dict)
listener['loadbalancer']['name'] = None
listener_id = LISTENER_ID

self.edge_driver.listener.create(self.context, listener,
self.completor)

mock_add_virtual_server.assert_called_with(
application_profile_id=listener_id,
description=listener['description'],
lb_service_id=LB_ID,
ip_address=LB_VIP,
tags=mock.ANY,
name=mock.ANY,
ports=[listener['protocol_port']],
max_concurrent_connections=None,
virtual_server_id=listener_id,
pool_id='',
lb_persistence_profile_id='')
self.assertTrue(self.last_completor_called)
self.assertTrue(self.last_completor_succees)

def test_update(self):
new_listener = lb_models.Listener(LISTENER_ID, LB_TENANT_ID,
'listener1-new', 'new-description',


Loading…
Cancel
Save