forked from shettyg/ovn-namespace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlb.sh
69 lines (59 loc) · 1.44 KB
/
lb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# 2 logical switches "foo" (192.168.1.0/24) and "bar" (172.16.1.0/24)
# connected to a router R1.
# foo has foo1, foo2, foo3 spread on 2 machines.
# bar has bar1, bar2, bar3 spread on 2 machines.
#
# Loadbalancer rules in 30.0.0.0/24 network.
usage () {
cat << EOF
usage: case1.sh COMMAND
Commands:
host1 Run commands for host1. This host has northd running.
host2 --db=tcp:IP:6640 Run commands for host2
EOF
}
host1 () {
sh ovn-router.sh create-router R1
ovn-nbctl ls-add foo
ovn-nbctl ls-add bar
sh ovn-router.sh connect-switch R1 foo 192.168.1.1/24
sh ovn-router.sh connect-switch R1 bar 172.16.1.1/24
sh ovn-port.sh add-port foo foo1 192.168.1.2/24 192.168.1.1
sh ovn-port.sh add-port foo foo2 192.168.1.3/24 192.168.1.1
sh ovn-port.sh add-port bar bar1 172.16.1.2/24 172.16.1.1
}
host2 () {
case $1 in
--db=*)
DB=`expr X"$1" : 'X[^=]*=\(.*\)'`
shift
;;
esac
if [ -z "$DB" ]; then
echo "DB not given"
exit 1
fi
sh ovn-port.sh add-port --db=$DB foo foo3 192.168.1.4/24 192.168.1.1
sh ovn-port.sh add-port --db=$DB bar bar2 172.16.1.3/24 172.16.1.1
sh ovn-port.sh add-port --db=$DB bar bar3 172.16.1.4/24 172.16.1.1
}
case $1 in
"host1")
shift
host1
exit 0
;;
"host2")
shift
host2 "$@"
exit 0
;;
-h | --help)
usage
exit 0
;;
*)
echo >&2 "$UTIL: unknown command \"$1\" (use --help for help)"
exit 1
;;
esac