aboutsummaryrefslogtreecommitdiffstats
path: root/vswitches
diff options
context:
space:
mode:
Diffstat (limited to 'vswitches')
-rw-r--r--vswitches/ovs_dpdk_vhost.py6
-rw-r--r--vswitches/ovs_vanilla.py53
-rw-r--r--vswitches/vswitch.py7
3 files changed, 64 insertions, 2 deletions
diff --git a/vswitches/ovs_dpdk_vhost.py b/vswitches/ovs_dpdk_vhost.py
index 1a53bd6d..874cc97b 100644
--- a/vswitches/ovs_dpdk_vhost.py
+++ b/vswitches/ovs_dpdk_vhost.py
@@ -158,6 +158,12 @@ class OvsDpdkVhost(IVSwitch):
bridge = self._bridges[switch_name]
bridge.del_flow(flow)
+ def dump_flows(self, switch_name):
+ """See IVswitch for general description
+ """
+ bridge = self._bridges[switch_name]
+ bridge.dump_flows()
+
@staticmethod
def _get_port_count(bridge, param):
"""Returns the number of ports having a certain parameter
diff --git a/vswitches/ovs_vanilla.py b/vswitches/ovs_vanilla.py
index a7d4d206..6716401d 100644
--- a/vswitches/ovs_vanilla.py
+++ b/vswitches/ovs_vanilla.py
@@ -20,7 +20,9 @@ from conf import settings
from vswitches.vswitch import IVSwitch
from src.ovs import VSwitchd, OFBridge
from tools.module_manager import ModuleManager, KernelModuleInsertMode
+from tools import tasks
+_LOGGER = logging.getLogger(__name__)
VSWITCHD_CONST_ARGS = ['--', '--log-file']
class OvsVanilla(IVSwitch):
@@ -36,6 +38,7 @@ class OvsVanilla(IVSwitch):
_logger = logging.getLogger()
_ports = settings.getValue('VSWITCH_VANILLA_PHY_PORT_NAMES')
_current_id = 0
+ _vport_id = 0
def __init__(self):
#vswitchd_args = VSWITCHD_CONST_ARGS
@@ -62,9 +65,18 @@ class OvsVanilla(IVSwitch):
Kills ovsdb and vswitchd and removes kernel modules.
"""
+ # remove all tap interfaces
+ for i in range(self._vport_id):
+ tapx = 'tap' + str(i)
+ tasks.run_task(['sudo', 'ip', 'tuntap', 'del',
+ tapx, 'mode', 'tap'],
+ _LOGGER, 'Deleting ' + tapx, False)
+ self._vport_id = 0
+
self._vswitchd.kill()
self._module_manager.remove_modules()
+
def add_switch(self, switch_name):
"""See IVswitch for general description
"""
@@ -94,16 +106,47 @@ class OvsVanilla(IVSwitch):
"defined in config!")
raise
+ if not self._ports[self._current_id]:
+ self._logger.error("VSWITCH_VANILLA_PHY_PORT_NAMES not set")
+ raise ValueError("Invalid VSWITCH_VANILLA_PHY_PORT_NAMES")
+
bridge = self._bridges[switch_name]
port_name = self._ports[self._current_id]
params = []
+
+ # For PVP only
+ tasks.run_task(['sudo', 'ifconfig', port_name, '0'],
+ _LOGGER, 'Remove IP', False)
+
of_port = bridge.add_port(port_name, params)
self._current_id += 1
return (port_name, of_port)
def add_vport(self, switch_name):
- """See IVswitch for general description"""
- raise NotImplementedError("Not implemented for Vanilla OVS.")
+ """
+ Method adds virtual port into OVS vanilla
+
+ See IVswitch for general description
+ """
+ # Create tap devices for the VM
+ tap_name = 'tap' + str(self._vport_id)
+ self._vport_id += 1
+
+ tasks.run_task(['sudo', 'ip', 'tuntap', 'del',
+ tap_name, 'mode', 'tap'],
+ _LOGGER, 'Creating tap device...', False)
+
+ tasks.run_task(['sudo', 'ip', 'tuntap', 'add',
+ tap_name, 'mode', 'tap'],
+ _LOGGER, 'Creating tap device...', False)
+
+ tasks.run_task(['sudo', 'ifconfig', tap_name, '0'],
+ _LOGGER, 'Bring up ' + tap_name, False)
+
+ bridge = self._bridges[switch_name]
+ of_port = bridge.add_port(tap_name, [])
+ return (tap_name, of_port)
+
def get_ports(self, switch_name):
"""See IVswitch for general description
@@ -130,3 +173,9 @@ class OvsVanilla(IVSwitch):
flow = flow or {}
bridge = self._bridges[switch_name]
bridge.del_flow(flow)
+
+ def dump_flows(self, switch_name):
+ """See IVswitch for general description
+ """
+ bridge = self._bridges[switch_name]
+ bridge.dump_flows()
diff --git a/vswitches/vswitch.py b/vswitches/vswitch.py
index 713974ae..dbf3e7d5 100644
--- a/vswitches/vswitch.py
+++ b/vswitches/vswitch.py
@@ -112,3 +112,10 @@ class IVSwitch(object):
For flow==None, all flows are deleted
"""
raise NotImplementedError()
+
+ def dump_flows(self, switch_name):
+ """Dump flows from the logical switch
+
+ :param switch_name: The switch on which to operate
+ """
+ raise NotImplementedError()