#! /bin/sh
-# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2016 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
[ -z "${bridges}" ] && return 0
}
-save_ofports_if_required () {
- # Save OpenFlow port numbers if we are upgrading from a pre-1.10 branch.
- #
- # (Versions 1.10 and later save OpenFlow port numbers without assistance,
- # so we don't have to do anything for them.
- case `ovs-appctl version | sed 1q` in
- "ovs-vswitchd (Open vSwitch) 1."[0-9].*)
- action "Saving ofport values" ovs_save save-ofports \
- "${script_ofports}"
- ;;
- esac
-}
-
save_flows_if_required () {
if test X"$DELETE_BRIDGES" != Xyes; then
action "Saving flows" ovs_save save-flows "${script_flows}"
> "${script_interfaces}"
}
-restore_ofports () {
- [ -x "${script_ofports}" ] && \
- action "Restoring ofport values" "${script_ofports}"
-}
-
flow_restore_wait () {
ovs_vsctl set open_vswitch . other_config:flow-restore-wait="true"
}
init_restore_scripts () {
script_interfaces=`mktemp`
script_flows=`mktemp`
- script_ofports=`mktemp`
- trap 'rm -f "${script_interfaces}" "${script_flows}" "${script_ofports}"' 0
+ trap 'rm -f "${script_interfaces}" "${script_flows}"' 0
}
force_reload_kmod () {
init_restore_scripts
save_flows_if_required
- save_ofports_if_required
# Restart the database first, since a large database may take a
# while to load, and we want to minimize forwarding disruption.
stop_ovsdb
start_ovsdb
- # Restore of ofports should happen before vswitchd is restarted.
- restore_ofports
-
stop_forwarding
if action "Saving interface configuration" save_interfaces; then
## restart ##
## ------- ##
-save_interfaces_if_required () {
- # Save interfaces if we are upgrading from a pre-1.10 branch.
- case `ovs-appctl version | sed 1q` in
- "ovs-vswitchd (Open vSwitch) 1."[0-9].*)
- ifaces=`internal_interfaces`
- action "Detected internal interfaces: $ifaces" true
- if action "Saving interface configuration" save_interfaces; then
- chmod +x "$script_interfaces"
- fi
- ;;
- esac
-}
-
restart () {
if daemon_is_running ovsdb-server && daemon_is_running ovs-vswitchd; then
init_restore_scripts
- save_interfaces_if_required
save_flows_if_required
- save_ofports_if_required
fi
# Restart the database first, since a large database may take a
stop_ovsdb
start_ovsdb
- # Restore of ofports, if required, should happen before vswitchd is
- # restarted.
- restore_ofports
-
stop_forwarding
# Start vswitchd by asking it to wait till flow restore is finished.
#! /bin/sh
-# Copyright (c) 2011, 2013 Nicira, Inc.
+# Copyright (c) 2011, 2013, 2016 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
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
}
done
}
-ovs_vsctl () {
- ovs-vsctl --no-wait "$@"
-}
-
-save_ofports ()
-{
- if (ovs-vsctl --version) > /dev/null 2>&1; then :; else
- 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"
- 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
case $1 in
save_interfaces "$@"
exit 0
;;
- "save-ofports")
- shift
- save_ofports "$@"
- exit 0
- ;;
-h | --help)
usage
exit 0