Container Infrastructure Management Service for OpenStack
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.

volume-service.sh 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. # Add rexray volume driver support for Swarm
  3. . /etc/sysconfig/heat-params
  4. set -e
  5. set -x
  6. # if no voulume driver is selected don't do any configuration
  7. if [ -z "$VOLUME_DRIVER" ]; then
  8. exit 0
  9. fi
  10. mkdir -p /etc/rexray
  11. mkdir -p /var/log/rexray
  12. mkdir -p /var/run/rexray
  13. mkdir -p /var/lib/rexray
  14. REXRAY_CONFIG=/etc/rexray/config.yml
  15. # Add rexray configuration
  16. cat > $REXRAY_CONFIG <<EOF
  17. libstorage:
  18. logging:
  19. level: info
  20. service: openstack
  21. integration:
  22. volume:
  23. operations:
  24. mount:
  25. preempt: $REXRAY_PREEMPT
  26. openstack:
  27. authUrl: $AUTH_URL
  28. userID: $TRUSTEE_USER_ID
  29. password: $TRUSTEE_PASSWORD
  30. trustID: $TRUST_ID
  31. EOF
  32. if [ ! -f /usr/bin/rexray ]; then
  33. # If rexray is not installed, run it in a docker container
  34. cat > /etc/systemd/system/rexray.service <<EOF
  35. [Unit]
  36. Description=Rexray container
  37. Requires=docker.service
  38. After=docker.service
  39. [Service]
  40. RemainAfterExit=yes
  41. ExecStartPre=-/usr/bin/docker pull openstackmagnum/rexray:alpine
  42. ExecStart=/usr/bin/rm -f /var/run/rexray/rexray.pid && \
  43. /usr/bin/docker run -d --name=rexray --privileged -p 7979:7979 \
  44. -v /run/docker/plugins:/run/docker/plugins \
  45. -v /var/lib/rexray:/var/lib/rexray:z \
  46. -v /var/log/rexray:/var/log/rexray \
  47. -v /var/run/rexray:/var/run/rexray \
  48. -v /dev:/dev \
  49. -v /etc/rexray/config.yml:/etc/rexray/config.yml \
  50. openstackmagnum/rexray:alpine
  51. ExecStop=/usr/bin/docker stop rexray
  52. [Install]
  53. WantedBy=multi-user.target
  54. EOF
  55. chown root:root /etc/systemd/system/rexray.service
  56. chmod 644 /etc/systemd/system/rexray.service
  57. systemctl daemon-reload
  58. fi
  59. echo "starting rexray..."
  60. systemctl enable rexray
  61. systemctl --no-block start rexray