blob: d02f26529d70d73b5a2debe94aa1961c00f90945 (
plain)
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
|
#!/bin/bash
# Copyright 2015 Mellanox Technologies, Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
readonly SCRIPT_NAME=`basename $0`
sysctl_conf_no_apply=no
function sysctl_conf (){
# params
op="$1"
var="$2"
val="$3"
# apply
if [ "x$op" == "xapply" ]; then
sysctl -e -p > /dev/null 2>&1
fi
# unset
if [ "x$op" == "xunset" -a "x$var" != "x" ]; then
sed -e "/^[\t\ ]*$var[\t\ ]*=.*$/d" -i /etc/sysctl.conf
if [ "x$sysctl_conf_no_apply" != "xyes" ]; then
sysctl_conf apply
fi
fi
# set
if [ "x$op" == "xset" -a "x$var" != "x" -a "x$val" != "x" ]; then
sysctl_conf_no_apply=yes
sval="$val"
sysctl_conf unset "$var"
echo "$var=$sval" >> /etc/sysctl.conf
sysctl_conf apply
sysctl_conf_no_apply=no
fi
}
function logger_print () {
priority=$1
msg=$2
logger -t $SCRIPT_NAME "${priority}: ${msg}"
echo $(date +"%Y-%m-%d %H:%M:%S") $SCRIPT_NAME ${priority}: ${msg} >> /var/log/mellanox-plugin.log
}
function get_mlnx_param () {
param="$1"
val=$(ruby -r hiera -r yaml -e "hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml'); mlnx = hiera.lookup 'mellanox-plugin', [], {}; puts mlnx['"$param"']")
echo $val
}
function get_distro () {
if [[ -f /etc/redhat-release ]]; then
dist='redhat';
elif [[ -f /etc/debian_version ]]; then
dist='ubuntu';
else
logger_print error "Could not detect linux distribution"
fi
echo $dist
}
function get_param () {
param="$1"
val=$(ruby -r hiera -r yaml -e 'hiera = Hiera.new(:config => '\''/etc/puppet/hiera.yaml'\''); out = hiera.lookup '\'''"$param"''\'', [], {}; puts out')
echo $val
}
readonly DISTRO=`get_distro`
readonly DRIVER=`get_mlnx_param driver`
readonly SRIOV=`get_mlnx_param sriov`
readonly USER_NUM_OF_VFS=`get_mlnx_param num_of_vfs`
readonly ISER=`get_mlnx_param iser`
readonly MAX_VFS=62
readonly MAX_VFS_CX5=96
readonly MIN_VFS=1
readonly CX=`get_mlnx_param cx_card`
readonly NETWORK_TYPE=`get_mlnx_param network_type`
readonly PHYSICAL_PORT=`get_mlnx_param physical_port`
readonly VXLAN_OFFLOADING=`get_mlnx_param vxlan_offloading`
readonly ROLES=`get_param roles`
readonly ROLE=`get_param role`
readonly DEBUG=`get_param debug`
readonly QOS=`get_mlnx_param mlnx_qos`
readonly REBOOT_REQUIRED=`get_mlnx_param reboot_required`
|