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

53 lines
1.6 KiB
Plaintext
Raw Normal View History

2020-07-30 07:38:37 +00:00
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit 1
fi
echo "ZZZ $1"
START(){
hostname=$(hostname)
2020-11-08 04:10:15 +00:00
loopbackIP={{host_loopback_IP}}
2020-11-23 04:16:52 +00:00
echo "Starting OpenVSwitch and OVN on $hostname with $loopbackIP and pointing to OVN controller {{OVN_SB_Connection}}"
2020-07-30 07:38:37 +00:00
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
#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
2020-11-25 02:29:35 +00:00
ovs-vsctl del-br br-int
2020-07-30 07:38:37 +00:00
ovs-vsctl set open . external-ids:ovn-bridge=br-int
2020-11-23 04:16:52 +00:00
ovs-vsctl set open . external-ids:ovn-remote={{OVN_SB_Connection}}
2020-07-30 07:38:37 +00:00
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"
2020-09-04 13:31:32 +00:00
{% if ansible_fqdn in groups['compute_nodes'] %}
2020-07-30 07:38:37 +00:00
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() {
echo "Stopping OpenVSwitch and OVN"
/usr/share/ovn/scripts/ovn-ctl stop_controller
/usr/share/ovn/scripts/ovn-ctl stop_ovsdb
/usr/share/openvswitch/scripts/ovs-ctl stop
echo "OpenVSwitch and OVN Stopped"
}
case $1 in
START|STOP) "$1" ;;
esac