Skip to content

Commit e7959a6

Browse files
committed
Dockerfile,runtime-scripts: split ovsdb & vswitchd
Signed-off-by: Cristian Staretu <[email protected]>
1 parent aee3f7d commit e7959a6

File tree

4 files changed

+109
-72
lines changed

4 files changed

+109
-72
lines changed

Dockerfile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1+
# Copyright 2018 Cisco Systems Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
114
# OVS Docker image
215

316
FROM alpine:3.7
417
LABEL maintainer "Cisco Contiv (https://contiv.github.io)"
518

6-
RUN mkdir -p /etc/openvswitch /var/log/contiv \
19+
RUN mkdir -p /etc/openvswitch \
720
&& echo 'http://dl-cdn.alpinelinux.org/alpine/v3.4/main' >> /etc/apk/repositories \
821
&& apk --no-cache add \
9-
openvswitch=2.5.0-r0 iptables ca-certificates openssl curl bash
10-
11-
COPY ovsInit.sh /scripts/
22+
openvswitch=2.5.0-r0 ca-certificates bash
1223

13-
ENTRYPOINT ["/scripts/ovsInit.sh"]
24+
COPY runtime-scripts/ /scripts/

ovsInit.sh

Lines changed: 0 additions & 67 deletions
This file was deleted.

runtime-scripts/start-ovs-vswitchd.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2018 Cisco Systems Inc. All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -euo pipefail
17+
18+
mkdir -p /var/run/openvswitch
19+
20+
if ! lsmod | cut -d" " -f1 | grep -q openvswitch; then
21+
echo "INFO: Loading kernel module: openvswitch"
22+
modprobe openvswitch
23+
sleep 2
24+
fi
25+
26+
echo "INFO: waiting for ovsdb"
27+
retry=0
28+
while ! ovsdb-client list-dbs | grep -q Open_vSwitch; do
29+
if [[ ${retry} -eq 15 ]]; then
30+
echo "CRITICAL: Failed to reach ovsdb server in 15 seconds"
31+
exit 1
32+
else
33+
echo "INFO: Waiting for ovsdb to start..."
34+
sleep 1
35+
((retry += 1))
36+
fi
37+
done
38+
39+
echo "INFO: Starting ovs-vswitchd"
40+
ovs-vswitchd -v --pidfile &
41+
VSWITCHD_PID=$!
42+
43+
sleep 2
44+
45+
echo "INFO: Setting OVS manager (tcp)..."
46+
ovs-vsctl set-manager tcp:127.0.0.1:6640
47+
48+
echo "INFO: Setting OVS manager (ptcp)..."
49+
ovs-vsctl set-manager ptcp:6640
50+
51+
wait $VSWITCHD_PID
52+
exit 1

runtime-scripts/start-ovsdb-server.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2018 Cisco Systems Inc. All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -euo pipefail
17+
18+
mkdir -p /var/run/openvswitch
19+
20+
if [ -d "/etc/openvswitch" ]; then
21+
if [ -f "/etc/openvswitch/conf.db" ]; then
22+
echo "INFO: The Open vSwitch database exists"
23+
else
24+
echo "INFO: The Open vSwitch database doesn't exist"
25+
echo "INFO: Creating the Open vSwitch database..."
26+
ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
27+
fi
28+
else
29+
echo "CRITICAL: Open vSwitch is not mounted from host"
30+
exit 1
31+
fi
32+
33+
echo "INFO: updating OVS database schema if needed"
34+
ovsdb-tool convert /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
35+
36+
echo "INFO: Starting ovsdb-server..."
37+
exec ovsdb-server --remote=punix:/var/run/openvswitch/db.sock \
38+
--remote=db:Open_vSwitch,Open_vSwitch,manager_options \
39+
--private-key=db:Open_vSwitch,SSL,private_key \
40+
--certificate=db:Open_vSwitch,SSL,certificate \
41+
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert

0 commit comments

Comments
 (0)