2020-07-30 07:38:37 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
|
|
echo "Illegal number of parameters"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-11-30 13:28:33 +00:00
|
|
|
echo "Command recieved: $1"
|
2020-07-30 07:38:37 +00:00
|
|
|
|
|
|
|
START(){
|
|
|
|
hostname=$(hostname)
|
2020-11-08 04:10:15 +00:00
|
|
|
loopbackIP={{host_loopback_IP}}
|
2020-11-23 04:16:52 +00:00
|
|
|
|
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
|
2020-11-30 13:28:33 +00:00
|
|
|
echo "OVS started"
|
2020-07-30 07:38:37 +00:00
|
|
|
#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-30 00:43:21 +00:00
|
|
|
#ovs-vsctl del-br br-int
|
|
|
|
|
2020-11-30 13:28:33 +00:00
|
|
|
{% 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}}"
|
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-11-30 13:28:33 +00:00
|
|
|
{% else %}
|
|
|
|
|
|
|
|
|
|
|
|
{% endif %}
|
2020-07-30 07:38:37 +00:00
|
|
|
|
2020-12-04 01:54:21 +00:00
|
|
|
{% if ansible_fqdn in groups['br_provider_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() {
|
2020-11-30 13:28:33 +00:00
|
|
|
{% if use_ovn is defined and use_ovn == true %}
|
|
|
|
echo "Stopping OVN"
|
2020-07-30 07:38:37 +00:00
|
|
|
/usr/share/ovn/scripts/ovn-ctl stop_controller
|
|
|
|
/usr/share/ovn/scripts/ovn-ctl stop_ovsdb
|
|
|
|
echo "OpenVSwitch and OVN Stopped"
|
2020-11-30 13:28:33 +00:00
|
|
|
{% else %}
|
|
|
|
echo "Stopping OpenVSwitch"
|
|
|
|
/usr/share/openvswitch/scripts/ovs-ctl stop
|
|
|
|
echo "OpenVSwitch Stopped"
|
|
|
|
{% endif %}
|
2020-07-30 07:38:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
START|STOP) "$1" ;;
|
|
|
|
esac
|