Merge "Use registry.receives decorator in neutron.db.l3_hamode_db"
This commit is contained in:
commit
da507c616d
@ -83,6 +83,7 @@ L3_HA_OPTS = [
|
||||
cfg.CONF.register_opts(L3_HA_OPTS)
|
||||
|
||||
|
||||
@registry.has_registry_receivers
|
||||
class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
||||
router_az_db.RouterAvailabilityZoneMixin):
|
||||
"""Mixin class to add high availability capability to routers."""
|
||||
@ -107,20 +108,6 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
||||
def __new__(cls, *args, **kwargs):
|
||||
inst = super(L3_HA_NAT_db_mixin, cls).__new__(cls, *args, **kwargs)
|
||||
inst._verify_configuration()
|
||||
registry.subscribe(inst._release_router_vr_id,
|
||||
resources.ROUTER, events.PRECOMMIT_DELETE)
|
||||
registry.subscribe(inst._cleanup_ha_network,
|
||||
resources.ROUTER, events.AFTER_DELETE)
|
||||
registry.subscribe(inst._precommit_router_create,
|
||||
resources.ROUTER, events.PRECOMMIT_CREATE)
|
||||
registry.subscribe(inst._before_router_create,
|
||||
resources.ROUTER, events.BEFORE_CREATE)
|
||||
registry.subscribe(inst._after_router_create,
|
||||
resources.ROUTER, events.AFTER_CREATE)
|
||||
registry.subscribe(inst._validate_migration,
|
||||
resources.ROUTER, events.PRECOMMIT_UPDATE)
|
||||
registry.subscribe(inst._reconfigure_ha_resources,
|
||||
resources.ROUTER, events.AFTER_UPDATE)
|
||||
return inst
|
||||
|
||||
def get_ha_network(self, context, tenant_id):
|
||||
@ -382,6 +369,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
||||
return n_utils.create_object_with_dependency(
|
||||
creator, dep_getter, dep_creator, dep_id_attr, dep_deleter)[1]
|
||||
|
||||
@registry.receives(resources.ROUTER, [events.BEFORE_CREATE])
|
||||
@db_api.retry_if_session_inactive()
|
||||
def _before_router_create(self, resource, event, trigger,
|
||||
context, router, **kwargs):
|
||||
@ -394,6 +382,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
||||
if not self.get_ha_network(context, router['tenant_id']):
|
||||
self._create_ha_network(context, router['tenant_id'])
|
||||
|
||||
@registry.receives(resources.ROUTER, [events.PRECOMMIT_CREATE])
|
||||
def _precommit_router_create(self, resource, event, trigger, context,
|
||||
router, router_db, **kwargs):
|
||||
"""Event handler to set ha flag and status on creation."""
|
||||
@ -412,6 +401,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
||||
l3_ha.HANetworkConcurrentDeletion(
|
||||
tenant_id=router['tenant_id']))
|
||||
|
||||
@registry.receives(resources.ROUTER, [events.AFTER_CREATE])
|
||||
def _after_router_create(self, resource, event, trigger, context,
|
||||
router_id, router, router_db, **kwargs):
|
||||
if not router['ha']:
|
||||
@ -432,6 +422,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
||||
context, router_id,
|
||||
{'status': n_const.ROUTER_STATUS_ERROR})['status']
|
||||
|
||||
@registry.receives(resources.ROUTER, [events.PRECOMMIT_UPDATE])
|
||||
def _validate_migration(self, resource, event, trigger, context,
|
||||
router_id, router, router_db, old_router,
|
||||
**kwargs):
|
||||
@ -463,6 +454,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
||||
router_db.extra_attributes.ha_vr_id = None
|
||||
self.set_extra_attr_value(context, router_db, 'ha', requested_ha_state)
|
||||
|
||||
@registry.receives(resources.ROUTER, [events.AFTER_UPDATE])
|
||||
def _reconfigure_ha_resources(self, resource, event, trigger, context,
|
||||
router_id, old_router, router, router_db,
|
||||
**kwargs):
|
||||
@ -521,6 +513,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
||||
"%(tenant)s."),
|
||||
{'network': net_id, 'tenant': tenant_id})
|
||||
|
||||
@registry.receives(resources.ROUTER, [events.PRECOMMIT_DELETE])
|
||||
def _release_router_vr_id(self, resource, event, trigger, context,
|
||||
router_db, **kwargs):
|
||||
"""Event handler for removal of VRID during router delete."""
|
||||
@ -531,6 +524,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
||||
self._delete_vr_id_allocation(
|
||||
context, ha_network, router_db.extra_attributes.ha_vr_id)
|
||||
|
||||
@registry.receives(resources.ROUTER, [events.AFTER_DELETE])
|
||||
@db_api.retry_if_session_inactive()
|
||||
def _cleanup_ha_network(self, resource, event, trigger, context,
|
||||
router_id, original, **kwargs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user