# Path: networking_odl/common/exceptions.py
# class NetworkingODLException(exceptions.NeutronException):
# class FullSyncError(NetworkingODLException):
# class UnsupportedResourceType(NetworkingODLException):
# class PluginMethodNotFound(NetworkingODLException, AttributeError):
# class ResourceNotRegistered(FullSyncError):


from neutron_lib.plugins import directory
from oslo_log import log as logging
from networking_odl.common import exceptions

class ResourceBaseDriver(object):
    """Base class for all the drivers to support full sync

       ResourceBaseDriver class acts as base class for all the drivers and
       provides default behaviour for full sync functionality.

       A driver has to provide class or object attribute RESOURCES, specifying
       resources it manages. RESOURCES must be a dictionary, keys of the
       dictionary should be resource type and value should be method suffix
       or plural used for the resources.

       A driver has to provide plugin type for itself, as class or object
       attribute. Its value should be the same, as used by neutron to
       register plugin for the resources it manages.
    """

    RESOURCES = {}
    plugin_type = None

    def __init__(self, *args, **kwargs):
        super(ResourceBaseDriver, self).__init__(*args, **kwargs)
        for resource in self.RESOURCES:
            ALL_RESOURCES[resource] = self

    def _get_resource_getter(self, method_suffix):
        method_name = "get_%s" % method_suffix
        try:
            return getattr(self.plugin, method_name)
        except AttributeError:

# Path: networking_odl/common/exceptions.py
# class NetworkingODLException(exceptions.NeutronException):
# class FullSyncError(NetworkingODLException):
# class UnsupportedResourceType(NetworkingODLException):
# class PluginMethodNotFound(NetworkingODLException, AttributeError):
# class ResourceNotRegistered(FullSyncError):


# Path: networking_odl/journal/base_driver.py
from neutron_lib.plugins import directory
from oslo_log import log as logging
from networking_odl.common import exceptions


class ResourceBaseDriver(object):
    """Base class for all the drivers to support full sync

       ResourceBaseDriver class acts as base class for all the drivers and
       provides default behaviour for full sync functionality.

       A driver has to provide class or object attribute RESOURCES, specifying
       resources it manages. RESOURCES must be a dictionary, keys of the
       dictionary should be resource type and value should be method suffix
       or plural used for the resources.

       A driver has to provide plugin type for itself, as class or object
       attribute. Its value should be the same, as used by neutron to
       register plugin for the resources it manages.
    """

    RESOURCES = {}
    plugin_type = None

    def __init__(self, *args, **kwargs):
        super(ResourceBaseDriver, self).__init__(*args, **kwargs)
        for resource in self.RESOURCES:
            ALL_RESOURCES[resource] = self

    def _get_resource_getter(self, method_suffix):
        method_name = "get_%s" % method_suffix
        try:
            return getattr(self.plugin, method_name)
        except AttributeError:

            raise exceptions.PluginMethodNotFound(plugin=self.plugin_type,