diff --git a/vmware_nsx/services/lbaas/lb_common.py b/vmware_nsx/services/lbaas/lb_common.py index 7088d70eca..cfd240e2b4 100644 --- a/vmware_nsx/services/lbaas/lb_common.py +++ b/vmware_nsx/services/lbaas/lb_common.py @@ -13,11 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. from neutron_lib import exceptions as n_exc +from oslo_log import helpers as log_helpers from vmware_nsx._i18n import _ from vmware_nsx.services.lbaas import lb_const +@log_helpers.log_method_call def validate_session_persistence(pool, listener, completor, old_pool=None): sp = pool.get('session_persistence') if not listener or not sp: diff --git a/vmware_nsx/services/lbaas/nsx_v3/implementation/lb_utils.py b/vmware_nsx/services/lbaas/nsx_v3/implementation/lb_utils.py index 6d53905f1c..2e001b79cb 100644 --- a/vmware_nsx/services/lbaas/nsx_v3/implementation/lb_utils.py +++ b/vmware_nsx/services/lbaas/nsx_v3/implementation/lb_utils.py @@ -250,44 +250,6 @@ def update_router_lb_vip_advertisement(context, core_plugin, router, nsx_router_id, [adv_rule], name_prefix=ADV_RULE_NAME) -@log_helpers.log_method_call -def validate_session_persistence(pool, listener, completor, old_pool=None): - sp = pool.get('session_persistence') - if not listener or not sp: - # safety first! - return - # L4 listeners only allow source IP persistence - if (listener['protocol'] == lb_const.LB_PROTOCOL_TCP and - sp['type'] != lb_const.LB_SESSION_PERSISTENCE_SOURCE_IP): - completor(success=False) - msg = (_("Invalid session persistence type %(sp_type)s for " - "pool on listener %(lst_id)s with %(proto)s protocol") % - {'sp_type': sp['type'], - 'lst_id': listener['id'], - 'proto': listener['protocol']}) - raise n_exc.BadRequest(resource='lbaas-pool', msg=msg) - # Cannot switch (yet) on update from source IP to cookie based, and - # vice versa - cookie_pers_types = (lb_const.LB_SESSION_PERSISTENCE_HTTP_COOKIE, - lb_const.LB_SESSION_PERSISTENCE_APP_COOKIE) - if old_pool: - oldsp = old_pool.get('session_persistence') - if not oldsp: - return - if ((sp['type'] == lb_const.LB_SESSION_PERSISTENCE_SOURCE_IP and - oldsp['type'] in cookie_pers_types) or - (sp['type'] in cookie_pers_types and - oldsp['type'] == lb_const.LB_SESSION_PERSISTENCE_SOURCE_IP)): - completor(success=False) - msg = (_("Cannot update session persistence type to " - "%(sp_type)s for pool on listener %(lst_id)s " - "from %(old_sp_type)s") % - {'sp_type': sp['type'], - 'lst_id': listener['id'], - 'old_sp_type': oldsp['type']}) - raise n_exc.BadRequest(resource='lbaas-pool', msg=msg) - - @log_helpers.log_method_call def delete_persistence_profile(nsxlib, persistence_profile_id): if persistence_profile_id: diff --git a/vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py b/vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py index 1c382c2df3..dbac68567c 100644 --- a/vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py @@ -24,6 +24,7 @@ from vmware_nsx._i18n import _ from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.db import db as nsx_db from vmware_nsx.services.lbaas import base_mgr +from vmware_nsx.services.lbaas import lb_common from vmware_nsx.services.lbaas import lb_const from vmware_nsx.services.lbaas.nsx_v3.implementation import lb_utils from vmware_nsxlib.v3 import exceptions as nsxlib_exc @@ -127,7 +128,7 @@ class EdgeListenerManagerFromDict(base_mgr.Nsxv3LoadbalancerBaseManager): old_pool = None if old_listener: old_pool = old_listener.get('default_pool') - lb_utils.validate_session_persistence( + lb_common.validate_session_persistence( listener.get('default_pool'), listener, completor, old_pool=old_pool) diff --git a/vmware_nsx/services/lbaas/octavia/octavia_driver.py b/vmware_nsx/services/lbaas/octavia/octavia_driver.py index 14a48ce45b..e47299ed04 100644 --- a/vmware_nsx/services/lbaas/octavia/octavia_driver.py +++ b/vmware_nsx/services/lbaas/octavia/octavia_driver.py @@ -189,6 +189,11 @@ class NSXOctaviaDriver(driver_base.ProviderDriver): pool_dict['loadbalancer_id']) if 'listener' not in pool_dict: self._get_listener_in_pool_dict(pool_dict, is_update) + # make sure this pool has a project id + if 'project_id' not in pool_dict: + project_id = self.get_obj_project_id('Pool', pool_dict) + pool_dict['tenant_id'] = pool_dict['project_id'] = project_id + return pool_dict def _get_hm_dict(self, hm_id, is_update): @@ -292,6 +297,10 @@ class NSXOctaviaDriver(driver_base.ProviderDriver): # Generate a loadbalancer object obj_dict['loadbalancer'] = self._get_load_balancer_dict( obj_dict['loadbalancer_id']) + if obj_dict.get('default_pool_id'): + # Generate the default pool object + obj_dict['default_pool'] = self._get_pool_dict( + obj_dict['default_pool_id'], is_update) # TODO(asarfaty): add default_tls_container_id elif obj_type == 'Pool':