summaryrefslogtreecommitdiffstats
path: root/vswitches
diff options
context:
space:
mode:
Diffstat (limited to 'vswitches')
-rw-r--r--vswitches/ovs.py27
-rw-r--r--vswitches/ovs_dpdk_vhost.py2
-rw-r--r--vswitches/vswitch.py7
3 files changed, 35 insertions, 1 deletions
diff --git a/vswitches/ovs.py b/vswitches/ovs.py
index 7e16c142..76cabb0d 100644
--- a/vswitches/ovs.py
+++ b/vswitches/ovs.py
@@ -91,6 +91,27 @@ class IVSwitchOvs(IVSwitch, tasks.Process):
self._logger.info("Vswitchd...Started.")
+ def restart(self):
+ """ Restart ``ovs-vswitchd`` instance. ``ovsdb-server`` is not restarted.
+
+ :raises: pexpect.EOF, pexpect.TIMEOUT
+ """
+ self._logger.info("Restarting vswitchd...")
+ if os.path.isfile(self._vswitchd_pidfile_path):
+ self._logger.info('Killing ovs-vswitchd...')
+ with open(self._vswitchd_pidfile_path, "r") as pidfile:
+ vswitchd_pid = pidfile.read().strip()
+ tasks.terminate_task(vswitchd_pid, logger=self._logger)
+
+ try:
+ tasks.Process.start(self)
+ self.relinquish()
+ except (pexpect.EOF, pexpect.TIMEOUT) as exc:
+ logging.error("Exception during VSwitch start.")
+ self._kill_ovsdb()
+ raise exc
+ self._logger.info("Vswitchd...Started.")
+
def configure(self):
""" Configure vswitchd through ovsdb if needed
"""
@@ -109,6 +130,7 @@ class IVSwitchOvs(IVSwitch, tasks.Process):
"""
self._logger.info("Terminating vswitchd...")
self.kill()
+ self._bridges = {}
self._logger.info("Vswitchd...Terminated.")
def add_switch(self, switch_name, params=None):
@@ -488,3 +510,8 @@ class IVSwitchOvs(IVSwitch, tasks.Process):
"""
bridge = self._bridges[switch_name]
return 'stp_enable : true' in ''.join(bridge.bridge_info())
+
+ def validate_restart(self, dummy_result):
+ """ Validate restart
+ """
+ return True
diff --git a/vswitches/ovs_dpdk_vhost.py b/vswitches/ovs_dpdk_vhost.py
index 3b20be35..11b32c88 100644
--- a/vswitches/ovs_dpdk_vhost.py
+++ b/vswitches/ovs_dpdk_vhost.py
@@ -149,7 +149,7 @@ class OvsDpdkVhost(IVSwitchOvs):
nic_type = 'dpdkvhostuserclient'
vhost_count = self._get_port_count('type={}'.format(nic_type))
- port_name = 'dpdkvhostuser' + str(vhost_count)
+ port_name = nic_type + str(vhost_count)
params = ['--', 'set', 'Interface', port_name, 'type={}'.format(nic_type)]
if not S.getValue('VSWITCH_VHOSTUSER_SERVER_MODE'):
params += ['--', 'set', 'Interface', port_name, 'options:vhost-server-path='
diff --git a/vswitches/vswitch.py b/vswitches/vswitch.py
index dd69e6d9..efa3a349 100644
--- a/vswitches/vswitch.py
+++ b/vswitches/vswitch.py
@@ -36,6 +36,13 @@ class IVSwitch(object):
"""
raise NotImplementedError()
+ def restart(self):
+ """Retart the vSwitch
+
+ Restart of vSwitch is required for failover testcases.
+ """
+ raise NotImplementedError()
+
def stop(self):
"""Stop the vSwitch