ansible-ovs-ovn/templates/ovsovn-service-manager.sh.j2

64 lines
1.8 KiB
Django/Jinja

#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit 1
fi
echo "Command recieved: $1"
START(){
hostname=$(hostname)
loopbackIP={{host_loopback_IP}}
DIR="/var/run/openvswitch/db.sock"
if [ -d "$DIR" ]; then
rm -rf $DIR
echo "Removed extraneous dir $DIR"
fi
/usr/share/openvswitch/scripts/ovs-ctl start --system-id=$hostname
echo "OVS started"
#Instruct OVSDB to listen on 127.0.0.2:6640 so the ovs-vsctl command from within a container can access OpenVswitch
ovs-appctl -t ovsdb-server ovsdb-server/add-remote ptcp:6640
#ovs-vsctl del-br br-int
{% if use_ovn is defined and use_ovn == true %}
echo "Starting OpenVSwitch and OVN on $hostname with $loopbackIP and pointing to OVN controller {{OVN_SB_Connection}}"
ovs-vsctl set open . external-ids:ovn-bridge=br-int
ovs-vsctl set open . external-ids:ovn-remote={{OVN_SB_Connection}}
ovs-vsctl set open . external-ids:ovn-encap-type=geneve
ovs-vsctl set open . external-ids:ovn-encap-ip=$loopbackIP
/usr/share/ovn/scripts/ovn-ctl start_controller
echo "OVS and OVN started"
{% else %}
{% endif %}
{% if ansible_fqdn in groups['compute_nodes'] %}
echo "Bringing online br-provider for WAN1"
ovs-vsctl --may-exist add-br br-provider
ovs-vsctl set open . external-ids:ovn-bridge-mappings=WAN1:br-provider
ovs-vsctl --may-exist add-port br-provider bond0.11
{% endif %}
}
STOP() {
{% if use_ovn is defined and use_ovn == true %}
echo "Stopping OVN"
/usr/share/ovn/scripts/ovn-ctl stop_controller
/usr/share/ovn/scripts/ovn-ctl stop_ovsdb
echo "OpenVSwitch and OVN Stopped"
{% else %}
echo "Stopping OpenVSwitch"
/usr/share/openvswitch/scripts/ovs-ctl stop
echo "OpenVSwitch Stopped"
{% endif %}
}
case $1 in
START|STOP) "$1" ;;
esac