Rename ovs.py and ovs.OvsPort to switch.py and SwitchPort
The object now represents a generic switch port and not a specific ovs port. The naming should represent it. Change-Id: Ifa4f43eeaf50d807c46a6a034a98ba02c8dd5bfa Partial-Bug: #1781376
This commit is contained in:
parent
329b41ee61
commit
e52ba1ee31
|
@ -22,7 +22,7 @@ from dragonflow.controller.common import constants as const
|
|||
from dragonflow.controller import df_base_app
|
||||
from dragonflow.db.models import constants as model_const
|
||||
from dragonflow.db.models import l2
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
@ -82,8 +82,8 @@ class ChassisSNATApp(df_base_app.DFlowApp, snat_mixin.SNATApp_mixin):
|
|||
self.external_ofport = self.vswitch_api.get_port_ofport(
|
||||
mapping[0])
|
||||
|
||||
@df_base_app.register_event(ovs.OvsPort, model_const.EVENT_CREATED)
|
||||
@df_base_app.register_event(ovs.OvsPort, model_const.EVENT_UPDATED)
|
||||
@df_base_app.register_event(switch.SwitchPort, model_const.EVENT_CREATED)
|
||||
@df_base_app.register_event(switch.SwitchPort, model_const.EVENT_UPDATED)
|
||||
def ovs_port_updated(self, ovs_port, orig_ovs_port=None):
|
||||
if ovs_port.name != self.external_network_bridge:
|
||||
return
|
||||
|
|
|
@ -18,7 +18,7 @@ from ryu.ofproto import nicira_ext
|
|||
from dragonflow.controller.common import constants as const
|
||||
from dragonflow.controller import df_base_app
|
||||
from dragonflow.db.models import constants as model_constants
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -38,8 +38,10 @@ class ClassifierApp(df_base_app.DFlowApp):
|
|||
goto_table_id=self.dfdp.apps['portsec'].entrypoints.default,
|
||||
)
|
||||
|
||||
@df_base_app.register_event(ovs.OvsPort, model_constants.EVENT_CREATED)
|
||||
@df_base_app.register_event(ovs.OvsPort, model_constants.EVENT_UPDATED)
|
||||
@df_base_app.register_event(
|
||||
switch.SwitchPort, model_constants.EVENT_CREATED)
|
||||
@df_base_app.register_event(
|
||||
switch.SwitchPort, model_constants.EVENT_UPDATED)
|
||||
def _ovs_port_created(self, ovs_port, orig_ovs_port=None):
|
||||
ofport = ovs_port.ofport
|
||||
lport_ref = ovs_port.lport
|
||||
|
@ -98,7 +100,8 @@ class ClassifierApp(df_base_app.DFlowApp):
|
|||
actions=actions,
|
||||
)
|
||||
|
||||
@df_base_app.register_event(ovs.OvsPort, model_constants.EVENT_DELETED)
|
||||
@df_base_app.register_event(
|
||||
switch.SwitchPort, model_constants.EVENT_DELETED)
|
||||
def _ovs_port_deleted(self, ovs_port):
|
||||
try:
|
||||
ofport, port_key = self._ofport_unique_key_map.pop(ovs_port.id)
|
||||
|
|
|
@ -36,7 +36,7 @@ from dragonflow.controller.common import constants as const
|
|||
from dragonflow.controller import df_base_app
|
||||
from dragonflow.db.models import constants as model_const
|
||||
from dragonflow.db.models import l2
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -66,8 +66,8 @@ class MetadataServiceApp(df_base_app.DFlowApp):
|
|||
# the flows.
|
||||
self._add_tap_metadata_port(self._ofport, self._interface_mac)
|
||||
|
||||
@df_base_app.register_event(ovs.OvsPort, model_const.EVENT_CREATED)
|
||||
@df_base_app.register_event(ovs.OvsPort, model_const.EVENT_UPDATED)
|
||||
@df_base_app.register_event(switch.SwitchPort, model_const.EVENT_CREATED)
|
||||
@df_base_app.register_event(switch.SwitchPort, model_const.EVENT_UPDATED)
|
||||
def ovs_port_updated(self, ovs_port, orig_ovs_port=None):
|
||||
if ovs_port.name != cfg.CONF.df_metadata.metadata_interface:
|
||||
return
|
||||
|
@ -87,7 +87,7 @@ class MetadataServiceApp(df_base_app.DFlowApp):
|
|||
self._ofport = ofport
|
||||
self._interface_mac = mac
|
||||
|
||||
@df_base_app.register_event(ovs.OvsPort, model_const.EVENT_DELETED)
|
||||
@df_base_app.register_event(switch.SwitchPort, model_const.EVENT_DELETED)
|
||||
def ovs_port_deleted(self, ovs_port):
|
||||
if ovs_port.name != cfg.CONF.df_metadata.metadata_interface:
|
||||
return
|
||||
|
|
|
@ -25,7 +25,7 @@ from dragonflow.controller.common import logical_networks
|
|||
from dragonflow.controller import df_base_app
|
||||
from dragonflow.db.models import constants as model_const
|
||||
from dragonflow.db.models import l2
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
|
||||
|
||||
NET_VLAN = 'vlan'
|
||||
|
@ -80,12 +80,12 @@ class ProviderApp(df_base_app.DFlowApp):
|
|||
mac = self.vswitch_api.get_port_mac_in_use(bridge)
|
||||
self.bridge_macs[physical_network] = mac
|
||||
|
||||
@df_base_app.register_event(ovs.OvsPort, model_const.EVENT_CREATED)
|
||||
@df_base_app.register_event(ovs.OvsPort, model_const.EVENT_UPDATED)
|
||||
@df_base_app.register_event(switch.SwitchPort, model_const.EVENT_CREATED)
|
||||
@df_base_app.register_event(switch.SwitchPort, model_const.EVENT_UPDATED)
|
||||
def _bridge_updated(self, ovsport, orig_ovsport=None):
|
||||
self._update_bridge_mac(ovsport.name, ovsport.mac_in_use)
|
||||
|
||||
@df_base_app.register_event(ovs.OvsPort, model_const.EVENT_DELETED)
|
||||
@df_base_app.register_event(switch.SwitchPort, model_const.EVENT_DELETED)
|
||||
def _bridge_deleted(self, ovsport):
|
||||
self._update_bridge_mac(ovsport.name, None)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ from dragonflow.common import constants
|
|||
from dragonflow.db import db_store
|
||||
from dragonflow.db.models import l2
|
||||
from dragonflow.db.models import migration
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
@ -50,9 +50,9 @@ class Topology(object):
|
|||
self.db_store = db_store.get_instance()
|
||||
|
||||
# TODO(snapiri) this should not be ovs specific
|
||||
ovs.OvsPort.register_created(self.ovs_port_updated)
|
||||
ovs.OvsPort.register_updated(self.ovs_port_updated)
|
||||
ovs.OvsPort.register_deleted(self.ovs_port_deleted)
|
||||
switch.SwitchPort.register_created(self.ovs_port_updated)
|
||||
switch.SwitchPort.register_updated(self.ovs_port_updated)
|
||||
switch.SwitchPort.register_deleted(self.ovs_port_deleted)
|
||||
|
||||
def ovs_port_updated(self, ovs_port, orig_ovs_port=None):
|
||||
"""
|
||||
|
@ -289,7 +289,7 @@ class Topology(object):
|
|||
new_ovs_to_lport_mapping = {}
|
||||
add_ovs_to_lport_mapping = {}
|
||||
delete_ovs_to_lport_mapping = self.ovs_to_lport_mapping
|
||||
for ovs_port in self.db_store.get_all(ovs.OvsPort):
|
||||
for ovs_port in self.db_store.get_all(switch.SwitchPort):
|
||||
key = ovs_port.id
|
||||
if ovs_port.type == constants.SWITCH_COMPUTE_INTERFACE:
|
||||
lport = self._get_lport(ovs_port)
|
||||
|
|
|
@ -20,8 +20,8 @@ from dragonflow.db.models import mixins
|
|||
|
||||
@mf.register_model
|
||||
@mf.construct_nb_db_model
|
||||
class OvsPort(mf.ModelBase, mixins.BasicEvents, mixins.Name):
|
||||
table_name = 'ovs_port'
|
||||
class SwitchPort(mf.ModelBase, mixins.BasicEvents, mixins.Name):
|
||||
table_name = 'switch_port'
|
||||
|
||||
ofport = fields.IntField()
|
||||
admin_state = df_fields.EnumField(('up', 'down'))
|
|
@ -17,7 +17,7 @@ from ovsdbapp.backend.ovs_idl import idlutils
|
|||
from ovsdbapp.schema.open_vswitch import impl_idl
|
||||
|
||||
from dragonflow.common import constants
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
from dragonflow.ovsdb import commands
|
||||
|
||||
ovsdb_monitor_table_filter_default = {
|
||||
|
@ -72,23 +72,23 @@ _HANDLED_INTERFACE_TYPES = (
|
|||
)
|
||||
|
||||
|
||||
def _is_ovsport_update_valid(action, ovsport):
|
||||
if ovsport.name == cfg.CONF.df_metadata.metadata_interface:
|
||||
def _is_ovsport_update_valid(action, switch_port):
|
||||
if switch_port.name == cfg.CONF.df_metadata.metadata_interface:
|
||||
return True
|
||||
|
||||
if ovsport.type not in _HANDLED_INTERFACE_TYPES:
|
||||
if switch_port.type not in _HANDLED_INTERFACE_TYPES:
|
||||
return False
|
||||
|
||||
if ovsport.name.startswith('qg'):
|
||||
if switch_port.name.startswith('qg'):
|
||||
return False
|
||||
|
||||
if (ovsport.type == constants.SWITCH_COMPUTE_INTERFACE and
|
||||
ovsport.lport is None):
|
||||
if (switch_port.type == constants.SWITCH_COMPUTE_INTERFACE and
|
||||
switch_port.lport is None):
|
||||
return False
|
||||
|
||||
if action == 'set':
|
||||
# No need for 'updated' event if the ofport is being deleted
|
||||
ofport = ovsport.ofport
|
||||
ofport = switch_port.ofport
|
||||
if (ofport is None) or (ofport < 0):
|
||||
return False
|
||||
|
||||
|
@ -116,7 +116,7 @@ def _get_interface_type(row):
|
|||
|
||||
|
||||
def _port_from_idl_row(row):
|
||||
res = ovs.OvsPort(
|
||||
res = switch.SwitchPort(
|
||||
id=str(row.uuid),
|
||||
name=row.name,
|
||||
type=_get_interface_type(row),
|
||||
|
|
|
@ -20,8 +20,8 @@ from oslo_log import log
|
|||
from ovs import vlog
|
||||
|
||||
from dragonflow.controller.common import constants
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import qos
|
||||
from dragonflow.db.models import switch
|
||||
from dragonflow.ovsdb import impl_idl
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -102,7 +102,7 @@ class OvsApi(object):
|
|||
continue
|
||||
|
||||
tunnel_ports.append(
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
id=str(iface['uuid']),
|
||||
name=iface['name'],
|
||||
tunnel_type=iface['type'],
|
||||
|
|
|
@ -20,7 +20,7 @@ from ryu import cfg as ryu_cfg
|
|||
from dragonflow import conf as cfg
|
||||
from dragonflow.controller import ryu_base_app
|
||||
from dragonflow.db.models import l2
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
from dragonflow.ovsdb import vswitch_impl
|
||||
from dragonflow.switch.drivers import df_switch_driver
|
||||
|
||||
|
@ -79,7 +79,7 @@ class DfOvsDriver(df_switch_driver.DfSwitchDriver):
|
|||
self.open_flow_app.notify_switch_sync_finished()
|
||||
|
||||
def sync_ignore_models(self):
|
||||
return [ovs.OvsPort, ]
|
||||
return [switch.SwitchPort, ]
|
||||
|
||||
def notify_port_status(self, ovs_port, status):
|
||||
if self.neutron_notifier:
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
from dragonflow.common import constants
|
||||
from dragonflow import conf as cfg
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
from dragonflow.tests.common import constants as const
|
||||
from dragonflow.tests.common import utils
|
||||
from dragonflow.tests.fullstack import test_base
|
||||
|
@ -25,14 +25,14 @@ class TestOvsdbMonitor(test_base.DFTestBase):
|
|||
self.set_wanted_vms = set()
|
||||
|
||||
def _check_wanted_vm_online(self, update, mac):
|
||||
if update.table != ovs.OvsPort.table_name:
|
||||
if update.table != switch.SwitchPort.table_name:
|
||||
return False
|
||||
if update.action != "create" and update.action != "set":
|
||||
return False
|
||||
if update.value is None:
|
||||
return False
|
||||
|
||||
_interface = ovs.OvsPort.from_json(update.value)
|
||||
_interface = switch.SwitchPort.from_json(update.value)
|
||||
if str(_interface.attached_mac) != mac:
|
||||
return False
|
||||
elif _interface.type != constants.SWITCH_COMPUTE_INTERFACE:
|
||||
|
@ -47,11 +47,11 @@ class TestOvsdbMonitor(test_base.DFTestBase):
|
|||
return True
|
||||
|
||||
def _check_wanted_vm_offline(self, update, mac):
|
||||
if update.table != ovs.OvsPort.table_name:
|
||||
if update.table != switch.SwitchPort.table_name:
|
||||
return False
|
||||
if update.action != "delete":
|
||||
return False
|
||||
_interface = ovs.OvsPort.from_json(update.value)
|
||||
_interface = switch.SwitchPort.from_json(update.value)
|
||||
if _interface is None:
|
||||
return False
|
||||
elif str(_interface.attached_mac) != mac:
|
||||
|
|
|
@ -32,8 +32,8 @@ from dragonflow.db import model_framework
|
|||
from dragonflow.db.models import core
|
||||
from dragonflow.db.models import l2
|
||||
from dragonflow.db.models import l3
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import secgroups
|
||||
from dragonflow.db.models import switch
|
||||
from dragonflow.tests import base as tests_base
|
||||
|
||||
|
||||
|
@ -290,7 +290,7 @@ fake_local_port1 = make_fake_local_port(
|
|||
dhcp_params=fake_dhcp_params)
|
||||
|
||||
|
||||
fake_ovs_port1 = ovs.OvsPort(
|
||||
fake_ovs_port1 = switch.SwitchPort(
|
||||
id='fake_ovs_port1',
|
||||
ofport=2,
|
||||
name='tap-fake_port1',
|
||||
|
@ -308,7 +308,7 @@ fake_local_port2 = make_fake_local_port(
|
|||
subnets=['fake_subnet1'])
|
||||
|
||||
|
||||
fake_ovs_port2 = ovs.OvsPort(
|
||||
fake_ovs_port2 = switch.SwitchPort(
|
||||
id='fake_ovs_port2',
|
||||
ofport=3,
|
||||
name='tap-fake_port2',
|
||||
|
|
|
@ -19,7 +19,7 @@ import testscenarios
|
|||
from dragonflow.common import constants
|
||||
from dragonflow.controller.common import constants as const
|
||||
from dragonflow.db.models import l2
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
from dragonflow.tests.unit import test_app_base
|
||||
|
||||
make_fake_local_port = test_app_base.make_fake_local_port
|
||||
|
@ -58,10 +58,10 @@ class TestClassifierAppForVlan(testscenarios.WithScenarios,
|
|||
lswitch='fake_vlan_switch1')
|
||||
self.controller.update(fake_local_vlan_port)
|
||||
self.app.mod_flow.assert_not_called()
|
||||
ovs_port = ovs.OvsPort(id='fake_ovs_port',
|
||||
lport=fake_local_vlan_port.id,
|
||||
ofport=1, admin_state='up',
|
||||
type=constants.SWITCH_COMPUTE_INTERFACE)
|
||||
ovs_port = switch.SwitchPort(id='fake_ovs_port',
|
||||
lport=fake_local_vlan_port.id,
|
||||
ofport=1, admin_state='up',
|
||||
type=constants.SWITCH_COMPUTE_INTERFACE)
|
||||
self.controller.update(ovs_port)
|
||||
port_key = fake_local_vlan_port.unique_key
|
||||
match = self.app.parser.OFPMatch(reg7=port_key)
|
||||
|
|
|
@ -19,7 +19,7 @@ from neutron.conf.agent.metadata import config as metadata_config
|
|||
from oslo_config import fixture as cfg_fixture
|
||||
|
||||
from dragonflow.controller.apps import metadata_service
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
from dragonflow.tests import base as tests_base
|
||||
from dragonflow.tests.unit import test_app_base
|
||||
|
||||
|
@ -36,7 +36,7 @@ class TestMetadataServiceApp(test_app_base.DFAppTestBase):
|
|||
'_add_tap_metadata_port') as mock_func:
|
||||
# Device without mac will not trigger update flow
|
||||
self.controller.update(
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
id='fake_ovs_port',
|
||||
ofport=1,
|
||||
name=self.meta_app._interface,
|
||||
|
@ -47,7 +47,7 @@ class TestMetadataServiceApp(test_app_base.DFAppTestBase):
|
|||
|
||||
# Other device update will not trigger update flow
|
||||
self.controller.update(
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
id='fake_ovs_port',
|
||||
ofport=1,
|
||||
name='no-interface',
|
||||
|
@ -59,7 +59,7 @@ class TestMetadataServiceApp(test_app_base.DFAppTestBase):
|
|||
|
||||
# Device with mac will trigger update flow
|
||||
self.controller.update(
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
id='fake_ovs_port',
|
||||
ofport=1,
|
||||
name=self.meta_app._interface,
|
||||
|
@ -71,7 +71,7 @@ class TestMetadataServiceApp(test_app_base.DFAppTestBase):
|
|||
|
||||
# Duplicated updated will not trigger update flow
|
||||
self.controller.update(
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
id='fake_ovs_port1',
|
||||
ofport=1,
|
||||
name=self.meta_app._interface,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from dragonflow.common import constants
|
||||
from dragonflow.db.models import ovs
|
||||
from dragonflow.db.models import switch
|
||||
from dragonflow.ovsdb import impl_idl
|
||||
from dragonflow.tests import base as tests_base
|
||||
|
||||
|
@ -23,7 +23,7 @@ class TestDFIdl(tests_base.BaseTestCase):
|
|||
self.assertFalse(
|
||||
impl_idl._is_ovsport_update_valid(
|
||||
'set',
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
ofport=1,
|
||||
name='qg-some-uuid',
|
||||
),
|
||||
|
@ -34,7 +34,7 @@ class TestDFIdl(tests_base.BaseTestCase):
|
|||
self.assertFalse(
|
||||
impl_idl._is_ovsport_update_valid(
|
||||
'set',
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
name='tap-uuid',
|
||||
),
|
||||
),
|
||||
|
@ -44,7 +44,7 @@ class TestDFIdl(tests_base.BaseTestCase):
|
|||
self.assertFalse(
|
||||
impl_idl._is_ovsport_update_valid(
|
||||
'set',
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
ofport=-1,
|
||||
name='tap-uuid',
|
||||
),
|
||||
|
@ -55,7 +55,7 @@ class TestDFIdl(tests_base.BaseTestCase):
|
|||
self.assertFalse(
|
||||
impl_idl._is_ovsport_update_valid(
|
||||
'set',
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
ofport=1,
|
||||
type=constants.SWITCH_PATCH_INTERFACE,
|
||||
name='tap-uuid',
|
||||
|
@ -67,7 +67,7 @@ class TestDFIdl(tests_base.BaseTestCase):
|
|||
self.assertFalse(
|
||||
impl_idl._is_ovsport_update_valid(
|
||||
'set',
|
||||
ovs.OvsPort(
|
||||
switch.SwitchPort(
|
||||
ofport=1,
|
||||
type=constants.SWITCH_COMPUTE_INTERFACE,
|
||||
name='tap-uuid',
|
||||
|
|
Loading…
Reference in New Issue