Add new class for Logging API methods
Not all logapi "DriverBase" [1] methods are implemented in rpc "LoggingApiNotification" [2] Now above classes inherit from class 'LoggingApiBase' [1]cf0cc1f4f2/neutron/services/logapi/drivers/base.py (L27)[2]cf0cc1f4f2/neutron/services/logapi/rpc/server.py (L102)Closes-bug: #1960533 Change-Id: I9fbfa0f823bcdde60910b018ef2a8fdffaf3512c
This commit is contained in:
86
neutron/services/logapi/api_base.py
Normal file
86
neutron/services/logapi/api_base.py
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import abc
|
||||||
|
|
||||||
|
|
||||||
|
class LoggingApiBase(object, metaclass=abc.ABCMeta):
|
||||||
|
"""Logging API methods"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def create_log(self, context, log_obj):
|
||||||
|
"""Create a log_obj invocation.
|
||||||
|
|
||||||
|
This method can be implemented by the specific driver subclass
|
||||||
|
to update the backend where necessary with a specific log object.
|
||||||
|
|
||||||
|
:param context: current running context information
|
||||||
|
:param log_obj: a log objects being created
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def create_log_precommit(self, context, log_obj):
|
||||||
|
"""Create a log_obj precommit.
|
||||||
|
|
||||||
|
This method can be implemented by the specific driver subclass
|
||||||
|
to handle the precommit event of a log_object that is being created.
|
||||||
|
|
||||||
|
:param context: current running context information
|
||||||
|
:param log_obj: a log object being created
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def update_log(self, context, log_obj):
|
||||||
|
"""Update a log_obj invocation.
|
||||||
|
|
||||||
|
This method can be implemented by the specific driver subclass
|
||||||
|
to update the backend where necessary with a specific log object.
|
||||||
|
|
||||||
|
:param context: current running context information
|
||||||
|
:param log_obj: a log object being updated
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def update_log_precommit(self, context, log_obj):
|
||||||
|
"""Update a log_obj precommit.
|
||||||
|
|
||||||
|
This method can be implemented by the specific driver subclass
|
||||||
|
to handle update precommit event of a log_object that is being updated.
|
||||||
|
|
||||||
|
:param context: current running context information
|
||||||
|
:param log_obj: a log_object being updated.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def delete_log(self, context, log_obj):
|
||||||
|
"""Delete a log_obj invocation.
|
||||||
|
|
||||||
|
This method can be implemented by the specific driver subclass
|
||||||
|
to delete the backend where necessary with a specific log object.
|
||||||
|
|
||||||
|
:param context: current running context information
|
||||||
|
:param log_obj: a log_object being deleted
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def delete_log_precommit(self, context, log_obj):
|
||||||
|
"""Delete a log_obj precommit.
|
||||||
|
|
||||||
|
This method can be implemented by the specific driver subclass
|
||||||
|
to handle delete precommit event of a log_object that is being deleted.
|
||||||
|
|
||||||
|
:param context: current running context information
|
||||||
|
:param log_obj: a log_object being deleted
|
||||||
|
"""
|
||||||
@@ -18,13 +18,14 @@ from neutron_lib.callbacks import registry
|
|||||||
from neutron_lib.services.logapi import constants as log_const
|
from neutron_lib.services.logapi import constants as log_const
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
from neutron.services.logapi import api_base
|
||||||
from neutron.services.logapi.rpc import server as server_rpc
|
from neutron.services.logapi.rpc import server as server_rpc
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@registry.has_registry_receivers
|
@registry.has_registry_receivers
|
||||||
class DriverBase(object):
|
class DriverBase(api_base.LoggingApiBase):
|
||||||
|
|
||||||
def __init__(self, name, vif_types, vnic_types,
|
def __init__(self, name, vif_types, vnic_types,
|
||||||
supported_logging_types, requires_rpc=False):
|
supported_logging_types, requires_rpc=False):
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import oslo_messaging
|
|||||||
|
|
||||||
from neutron.api.rpc.callbacks import events
|
from neutron.api.rpc.callbacks import events
|
||||||
from neutron.api.rpc.handlers import resources_rpc
|
from neutron.api.rpc.handlers import resources_rpc
|
||||||
|
from neutron.services.logapi import api_base
|
||||||
from neutron.services.logapi.common import db_api
|
from neutron.services.logapi.common import db_api
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@@ -99,7 +100,7 @@ class LoggingApiSkeleton(object):
|
|||||||
return rpc_method(context, log_resources)
|
return rpc_method(context, log_resources)
|
||||||
|
|
||||||
|
|
||||||
class LoggingApiNotification(object):
|
class LoggingApiNotification(api_base.LoggingApiBase):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.notification_api = resources_rpc.ResourcesPushRpcApi()
|
self.notification_api = resources_rpc.ResourcesPushRpcApi()
|
||||||
@@ -108,14 +109,23 @@ class LoggingApiNotification(object):
|
|||||||
def create_log(self, context, log_obj):
|
def create_log(self, context, log_obj):
|
||||||
self.notification_api.push(context, [log_obj], events.CREATED)
|
self.notification_api.push(context, [log_obj], events.CREATED)
|
||||||
|
|
||||||
|
def create_log_precommit(self, context, log_obj):
|
||||||
|
pass
|
||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
def update_log(self, context, log_obj):
|
def update_log(self, context, log_obj):
|
||||||
self.notification_api.push(context, [log_obj], events.UPDATED)
|
self.notification_api.push(context, [log_obj], events.UPDATED)
|
||||||
|
|
||||||
|
def update_log_precommit(self, context, log_obj):
|
||||||
|
pass
|
||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
def delete_log(self, context, log_obj):
|
def delete_log(self, context, log_obj):
|
||||||
self.notification_api.push(context, [log_obj], events.DELETED)
|
self.notification_api.push(context, [log_obj], events.DELETED)
|
||||||
|
|
||||||
|
def delete_log_precommit(self, context, log_obj):
|
||||||
|
pass
|
||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
def resource_update(self, context, log_objs):
|
def resource_update(self, context, log_objs):
|
||||||
"""Tell to agent when resources related to log_objects updated"""
|
"""Tell to agent when resources related to log_objects updated"""
|
||||||
|
|||||||
Reference in New Issue
Block a user