V2T migration: Update FWaaS group status from driver

When the migration takes place, the rpc queues are not working so the
group's status should be updated in the DB directly

Change-Id: I7a1afe751f329eabb055dccb7d5367c47de12426
This commit is contained in:
asarfaty 2021-03-18 10:56:23 +02:00 committed by Adit Sarfaty
parent 5fa59aac52
commit f3c1853c39
1 changed files with 17 additions and 0 deletions

View File

@ -13,12 +13,21 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutron_lib import constants as nl_constants
from neutron_lib import context as n_context from neutron_lib import context as n_context
from neutron_lib.exceptions import firewall_v2 as exceptions from neutron_lib.exceptions import firewall_v2 as exceptions
from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from vmware_nsx.services.fwaas.common import fwaas_driver_base from vmware_nsx.services.fwaas.common import fwaas_driver_base
try:
from neutron_fwaas.db.firewall.v2 import firewall_db_v2
except ImportError:
# FWaaS project no found
from vmware_nsx.services.fwaas.common import fwaas_mocks \
as firewall_db_v2
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -61,6 +70,14 @@ class CommonEdgeFwaasV3Driver(fwaas_driver_base.EdgeFwaasDriverBaseV2):
"%s", router_id, e) "%s", router_id, e)
raise self.driver_exception(driver=self.driver_name) raise self.driver_exception(driver=self.driver_name)
if cfg.CONF.api_replay_mode and len(routers) > 0:
# In api replay mode the RPC isn't working so the FW group status
# should be updated directly
with context.session.begin(subtransactions=True):
group = (context.session.query(firewall_db_v2.FirewallGroup).
filter_by(id=fwg_id).one())
group['status'] = nl_constants.ACTIVE
def should_apply_firewall_to_router(self, router_data): def should_apply_firewall_to_router(self, router_data):
"""Return True if the firewall rules should be added the router""" """Return True if the firewall rules should be added the router"""
if not router_data.get('external_gateway_info'): if not router_data.get('external_gateway_info'):