Browse Source

VTEP configuration script for OVS ToR emulator

Change-Id: I93e0e8c82460fc90a7c6e1fb2190b9a137bdd77a
Signed-off-by: Illia Polliul <ipolliul@mirantis.com>
changes/44/439544/1
Illia Polliul 2 years ago
parent
commit
b115ce7ebc
1 changed files with 61 additions and 0 deletions
  1. 61
    0
      vtep_start.sh

+ 61
- 0
vtep_start.sh View File

@@ -0,0 +1,61 @@
1
+#!/usr/bin/env bash
2
+ 
3
+while 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
20
+done
21
+
22
+if [[ -z $MODE ]]; then
23
+  echo "You need to specify mode with -m" >&2
24
+fi
25
+
26
+if [[ $MODE != 'pssl' && $MODE != 'tcp' ]]; then
27
+  echo "You need to provide 'pssl' or 'tcp' with -m argument"
28
+fi
29
+
30
+if [[ $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
40
+else
41
+  COMMAND='ptcp:6632'
42
+fi
43
+
44
+rm /etc/openvswitch/*.db
45
+ovsdb-tool create /etc/openvswitch/ovs.db /usr/share/openvswitch/vswitch.ovsschema ; ovsdb-tool create /etc/openvswitch/vtep.db /usr/share/openvswitch/vtep.ovsschema
46
+service openvswitch-switch stop
47
+ovsdb-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
48
+ovs-vswitchd --log-file --detach --pidfile unix:/var/run/openvswitch/db.sock 
49
+ovsdb-client list-dbs unix:/var/run/openvswitch/db.sock
50
+ovs-vsctl add-br TOR1
51
+vtep-ctl add-ps TOR1
52
+vtep-ctl set Physical_Switch TOR1 tunnel_ips=10.109.4.229
53
+python /usr/share/openvswitch/scripts/ovs-vtep --log-file=/var/log/openvswitch/ovs-vtep.log --pidfile=/var/run/openvswitch/ovs-vtep.pid --detach TOR1
54
+ip netns add ns1
55
+ip link add nstap1 type veth peer name tortap1
56
+ovs-vsctl add-port TOR1 tortap1
57
+ip link set nstap1 netns ns1
58
+ip netns exec ns1 ip link set dev nstap1 up
59
+ip link set dev tortap1 up
60
+ip netns exec ns1 ip link set nstap1 address 00:01:00:00:05:78
61
+

Loading…
Cancel
Save