summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIllia Polliul <ipolliul@mirantis.com>2017-03-01 12:38:04 +0100
committerIllia Polliul <ipolliul@mirantis.com>2017-03-01 12:38:04 +0100
commitb115ce7ebcbf01154f70fafaef82e537c5bc1668 (patch)
treed23416ebd613408cddffb4af4cacfffc7bd4bed4
parent0a3c290360e1e94d5d24586a86115bf7537510aa (diff)
VTEP configuration script for OVS ToR emulator
Change-Id: I93e0e8c82460fc90a7c6e1fb2190b9a137bdd77a Signed-off-by: Illia Polliul <ipolliul@mirantis.com>
Notes
Notes (review): Verified+1: Plugins CI <plugins.ci@mirantis.com> Code-Review+2: okosse <okosse@mirantis.com> Workflow+1: okosse <okosse@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 01 Mar 2017 11:42:31 +0000 Reviewed-on: https://review.openstack.org/439544 Project: openstack/fuel-plugin-contrail Branch: refs/heads/master
-rwxr-xr-xvtep_start.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/vtep_start.sh b/vtep_start.sh
new file mode 100755
index 0000000..f74cc69
--- /dev/null
+++ b/vtep_start.sh
@@ -0,0 +1,61 @@
1#!/usr/bin/env bash
2
3while getopts ":m:i:p:d:" opt; do
4 case $opt in
5 m)
6 echo "Running in $OPTARG mode" >&2
7 MODE=$OPTARG
8 ;;
9 i)
10 HAPROXY_IP=$OPTARG
11 ;;
12 p)
13 HAPROXY_PORT=$OPTARG
14 ;;
15 :)
16 echo "Option -$OPTARG requires an argument." >&2
17 exit 1
18 ;;
19 esac
20done
21
22if [[ -z $MODE ]]; then
23 echo "You need to specify mode with -m" >&2
24fi
25
26if [[ $MODE != 'pssl' && $MODE != 'tcp' ]]; then
27 echo "You need to provide 'pssl' or 'tcp' with -m argument"
28fi
29
30if [[ $MODE = "pssl" ]]; then
31 if [[ -z $HAPROXY_IP || -z $HAPROXY_PORT ]] ; then
32 echo "In pssl mode:" >&2
33 echo "Haproxy ip needs to be provided with -p option" >&2
34 echo "Haproxy port needs to be provided with -p option" >&2
35 exit 1
36 else
37 COMMAND="ssl:${HAPROXY_IP}:${HAPROXY_PORT}"
38 CERTS_PATH='-p /var/db/certs/vtep_1-privkey.pem -c /var/db/certs/vtep_1-cert.pem -C /var/db/certs/cacert.pem'
39 fi
40else
41 COMMAND='ptcp:6632'
42fi
43
44rm /etc/openvswitch/*.db
45ovsdb-tool create /etc/openvswitch/ovs.db /usr/share/openvswitch/vswitch.ovsschema ; ovsdb-tool create /etc/openvswitch/vtep.db /usr/share/openvswitch/vtep.ovsschema
46service openvswitch-switch stop
47ovsdb-server --pidfile --detach --log-file --remote punix:/var/run/openvswitch/db.sock --remote=db:hardware_vtep,Global,managers --remote $COMMAND $CERTS_PATH /etc/openvswitch/ovs.db /etc/openvswitch/vtep.db
48ovs-vswitchd --log-file --detach --pidfile unix:/var/run/openvswitch/db.sock
49ovsdb-client list-dbs unix:/var/run/openvswitch/db.sock
50ovs-vsctl add-br TOR1
51vtep-ctl add-ps TOR1
52vtep-ctl set Physical_Switch TOR1 tunnel_ips=10.109.4.229
53python /usr/share/openvswitch/scripts/ovs-vtep --log-file=/var/log/openvswitch/ovs-vtep.log --pidfile=/var/run/openvswitch/ovs-vtep.pid --detach TOR1
54ip netns add ns1
55ip link add nstap1 type veth peer name tortap1
56ovs-vsctl add-port TOR1 tortap1
57ip link set nstap1 netns ns1
58ip netns exec ns1 ip link set dev nstap1 up
59ip link set dev tortap1 up
60ip netns exec ns1 ip link set nstap1 address 00:01:00:00:05:78
61