Skip to content

Commit dbb7263

Browse files
committed
start netplugin at bootup
1 parent 59202a7 commit dbb7263

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

Vagrantfile

+7-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8686
node_peers += ["#{node_name}=http://#{node_addr}:2380,#{node_name}=http://#{node_addr}:7001"]
8787
consul_join_flag = if n > 0 then "-join #{node_ips[0]}" else "" end
8888
consul_bootstrap_flag = "-bootstrap-expect=3"
89+
swarm_flag = "slave"
8990
if num_nodes < 3 then
9091
if n == 0 then
9192
consul_bootstrap_flag = "-bootstrap"
93+
swarm_flag = "master"
9294
else
9395
consul_bootstrap_flag = ""
96+
swarm_flag = "slave"
9497
end
9598
end
9699
config.vm.define node_name do |node|
@@ -136,15 +139,17 @@ set -x
136139
-bind=#{node_addr} -data-dir /opt/consul 0<&- &>/tmp/consul.log &) || exit 1
137140
138141
# start swarm
139-
(nohup #{gopath_folder}/src/github.com/contiv/netplugin/scripts/start-swarm.sh #{node_addr} > /tmp/start-swarm.log &) || exit 1
142+
(nohup #{gopath_folder}/src/github.com/contiv/netplugin/scripts/start-swarm.sh #{node_addr} #{swarm_flag}> /tmp/start-swarm.log &) || exit 1
140143
141144
SCRIPT
142145
node.vm.provision "shell", run: "always" do |s|
143146
s.inline = provision_node
144147
end
145148

146149
# forward netmaster port
147-
# node.vm.network "forwarded_port", guest: 9999, host: 8080 + n
150+
if n == 0 then
151+
node.vm.network "forwarded_port", guest: 9999, host: 8080
152+
end
148153
end
149154
end
150155
end

scripts/cleanup

+8
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@ then
2626
exit 1
2727
fi
2828

29+
# stop netmaster and netplugin if they are running
30+
killall netplugin
31+
killall netmaster
32+
33+
# Cleanup etcd and consul state
2934
etcdctl rm -recursive /contiv > /dev/null 2>&1
35+
etcdctl rm -recursive /contiv.io > /dev/null 2>&1
3036
curl -X DELETE http://localhost:8500/v1/kv/contiv?recurse > /dev/null 2>&1
37+
38+
# Cleanup ovs state
3139
ovs-vsctl del-br contivVlanBridge > /dev/null 2>&1
3240
ovs-vsctl del-br contivVxlanBridge > /dev/null 2>&1
3341

scripts/start-swarm.sh

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/bin/bash
22

3-
USAGE="Usage: $0 <node-addr>"
3+
USAGE="Usage: $0 <node-addr> <master|slave>"
44

5-
if [ $# -ne 1 ]; then
5+
if [ $# -ne 2 ]; then
66
echo $USAGE
77
exit 1
88
fi
99

1010
node_addr=$1
11+
mode=$2
12+
source /etc/profile.d/envvar.sh
1113

1214
echo "start-swarm waiting for etcd"
1315

@@ -18,10 +20,21 @@ while [[ `etcdctl cluster-health | head -n 1` != "cluster is healthy" ]]; do
1820
etcdctl cluster-health;
1921
done
2022

21-
echo "starting swarm on " $node_addr
22-
23+
echo "starting swarm in" $mode "mode on" $node_addr
24+
echo "starting swarm join"
2325
# Start swarm discovery
2426
nohup /usr/bin/swarm join --advertise=$node_addr:2385 etcd://localhost:2379 > /tmp/swarm-join.log 2>&1 &
2527

26-
# Start swarm manager
27-
nohup /usr/bin/swarm manage -H tcp://$node_addr:2375 etcd://localhost:2379 > /tmp/swarm-manage.log 2>&1 &
28+
echo "starting netplugin"
29+
# start netplugin
30+
nohup /opt/gopath/bin/netplugin -native-integration=true > /tmp/netplugin.log 2>&1 &
31+
32+
if [[ $mode == "master" ]]; then
33+
echo "starting swarm manager"
34+
# Start swarm manager
35+
nohup /usr/bin/swarm manage -H tcp://$node_addr:2375 etcd://localhost:2379 > /tmp/swarm-manage.log 2>&1 &
36+
37+
echo "starting netmaster"
38+
#start netmaster
39+
nohup /opt/gopath/bin/netmaster > /tmp/netmaster.log 2>&1 &
40+
fi

0 commit comments

Comments
 (0)