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

This commit is contained in:
Zuul 2020-06-20 05:18:06 +00:00 committed by Gerrit Code Review
commit 7ad74ce1bc
5 changed files with 45 additions and 8 deletions

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]})

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,

View File

@ -254,7 +254,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]})

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']})

View File

@ -13,7 +13,9 @@
# 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_lib import context
from neutron_lib import exceptions as n_exc
@ -895,6 +897,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',