Refactor the Neutron OSKenApp class
Move the duplicated code to a base class BaseNeutronAgentOSKenApp. Authored-By: Swaminathan Vasudevan <SVasudevan@suse.com> Co-Authored-By: Slawek Kaplonski <skaplons@redhat.com> Related-Bug: #1774459 Change-Id: I10c64c318cf04692c30eff6cb718450ea174caf0
This commit is contained in:
parent
a37173c876
commit
9f158922b6
@ -0,0 +1,38 @@
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from os_ken.base import app_manager
|
||||
from os_ken.controller import handler
|
||||
from os_ken.controller import ofp_event
|
||||
from os_ken.ofproto import ofproto_v1_3
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BaseNeutronAgentOSKenApp(app_manager.OSKenApp):
|
||||
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
|
||||
packet_in_handlers = []
|
||||
|
||||
def register_packet_in_handler(self, caller):
|
||||
self.packet_in_handlers.append(caller)
|
||||
|
||||
def unregister_packet_in_handler(self, caller):
|
||||
self.packet_in_handlers.remove(caller)
|
||||
|
||||
@handler.set_ev_cls(ofp_event.EventOFPPacketIn, handler.MAIN_DISPATCHER)
|
||||
def packet_in_handler(self, ev):
|
||||
for caller in self.packet_in_handlers:
|
||||
caller(ev)
|
@ -19,10 +19,11 @@ import functools
|
||||
import os_ken.app.ofctl.api # noqa
|
||||
from os_ken.base import app_manager
|
||||
from os_ken.lib import hub
|
||||
from os_ken.ofproto import ofproto_v1_3
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
|
||||
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \
|
||||
import base_oskenapp
|
||||
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \
|
||||
import br_int
|
||||
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \
|
||||
@ -49,9 +50,7 @@ def agent_main_wrapper(bridge_classes):
|
||||
hub.spawn(app_manager.AppManager.get_instance().close)
|
||||
|
||||
|
||||
class OVSNeutronAgentOSKenApp(app_manager.OSKenApp):
|
||||
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
|
||||
|
||||
class OVSNeutronAgentOSKenApp(base_oskenapp.BaseNeutronAgentOSKenApp):
|
||||
def start(self):
|
||||
# Start os-ken event loop thread
|
||||
super(OVSNeutronAgentOSKenApp, self).start()
|
||||
|
@ -13,26 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from os_ken.base import app_manager
|
||||
from os_ken.controller import handler
|
||||
from os_ken.controller import ofp_event
|
||||
from os_ken.ofproto import ofproto_v1_3
|
||||
from oslo_log import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \
|
||||
import base_oskenapp
|
||||
|
||||
|
||||
class OVSLogOSKenApp(app_manager.OSKenApp):
|
||||
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
|
||||
packet_in_handlers = []
|
||||
|
||||
def register_packet_in_handler(self, caller):
|
||||
self.packet_in_handlers.append(caller)
|
||||
|
||||
def unregister_packet_in_handler(self, caller):
|
||||
self.packet_in_handlers.remove(caller)
|
||||
|
||||
@handler.set_ev_cls(ofp_event.EventOFPPacketIn, handler.MAIN_DISPATCHER)
|
||||
def packet_in_handler(self, ev):
|
||||
for caller in self.packet_in_handlers:
|
||||
caller(ev)
|
||||
class OVSLogOSKenApp(base_oskenapp.BaseNeutronAgentOSKenApp):
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user