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
This commit is contained in:
Shachar Snapiri 2018-07-19 13:24:17 +03:00
parent 7d9ebea601
commit 8114ddbf8a
8 changed files with 39 additions and 39 deletions

View File

@ -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"

View File

@ -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",

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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',
)

View File

@ -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)

View File

@ -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',
),
),