Fix making all user defined flavor routers HA

Since [1] was merged, user defined flavor routers with the HA
attribute set to False cannot be created. This change fixes
it.

Closes-Bug: #2057983

[1] https://review.opendev.org/c/openstack/neutron/+/910889

Change-Id: Ic72979cfe535c1bb8cba77fb82a380c167509060
This commit is contained in:
Miguel Lavalle 2024-03-14 18:09:28 -05:00
parent 1b3bc34f67
commit 26ff51bf05
2 changed files with 11 additions and 0 deletions

View File

@ -17,6 +17,7 @@ from neutron_lib.callbacks import priority_group
from neutron_lib.callbacks import registry
from neutron_lib.callbacks import resources
from neutron.common.ovn import utils
from neutron.db import l3_attrs_db
@ -31,5 +32,8 @@ class OVN_L3_HA_db_mixin(l3_attrs_db.ExtraAttributesMixin):
# NOTE(ralonsoh): OVN L3 router HA flag is mandatory and True always,
# enforced by ``OvnDriver.ha_support`` set to ``MANDATORY``. This flag
# cannot be updated.
router = payload.latest_state
if not utils.is_ovn_provider_router(router):
return
router_db = payload.metadata['router_db']
self.set_extra_attr_value(router_db, 'ha', True)

View File

@ -48,3 +48,10 @@ class OVN_L3_HA_db_mixinTestCase(test_plugin.NeutronDbPluginV2TestCase):
router_db = self._create_router(router_dict)
router = router_obj.Router.get_object(self.ctx, id=router_db.id)
self.assertTrue(router.extra_attributes.ha)
def test_create_no_ovn_router(self):
router_dict = {'name': 'foo_router', 'admin_state_up': True,
'distributed': False, 'flavor_id': 'uuid'}
router_db = self._create_router(router_dict)
router = router_obj.Router.get_object(self.ctx, id=router_db.id)
self.assertFalse(router.extra_attributes.ha)