rdobuilder b024ac
#!/bin/bash
rdobuilder b024ac
rdobuilder b024ac
# Copyright (c) 2011 Alexey I. Froloff.
rdobuilder b024ac
#
rdobuilder b024ac
# Licensed under the Apache License, Version 2.0 (the "License");
rdobuilder b024ac
# you may not use this file except in compliance with the License.
rdobuilder b024ac
# You may obtain a copy of the License at:
rdobuilder b024ac
#
rdobuilder b024ac
#     http://www.apache.org/licenses/LICENSE-2.0
rdobuilder b024ac
#
rdobuilder b024ac
# Unless required by applicable law or agreed to in writing, software
rdobuilder b024ac
# distributed under the License is distributed on an "AS IS" BASIS,
rdobuilder b024ac
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rdobuilder b024ac
# See the License for the specific language governing permissions and
rdobuilder b024ac
# limitations under the License.
rdobuilder b024ac
rdobuilder b024ac
. /etc/init.d/functions
rdobuilder b024ac
rdobuilder b024ac
cd /etc/sysconfig/network-scripts
rdobuilder b024ac
. ./network-functions
rdobuilder b024ac
rdobuilder b024ac
[ -f ../network ] && . ../network
rdobuilder b024ac
rdobuilder b024ac
CONFIG=${1}
rdobuilder b024ac
TIMEOUT=10
rdobuilder b024ac
rdobuilder b024ac
source_config
rdobuilder b024ac
rdobuilder b024ac
. /etc/sysconfig/network
rdobuilder b024ac
rdobuilder b024ac
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${REAL_DEVICETYPE}"
rdobuilder b024ac
rdobuilder b024ac
if [ ! -x ${OTHERSCRIPT} ]; then
rdobuilder b024ac
    OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth"
rdobuilder b024ac
fi
rdobuilder b024ac
rdobuilder b024ac
SERVICE_UNIT=/usr/lib/systemd/system/ovsdb-server.service
rdobuilder b024ac
if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
rdobuilder b024ac
        if ! systemctl --quiet is-active ovsdb-server.service; then
rdobuilder b024ac
                systemctl start ovsdb-server.service
rdobuilder b024ac
        fi
rdobuilder b024ac
else
rdobuilder b024ac
        if [ ! -f /var/lock/subsys/openvswitch ]; then
rdobuilder b024ac
                /sbin/service openvswitch start
rdobuilder b024ac
        fi
rdobuilder b024ac
fi
rdobuilder b024ac
rdobuilder b024ac
case "$TYPE" in
rdobuilder b024ac
        OVSBridge|OVSUserBridge)
rdobuilder b024ac
                ${OTHERSCRIPT} ${CONFIG} $2
rdobuilder b024ac
                retval=$?
rdobuilder b024ac
                ovs-vsctl -t ${TIMEOUT} -- --if-exists del-br "$DEVICE"
rdobuilder b024ac
                ;;
rdobuilder b024ac
        OVSPort|OVSIntPort|OVSBond)
rdobuilder b024ac
                ${OTHERSCRIPT} ${CONFIG} $2
rdobuilder b024ac
                retval=$?
rdobuilder b024ac
                ovs-vsctl -t ${TIMEOUT} -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE"
rdobuilder b024ac
                ;;
rdobuilder b024ac
        OVSPatchPort|OVSTunnel)
rdobuilder b024ac
                ovs-vsctl -t ${TIMEOUT} -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE"
rdobuilder b024ac
                ;;
rdobuilder b024ac
        OVSDPDKPort|OVSDPDKVhostUserPort|OVSDPDKBond)
rdobuilder b024ac
                ovs-vsctl -t ${TIMEOUT} -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE"
rdobuilder b024ac
                ;;
rdobuilder b024ac
        *)
rdobuilder b024ac
                echo $"Invalid OVS interface type $TYPE"
rdobuilder b024ac
                exit 1
rdobuilder b024ac
                ;;
rdobuilder b024ac
esac
rdobuilder b024ac
rdobuilder b024ac
exit $retval