diff options
author | Gurucharan Shetty <gshetty@nicira.com> | 2013-01-11 13:01:55 -0800 |
---|---|---|
committer | Gurucharan Shetty <gshetty@nicira.com> | 2013-01-16 13:39:38 -0800 |
commit | 1eccfa36c1ab36e2120a527ca95ca7ef4bce39fc (patch) | |
tree | b935552c5a465365b93120c6d2a38cc55833c222 /utilities | |
parent | e99d41f787d7d81b10a5c480f3174d68c7cc7e99 (diff) |
ovs-save: Add a helper command to maintain ofport value.
This patch adds a helper command: save-ofports. The command
will o/p a shell script that will set the 'ofport_request' column
of the interface table with the value of the corresponding ofport.
This command takes a list of bridges as input and will be used by
a future commit to restore the ofport value across force-reload-kmod.
This command is only useful while trying to upgrade from a pre-1.10
branch to 1.10 or a later branch.
Issue #13556
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Diffstat (limited to 'utilities')
-rwxr-xr-x | utilities/ovs-save | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/utilities/ovs-save b/utilities/ovs-save index 2ab9d086..16ac8798 100755 --- a/utilities/ovs-save +++ b/utilities/ovs-save @@ -27,6 +27,8 @@ Commands: configuration. save-flows Outputs a shell script on stdout that will restore Openflow flows of each Open vSwitch bridge. + save-ofports Outputs a shell script on stdout that will restore + the ofport value across a force-reload-kmod. This script is meant as a helper for the Open vSwitch init script commands. EOF } @@ -174,6 +176,32 @@ save_flows () { done } +ovs_vsctl () { + ovs-vsctl --no-wait --timeout=1 "$@" +} + +save_ofports () +{ + if missing_program ovs-vsctl; then + echo "$0: ovs-vsctl not found in $PATH" >&2 + exit 1 + fi + + for bridge in "$@"; do + count=0 + for iface in `ovs_vsctl list-ifaces ${bridge}`; do + ofport=`ovs_vsctl get interface ${iface} ofport` + [ "${count}" -eq 0 ] && cmd="ovs-vsctl --no-wait --timeout=1" + cmd="${cmd} -- --if-exists set interface "${iface}" \ + ofport_request="${ofport}"" + + # Run set interface command on 50 ports at a time. + count=`expr ${count} + 1` + [ "${count}" -eq 50 ] && count=0 && echo "${cmd}" && cmd="" + done + echo "${cmd}" + done +} while [ $# -ne 0 ] do @@ -188,6 +216,11 @@ do save_interfaces "$@" exit 0 ;; + "save-ofports") + shift + save_ofports "$@" + exit 0 + ;; -h | --help) usage exit 0 |