-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_then_bind.sh
executable file
·70 lines (45 loc) · 1.42 KB
/
create_then_bind.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
70
#!/bin/bash -f
source perf/perf.rc
assign_net_hosts
for i in `seq $NETS`; do
cnt=0
for host in `get_net_hosts $i`; do
#echo Creating ports for network $i on host ${host}
(as hv$host
for j in `seq $PORTS_PER_NET_PER_HOST`; do
if [ $PORTS_PER_NET_PER_HOST == 1 ]; then
vif=${i};
else
vif=${i}_${j};
fi
ovs-vsctl add-port br-int vif${vif} -- set Interface vif${vif} external-ids:iface-id=lp${host}_${vif}
done) &
((cnt++))
done
case $i in
*50|*00) echo Network $i: $((cnt * PORTS_PER_NET_PER_HOST)) physical "port(s)" created; wait ;;
esac
done
wait
cnt=1
before=`date +%s%3N`
echo -n 'Creating & binding logical ports...'
for i in `seq $NETS`; do
for host in `get_net_hosts $i`; do
for j in `seq $PORTS_PER_NET_PER_HOST`; do
if [ $PORTS_PER_NET_PER_HOST == 1 ]; then
vif=${i};
else
vif=${i}_${j};
fi
yy=$(printf %02x $(expr $cnt / 256))
xx=$(printf %02x $(expr $cnt % 256))
ovn-nbctl lport-add br$i lp${host}_${vif}
ovn-nbctl lport-set-addresses lp${host}_${vif} f0:00:00:00:$yy:$xx
((cnt++))
done
done
done
after=`date +%s%3N`
((cnt--))
printf "total of %d (in %'.fms per port)\n" $((cnt)) $(( ((after-before + cnt-1)/cnt) ))