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.

pre_build_hook 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 PLUGIN_DIR="$(dirname $0)"
  17. readonly PLUGIN_VERSION=`cat ${PLUGIN_DIR}/.version`
  18. readonly REPOSITORY_PATH='bgate.mellanox.com/openstack/mellanox_fuel_plugin'
  19. function download {
  20. FILE_TYPE=$1
  21. FILE_NAME=$2
  22. case ${FILE_TYPE} in
  23. 'bootstrap')
  24. PREFIX_URL=$PLUGIN_VERSION/bootstrap/latest-build
  25. BUILD_DIR=bootstrap/
  26. FILE_NAME=`curl http://${REPOSITORY_PATH}/${PREFIX_URL}/ | tr '<' '\n' | tr '>' '\n' | grep ^$FILE_NAME`
  27. ;;
  28. 'rpm')
  29. PREFIX_URL=$PLUGIN_VERSION/repositories/centos/Packages
  30. BUILD_DIR=repositories/centos/Packages
  31. ;;
  32. 'deb')
  33. PREFIX_URL=$PLUGIN_VERSION/repositories/ubuntu
  34. BUILD_DIR=repositories/ubuntu
  35. ;;
  36. *)
  37. echo "Can't download ${FILE_NAME}. File of type ${FILE_TYPE} is not supported."
  38. exit 1
  39. esac
  40. URL="http://${REPOSITORY_PATH}/${PREFIX_URL}/${FILE_NAME}"
  41. DEST_DIR="${PLUGIN_DIR}/${BUILD_DIR}"
  42. wget ${URL} -P ${DEST_DIR}
  43. if [ $? -ne 0 ]; then
  44. echo "Failed fetching package from: ${URL} to ${DEST_DIR}" >&2
  45. exit 1
  46. fi
  47. }
  48. function get_packages() {
  49. file_type=$1
  50. old_packages=$2
  51. files=$3
  52. rm -rf $old_packages
  53. for f in $files; do
  54. download $file_type $f
  55. done
  56. }
  57. old_debs="${PLUGIN_DIR}/repositories/ubuntu/*.deb"
  58. deb_files="cirros-testvm-mellanox_0.3.2-ubuntu3_amd64.deb
  59. cirros-testvm-mellanox-ib_0.3.2-9_amd64.deb
  60. eswitchd_1.0.0-18_amd64.deb
  61. mlnx-ofed-fuel_4.0-2.0.0.1_amd64.deb
  62. lldpd_0.9.1-0_amd64.deb
  63. python-networking-mlnx_7.0.0-1_all.deb"
  64. get_packages "deb" "$old_debs" "$deb_files"