Split out DVR DB into multiple classes

This splits the DVR class into subclasses. One that contains the logic
that will ultimately be independent from the L3 mixin which contains the
callbacks that will be used by the DVR service provider. The second
contains all of the agent and scheduling interface logic that will
likely need to remain a mixin for the foreseeable future.

Related: blueprint multi-l3-backends
Change-Id: I64051c9850c82407801cfd9bf9b4ddba3374b9ac
This commit is contained in:
Kevin Benton 2017-04-18 04:32:48 -07:00
parent 336a3ea263
commit f76bafb422
1 changed files with 21 additions and 3 deletions

View File

@ -58,9 +58,14 @@ cfg.CONF.register_opts(router_distributed_opts)
@registry.has_registry_receivers
class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
l3_attrs_db.ExtraAttributesMixin):
"""Mixin class to enable DVR support."""
class DVRResourceOperationHandler(object):
"""Contains callbacks for DVR operations.
TODO(kevinbenton): currently this needs to be implemented as a mixin
into the main L3 mixin. Once we replace references to self with an
l3 plugin lookup we can stop using it as a mixin and just load it
directly in the DVR flavor.
"""
@registry.receives(resources.ROUTER, [events.PRECOMMIT_CREATE])
def _set_distributed_flag(self, resource, event, trigger, context,
@ -551,6 +556,13 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
p['id'],
l3_port_check=False)
class _DVRAgentInterfaceMixin(object):
"""Contains calls made by the DVR scheduler and RPC interface.
Must be instantiated as a mixin with the L3 plugin.
"""
def _get_snat_sync_interfaces(self, context, router_ids):
"""Query router interfaces that relate to list of router_ids."""
if not router_ids:
@ -939,6 +951,12 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
context, address_pair_port['id'], {'port': port_data})
return update_port
class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
l3_attrs_db.ExtraAttributesMixin,
DVRResourceOperationHandler,
_DVRAgentInterfaceMixin):
"""Mixin class to enable DVR support."""
router_device_owners = (
l3_db.L3_NAT_db_mixin.router_device_owners +
(const.DEVICE_OWNER_DVR_INTERFACE,