-
Notifications
You must be signed in to change notification settings - Fork 0
/
sriov_multus_deploy.sh
executable file
·146 lines (117 loc) · 3.41 KB
/
sriov_multus_deploy.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
set -e
set -x
parse_conf(){
param=$1
if [[ -f local.conf ]]
then
echo `grep -x $param"=.*" local.conf | cut -d"=" -f 2 -s`
fi
}
interface=`parse_conf interface`
is_bond=`parse_conf is_bond`
slave1=`parse_conf slave1`
while test $# -gt 0; do
case "$1" in
--interface | -f)
interface=$2
shift
shift
;;
--help | -h)
echo "
daemonset_deploy.sh [options] --interface <interface>: deploy the daemonsets "\
"of the sriov device plugin and the multus.
--interface | -i) <interface> The interface to use for SRIOV.
"
exit 0
;;
*)
echo "No such option!!"
echo "Exiting ...."
exit 1
esac
done
exec 1> >(logger -s -t $(basename $0)) 2>&1
##################################################
##################################################
############## functions ####################
##################################################
##################################################
check_interface(){
local_interface=$1
if [[ -z $local_interface ]]
then
echo "ERROR: no interface was provided, please provide one using the "\
"--interface option."
echo "Exiting ...."
exit 1
fi
if [[ ! -d /sys/class/net/"$local_interface" ]]
then
echo "ERROR: No interface named $local_interface exist on the machine, "\
"please check the interface name spelling, or make sure that the "\
"interface really exist."
echo "Exiting ...."
exit 1
fi
if [[ "`cat /sys/class/net/$local_interface/device/sriov_numvfs`" == "0" ]]
then
echo "ERROR: Interface $local_interface has no vfs, please create some "\
"and try again."
echo "Exiting ...."
exit 1
fi
}
set_sriov_device(){
local_interface=$1
device="`cat /sys/class/net/$local_interface/device/sriov_vf_device`"
device_line_number=`awk "/device/ {print NR}" sriov-setup.yaml`
sed -i "$device_line_number s/\[.*\]/[\"$device\"]/" sriov-setup.yaml
}
deploy_components(){
if [[ -d yaml/ ]]
then
cd yaml/
if [[ "$is_bond" == "true" ]]
then
set_sriov_device "$slave1"
else
set_sriov_device "$interface"
fi
kubectl create -f sriov-setup.yaml
kubectl create -f sriovdp-daemonset.yaml
kubectl create -f multus-daemonset.yaml
kubectl create -f sriov-net.yaml
else
echo "ERROR: there is no yaml directory in the current working "\
"directory, please make sure to run the script from the"\
"Kubernetes-OVN-setup directory."
echo "Exiting ...."
exit 1
fi
}
##################################################
##################################################
############## validation ####################
##################################################
##################################################
if [[ "$is_bond" == "true" ]]
then
if [[ -n "$slave1" ]]
then
check_interface "$slave1"
else
echo "is_bond is true, but no slave1 provided!!, please provide one using --slave1 option."
echo "Exiting...."
exit 1
fi
else
check_interface "$interface"
fi
##################################################
##################################################
############## main ####################
##################################################
##################################################
deploy_components