NSX|V3+P: Fix listener creation when LB has no name
Change-Id: Idaa39e140a724d01892e6c29a914d47ec4f5b18a
This commit is contained in:
parent
eb27d79bd8
commit
063c976fd6
|
@ -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]})
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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]})
|
||||
|
|
|
@ -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']})
|
||||
|
|
|
@ -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…
Reference in New Issue