From 8114ddbf8a7c3082347896a09b6a8e799b5d3b3a Mon Sep 17 00:00:00 2001 From: Shachar Snapiri Date: Thu, 19 Jul 2018 13:24:17 +0300 Subject: [PATCH] Rename OVS INTERFACE constants to PORT INTERFACE These constants are generic and are relevant to any switch backend we will use. The current name is probably because of historical reasons. Change-Id: I15ce23580daba0c3b2682d9bf0233b9298b1e642 Partial-Bug: #1781376 --- dragonflow/common/constants.py | 10 ++++---- dragonflow/controller/topology.py | 22 ++++++++--------- dragonflow/db/models/ovs.py | 24 +++++++++---------- dragonflow/ovsdb/impl_idl.py | 8 +++---- .../tests/fullstack/test_ovsdb_monitor.py | 4 ++-- dragonflow/tests/unit/test_app_base.py | 4 ++-- dragonflow/tests/unit/test_classifier_app.py | 2 +- dragonflow/tests/unit/test_ovsdb_monitor.py | 4 ++-- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/dragonflow/common/constants.py b/dragonflow/common/constants.py index 99cc1dca1..e8d341867 100644 --- a/dragonflow/common/constants.py +++ b/dragonflow/common/constants.py @@ -12,11 +12,11 @@ # limitations under the License. from neutron_lib import constants as n_const -OVS_COMPUTE_INTERFACE = "compute" -OVS_BRIDGE_INTERFACE = "bridge" -OVS_PATCH_INTERFACE = "patch" -OVS_TUNNEL_INTERFACE = "tunnel" -OVS_UNKNOWN_INTERFACE = "unknown" +SWITCH_COMPUTE_INTERFACE = "compute" +SWITCH_BRIDGE_INTERFACE = "bridge" +SWITCH_PATCH_INTERFACE = "patch" +SWITCH_TUNNEL_INTERFACE = "tunnel" +SWITCH_UNKNOWN_INTERFACE = "unknown" DHCP_SIADDR = "siaddr" diff --git a/dragonflow/controller/topology.py b/dragonflow/controller/topology.py index cf30c1988..eb6d0a7da 100644 --- a/dragonflow/controller/topology.py +++ b/dragonflow/controller/topology.py @@ -30,8 +30,8 @@ LOG = log.getLogger(__name__) OvsLportMapping = collections.namedtuple('OvsLportMapping', ('lport_id', 'topic')) -_OVS_PORT_TYPES = (constants.OVS_COMPUTE_INTERFACE, - constants.OVS_TUNNEL_INTERFACE) +_SWITCH_PORT_TYPES = (constants.SWITCH_COMPUTE_INTERFACE, + constants.SWITCH_TUNNEL_INTERFACE) class Topology(object): @@ -65,7 +65,7 @@ class Topology(object): """ LOG.info("Ovs port updated: %s", ovs_port) - if ovs_port.type not in _OVS_PORT_TYPES: + if ovs_port.type not in _SWITCH_PORT_TYPES: LOG.info("Unmanaged port online: %s", ovs_port) return @@ -80,18 +80,18 @@ class Topology(object): def _handle_ovs_port_added(self, ovs_port): port_type = ovs_port.type - if port_type == constants.OVS_COMPUTE_INTERFACE: + if port_type == constants.SWITCH_COMPUTE_INTERFACE: self._compute_port_added(ovs_port) - elif port_type == constants.OVS_TUNNEL_INTERFACE: + elif port_type == constants.SWITCH_TUNNEL_INTERFACE: self._tunnel_port_added(ovs_port) else: LOG.warning('Invalid port type on %r', ovs_port) def _handle_ovs_port_updated(self, ovs_port): port_type = ovs_port.type - if port_type == constants.OVS_COMPUTE_INTERFACE: + if port_type == constants.SWITCH_COMPUTE_INTERFACE: self._compute_port_updated(ovs_port) - elif port_type == constants.OVS_TUNNEL_INTERFACE: + elif port_type == constants.SWITCH_TUNNEL_INTERFACE: self._tunnel_port_updated(ovs_port) else: LOG.warning('Invalid port type on %r', ovs_port) @@ -105,7 +105,7 @@ class Topology(object): @param ovs_port: @return : None """ - if ovs_port.type not in _OVS_PORT_TYPES: + if ovs_port.type not in _SWITCH_PORT_TYPES: LOG.info("Unmanaged port offline: %s", ovs_port) return @@ -117,9 +117,9 @@ class Topology(object): def _handle_ovs_port_deleted(self, ovs_port): port_type = ovs_port.type - if port_type == constants.OVS_COMPUTE_INTERFACE: + if port_type == constants.SWITCH_COMPUTE_INTERFACE: self._compute_port_deleted(ovs_port) - elif port_type == constants.OVS_TUNNEL_INTERFACE: + elif port_type == constants.SWITCH_TUNNEL_INTERFACE: self._tunnel_port_deleted(ovs_port) else: LOG.warning('Invalid port type on %r', ovs_port) @@ -291,7 +291,7 @@ class Topology(object): delete_ovs_to_lport_mapping = self.ovs_to_lport_mapping for ovs_port in self.db_store.get_all(ovs.OvsPort): key = ovs_port.id - if ovs_port.type == constants.OVS_COMPUTE_INTERFACE: + if ovs_port.type == constants.SWITCH_COMPUTE_INTERFACE: lport = self._get_lport(ovs_port) if lport is None: LOG.warning("No logical port found for ovs port: %s", diff --git a/dragonflow/db/models/ovs.py b/dragonflow/db/models/ovs.py index c5303dbb3..3e2a3d219 100644 --- a/dragonflow/db/models/ovs.py +++ b/dragonflow/db/models/ovs.py @@ -23,19 +23,19 @@ def _get_interface_type(row): interface_name = row.name if interface_type == "internal" and "br" in interface_name: - return constants.OVS_BRIDGE_INTERFACE + return constants.SWITCH_BRIDGE_INTERFACE if interface_type == "patch": - return constants.OVS_PATCH_INTERFACE + return constants.SWITCH_PATCH_INTERFACE if 'iface-id' in row.external_ids: - return constants.OVS_COMPUTE_INTERFACE + return constants.SWITCH_COMPUTE_INTERFACE options = row.options if 'remote_ip' in options: - return constants.OVS_TUNNEL_INTERFACE + return constants.SWITCH_TUNNEL_INTERFACE - return constants.OVS_UNKNOWN_INTERFACE + return constants.SWITCH_UNKNOWN_INTERFACE @mf.register_model @@ -48,11 +48,11 @@ class OvsPort(mf.ModelBase, mixins.BasicEvents, mixins.Name): lport = df_fields.ReferenceField(l2.LogicalPort) type = df_fields.EnumField( ( - constants.OVS_BRIDGE_INTERFACE, - constants.OVS_PATCH_INTERFACE, - constants.OVS_COMPUTE_INTERFACE, - constants.OVS_TUNNEL_INTERFACE, - constants.OVS_UNKNOWN_INTERFACE, + constants.SWITCH_BRIDGE_INTERFACE, + constants.SWITCH_PATCH_INTERFACE, + constants.SWITCH_COMPUTE_INTERFACE, + constants.SWITCH_TUNNEL_INTERFACE, + constants.SWITCH_UNKNOWN_INTERFACE, ), ) peer = fields.StringField() @@ -76,10 +76,10 @@ class OvsPort(mf.ModelBase, mixins.BasicEvents, mixins.Name): if row.admin_state: res.admin_state = row.admin_state[0] - if res.type == constants.OVS_PATCH_INTERFACE: + if res.type == constants.SWITCH_PATCH_INTERFACE: res.peer = row.options['peer'] - if res.type == constants.OVS_TUNNEL_INTERFACE: + if res.type == constants.SWITCH_TUNNEL_INTERFACE: res.tunnel_type = row.type external_ids = row.external_ids diff --git a/dragonflow/ovsdb/impl_idl.py b/dragonflow/ovsdb/impl_idl.py index 7fd3ff00d..4d852e3fb 100644 --- a/dragonflow/ovsdb/impl_idl.py +++ b/dragonflow/ovsdb/impl_idl.py @@ -66,9 +66,9 @@ ovsdb_monitor_table_filter_default = { } _HANDLED_INTERFACE_TYPES = ( - constants.OVS_COMPUTE_INTERFACE, - constants.OVS_TUNNEL_INTERFACE, - constants.OVS_BRIDGE_INTERFACE, + constants.SWITCH_COMPUTE_INTERFACE, + constants.SWITCH_TUNNEL_INTERFACE, + constants.SWITCH_BRIDGE_INTERFACE, ) @@ -82,7 +82,7 @@ def _is_ovsport_update_valid(action, ovsport): if ovsport.name.startswith('qg'): return False - if (ovsport.type == constants.OVS_COMPUTE_INTERFACE and + if (ovsport.type == constants.SWITCH_COMPUTE_INTERFACE and ovsport.lport is None): return False diff --git a/dragonflow/tests/fullstack/test_ovsdb_monitor.py b/dragonflow/tests/fullstack/test_ovsdb_monitor.py index 1335eeeb5..33e4dc368 100644 --- a/dragonflow/tests/fullstack/test_ovsdb_monitor.py +++ b/dragonflow/tests/fullstack/test_ovsdb_monitor.py @@ -35,7 +35,7 @@ class TestOvsdbMonitor(test_base.DFTestBase): _interface = ovs.OvsPort.from_json(update.value) if str(_interface.attached_mac) != mac: return False - elif _interface.type != constants.OVS_COMPUTE_INTERFACE: + elif _interface.type != constants.SWITCH_COMPUTE_INTERFACE: return False elif _interface.lport is None: return False @@ -56,7 +56,7 @@ class TestOvsdbMonitor(test_base.DFTestBase): return False elif str(_interface.attached_mac) != mac: return False - elif _interface.type != constants.OVS_COMPUTE_INTERFACE: + elif _interface.type != constants.SWITCH_COMPUTE_INTERFACE: return False elif _interface.lport is None: return False diff --git a/dragonflow/tests/unit/test_app_base.py b/dragonflow/tests/unit/test_app_base.py index 3aba1a508..3c32c4457 100644 --- a/dragonflow/tests/unit/test_app_base.py +++ b/dragonflow/tests/unit/test_app_base.py @@ -295,7 +295,7 @@ fake_ovs_port1 = ovs.OvsPort( ofport=2, name='tap-fake_port1', admin_state='up', - type=constants.OVS_COMPUTE_INTERFACE, + type=constants.SWITCH_COMPUTE_INTERFACE, lport='fake_port1', attached_mac='fa:16:3e:8c:2e:b3', ) @@ -313,7 +313,7 @@ fake_ovs_port2 = ovs.OvsPort( ofport=3, name='tap-fake_port2', admin_state='up', - type=constants.OVS_COMPUTE_INTERFACE, + type=constants.SWITCH_COMPUTE_INTERFACE, lport='fake_port2', attached_mac='fa:16:3e:8c:2e:b4', ) diff --git a/dragonflow/tests/unit/test_classifier_app.py b/dragonflow/tests/unit/test_classifier_app.py index 8f97d1e12..6afbff09d 100644 --- a/dragonflow/tests/unit/test_classifier_app.py +++ b/dragonflow/tests/unit/test_classifier_app.py @@ -61,7 +61,7 @@ class TestClassifierAppForVlan(testscenarios.WithScenarios, ovs_port = ovs.OvsPort(id='fake_ovs_port', lport=fake_local_vlan_port.id, ofport=1, admin_state='up', - type=constants.OVS_COMPUTE_INTERFACE) + 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) diff --git a/dragonflow/tests/unit/test_ovsdb_monitor.py b/dragonflow/tests/unit/test_ovsdb_monitor.py index 2a6095982..51b10a60b 100644 --- a/dragonflow/tests/unit/test_ovsdb_monitor.py +++ b/dragonflow/tests/unit/test_ovsdb_monitor.py @@ -57,7 +57,7 @@ class TestDFIdl(tests_base.BaseTestCase): 'set', ovs.OvsPort( ofport=1, - type=constants.OVS_PATCH_INTERFACE, + type=constants.SWITCH_PATCH_INTERFACE, name='tap-uuid', ), ), @@ -69,7 +69,7 @@ class TestDFIdl(tests_base.BaseTestCase): 'set', ovs.OvsPort( ofport=1, - type=constants.OVS_COMPUTE_INTERFACE, + type=constants.SWITCH_COMPUTE_INTERFACE, name='tap-uuid', ), ),