Fuel plugin for Mellanox support
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/bash
  2. # Copyright 2015 Mellanox Technologies, Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  13. # implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. readonly SCRIPT_NAME=`basename $0`
  17. sysctl_conf_no_apply=no
  18. function sysctl_conf (){
  19. # params
  20. op="$1"
  21. var="$2"
  22. val="$3"
  23. # apply
  24. if [ "x$op" == "xapply" ]; then
  25. sysctl -e -p > /dev/null 2>&1
  26. fi
  27. # unset
  28. if [ "x$op" == "xunset" -a "x$var" != "x" ]; then
  29. sed -e "/^[\t\ ]*$var[\t\ ]*=.*$/d" -i /etc/sysctl.conf
  30. if [ "x$sysctl_conf_no_apply" != "xyes" ]; then
  31. sysctl_conf apply
  32. fi
  33. fi
  34. # set
  35. if [ "x$op" == "xset" -a "x$var" != "x" -a "x$val" != "x" ]; then
  36. sysctl_conf_no_apply=yes
  37. sval="$val"
  38. sysctl_conf unset "$var"
  39. echo "$var=$sval" >> /etc/sysctl.conf
  40. sysctl_conf apply
  41. sysctl_conf_no_apply=no
  42. fi
  43. }
  44. function logger_print () {
  45. priority=$1
  46. msg=$2
  47. logger -t $SCRIPT_NAME "${priority}: ${msg}"
  48. echo $(date +"%Y-%m-%d %H:%M:%S") $SCRIPT_NAME ${priority}: ${msg} >> /var/log/mellanox-plugin.log
  49. }
  50. function get_mlnx_param () {
  51. param="$1"
  52. val=$(ruby -r hiera -r yaml -e "hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml'); mlnx = hiera.lookup 'mellanox-plugin', [], {}; puts mlnx['"$param"']")
  53. echo $val
  54. }
  55. function get_distro () {
  56. if [[ -f /etc/redhat-release ]]; then
  57. dist='redhat';
  58. elif [[ -f /etc/debian_version ]]; then
  59. dist='ubuntu';
  60. else
  61. logger_print error "Could not detect linux distribution"
  62. fi
  63. echo $dist
  64. }
  65. function get_param () {
  66. param="$1"
  67. val=$(ruby -r hiera -r yaml -e 'hiera = Hiera.new(:config => '\''/etc/puppet/hiera.yaml'\''); out = hiera.lookup '\'''"$param"''\'', [], {}; puts out')
  68. echo $val
  69. }
  70. readonly DISTRO=`get_distro`
  71. readonly DRIVER=`get_mlnx_param driver`
  72. readonly SRIOV=`get_mlnx_param sriov`
  73. readonly USER_NUM_OF_VFS=`get_mlnx_param num_of_vfs`
  74. readonly ISER=`get_mlnx_param iser`
  75. readonly MAX_VFS=62
  76. readonly MIN_VFS=1
  77. readonly CX=`get_mlnx_param cx_card`
  78. readonly NETWORK_TYPE=`get_mlnx_param network_type`
  79. readonly PHYSICAL_PORT=`get_mlnx_param physical_port`
  80. readonly VXLAN_OFFLOADING=`get_mlnx_param vxlan_offloading`
  81. readonly ROLES=`get_param roles`
  82. readonly ROLE=`get_param role`
  83. readonly DEBUG=`get_param debug`
  84. readonly QOS=`get_mlnx_param mlnx_qos`
  85. readonly REBOOT_REQUIRED=`get_mlnx_param reboot_required`