From 54b21db7235d51b75a45a477d57daa06cb9ffe55 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Tue, 1 Sep 2015 17:56:09 -0300 Subject: [PATCH] ovs-ctl: Add option to delete transient ports. When using virtualization, new ports are created and removed all the time. These ports do not persist after a system reboot, for example. They may be created again by the virtualization manager, but that will happen after the vswitch is already running, and the virtualization manager will add them again to the bridge. If a reboot happens without properly deleting such ports, all kinds of errors will happen. The absence of the ports will be logged as errors, and adding those ports again to the database will fail. Deleting all bridges may not be an option, if the system cannot persist other information outside of OVSDB. This patch introduces the notion of transient ports. Ports may be added as transient, as a boolean in other_config smap. When openvswitch is started by using --delete-transient-ports ovs-ctl option, all transient ports will be removed. Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Ben Pfaff --- utilities/ovs-ctl.8 | 11 ++++++++++- utilities/ovs-ctl.in | 10 ++++++++++ vswitchd/vswitch.xml | 8 ++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8 index c08c7db4e..6a9a544ca 100644 --- a/utilities/ovs-ctl.8 +++ b/utilities/ovs-ctl.8 @@ -90,10 +90,14 @@ Initializes a few values inside the database. If the \fB\-\-delete\-bridges\fR option was used, deletes all of the bridges from the database. . +.IP 6. +If the \fB\-\-delete\-transient\-ports\fR option was used, deletes all ports +that have \fBother_config:transient\fR set to true. +. .PP The \fBstart\fR command skips the following step if \fBovs\-vswitchd\fR is already running: -.IP 6. +.IP 7. Starts \fBovs\-vswitchd\fR. . .SS "Options" @@ -148,6 +152,11 @@ on every boot. This option supports that, by deleting all Open vSwitch bridges after starting \fBovsdb\-server\fR but before starting \fBovs\-vswitchd\fR. . +.IP "\fB\-\-delete\-transient\-ports\fR" +Deletes all ports that have the other_config:transient value set to true. This +is important on certain environments where some ports are going to be recreated +after reboot, but other ports need to be persisted in the database. +. .PP The following options are less important: . diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index 9bbbe0d58..bca8c5623 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -177,6 +177,12 @@ check_force_cores () { fi } +del_transient_ports () { + for port in `ovs-vsctl --bare -- --columns=name find port other_config:transient=true`; do + ovs_vsctl -- del-port "$port" + done +} + start_ovsdb () { check_force_cores @@ -219,6 +225,9 @@ start_ovsdb () { ovs_vsctl del-br $bridge done fi + if test X"$DELETE_TRANSIENT_PORTS" = Xyes; then + del_transient_ports + fi fi } @@ -536,6 +545,7 @@ set_defaults () { SYSTEM_ID= DELETE_BRIDGES=no + DELETE_TRANSIENT_PORTS=no DAEMON_CWD=/ FORCE_COREFILES=yes diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 457f34a66..0ab4a9a30 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -1659,6 +1659,14 @@ fake-bridge-, e.g. fake-bridge-xs-network-uuids. + + +

+ If set to true, the port will be removed when + ovs-ctl start --delete-transient-ports is used. +

+
-- 2.20.1