summaryrefslogtreecommitdiffstats
path: root/vswitches/ovs_vanilla.py
diff options
context:
space:
mode:
Diffstat (limited to 'vswitches/ovs_vanilla.py')
-rw-r--r--vswitches/ovs_vanilla.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/vswitches/ovs_vanilla.py b/vswitches/ovs_vanilla.py
index 6a380b1b..89023a79 100644
--- a/vswitches/ovs_vanilla.py
+++ b/vswitches/ovs_vanilla.py
@@ -18,7 +18,7 @@
import logging
from conf import settings
from vswitches.ovs import IVSwitchOvs
-from src.ovs import VSwitchd, DPCtl
+from src.ovs import DPCtl
from tools.module_manager import ModuleManager
from tools import tasks
@@ -32,18 +32,16 @@ class OvsVanilla(IVSwitchOvs):
see the interface definition.
"""
- _ports = settings.getValue('VSWITCH_VANILLA_PHY_PORT_NAMES')
_current_id = 0
_vport_id = 0
def __init__(self):
super(OvsVanilla, self).__init__()
+ self._ports = list(nic['device'] for nic in settings.getValue('NICS'))
self._logger = logging.getLogger(__name__)
- self._vswitchd_args = ["unix:%s" % VSwitchd.get_db_sock_path()]
+ self._vswitchd_args += ["unix:%s" % self.get_db_sock_path()]
self._vswitchd_args += settings.getValue('VSWITCHD_VANILLA_ARGS')
- self._vswitchd = VSwitchd(vswitchd_args=self._vswitchd_args,
- expected_cmd="db.sock: connected")
- self._bridges = {}
+ self._expect = "db.sock: connected"
self._module_manager = ModuleManager()
def start(self):
@@ -77,8 +75,7 @@ class OvsVanilla(IVSwitchOvs):
def add_phy_port(self, switch_name):
"""
- Method adds port based on configured VSWITCH_VANILLA_PHY_PORT_NAMES
- stored in config file.
+ Method adds port based on detected device names.
See IVswitch for general description
"""
@@ -89,16 +86,18 @@ class OvsVanilla(IVSwitchOvs):
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")
+ self._logger.error("Can't detect device name for NIC %s", self._current_id)
+ raise ValueError("Invalid device name for %s" % self._current_id)
bridge = self._bridges[switch_name]
port_name = self._ports[self._current_id]
params = []
# For PVP only
- tasks.run_task(['sudo', 'ifconfig', port_name, '0'],
+ tasks.run_task(['sudo', 'ip', 'addr', 'flush', 'dev', port_name],
self._logger, 'Remove IP', False)
+ tasks.run_task(['sudo', 'ip', 'link', 'set', 'dev', port_name, 'up'],
+ self._logger, 'Bring up ' + port_name, False)
of_port = bridge.add_port(port_name, params)
self._current_id += 1
@@ -122,7 +121,9 @@ class OvsVanilla(IVSwitchOvs):
tap_name, 'mode', 'tap'],
self._logger, 'Creating tap device...', False)
- tasks.run_task(['sudo', 'ifconfig', tap_name, '0'],
+ tasks.run_task(['sudo', 'ip', 'addr', 'flush', 'dev', tap_name],
+ self._logger, 'Remove IP', False)
+ tasks.run_task(['sudo', 'ip', 'link', 'set', 'dev', tap_name, 'up'],
self._logger, 'Bring up ' + tap_name, False)
bridge = self._bridges[switch_name]