Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure ovs logging directory created before start service #1028

Merged
merged 1 commit into from
Oct 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 37 additions & 16 deletions scripts/netContain/scripts/ovsInit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,52 @@ set -euo pipefail
modprobe openvswitch

mkdir -p /var/run/openvswitch
mkdir -p /var/contiv/log/

sleep 2

if [ -d "/etc/openvswitch" ]; then
if [ -f "/etc/openvswitch/conf.db" ]; then
echo "The Open vSwitch database exists"
else
echo "The Open VSwitch database doesn't exist"
echo "Creating the Open VSwitch database..."
ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
fi
if [ -f "/etc/openvswitch/conf.db" ]; then
echo "INFO: The Open vSwitch database exists"
else
echo "INFO: The Open VSwitch database doesn't exist"
echo "INFO: Creating the Open VSwitch database..."
ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
fi
else
echo "Open vSwitch not mounted from host"
echo "CRITICAL: Open vSwitch is not mounted from host"
exit 1
fi

echo "Starting ovsdb-server..."
ovsdb-server --remote=punix:/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --log-file=/var/contiv/log/ovs-db.log -vsyslog:dbg -vfile:dbg --pidfile --detach /etc/openvswitch/conf.db

echo "Starting ovs-vswitchd"
ovs-vswitchd -v --pidfile --detach --log-file=/var/contiv/log/ovs-vswitchd.log -vconsole:err -vsyslog:info -vfile:info &

echo "Setting OVS manager (tcp)..."
echo "INFO: Starting ovsdb-server..."
ovsdb-server --remote=punix:/var/run/openvswitch/db.sock \
--remote=db:Open_vSwitch,Open_vSwitch,manager_options \
--private-key=db:Open_vSwitch,SSL,private_key \
--certificate=db:Open_vSwitch,SSL,certificate \
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
--log-file=/var/contiv/log/ovs-db.log -vsyslog:dbg -vfile:dbg \
--pidfile --detach /etc/openvswitch/conf.db

echo "INFO: Starting ovs-vswitchd"
ovs-vswitchd -v --pidfile --detach --log-file=/var/contiv/log/ovs-vswitchd.log \
-vconsole:err -vsyslog:info -vfile:info &

retry=0
while [[ $(ovsdb-client list-dbs | grep -c Open_vSwitch) -eq 0 ]] ; do
if [[ ${retry} -eq 5 ]]; then
echo "CRITICAL: Failed to start ovsdb in 5 seconds."
exit 1
else
echo "INFO: Waiting for ovsdb to start..."
sleep 1
((retry+=1))
fi
done

echo "INFO: Setting OVS manager (tcp)..."
ovs-vsctl set-manager tcp:127.0.0.1:6640

echo "Setting OVS manager (ptcp)..."
echo "INFO: Setting OVS manager (ptcp)..."
ovs-vsctl set-manager ptcp:6640

exit 0