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.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 rm -f rexray
  42. ExecStartPre=-/usr/bin/docker pull openstackmagnum/rexray:alpine
  43. ExecStartPre=-/usr/bin/rm -f /var/run/rexray/rexray.pid
  44. ExecStart=/usr/bin/docker run -d --name=rexray --privileged \\
  45. --pid host \\
  46. --net host \\
  47. -p 7979:7979 \\
  48. -v /run/docker/plugins:/run/docker/plugins \\
  49. -v /var/lib/rexray:/var/lib/rexray:Z \\
  50. -v /var/lib/libstorage:/var/lib/libstorage:rshared \\
  51. -v /var/log/rexray:/var/log/rexray \\
  52. -v /var/run/rexray:/var/run/rexray \\
  53. -v /var/lib/docker:/var/lib/docker:rshared \\
  54. -v /var/run/docker:/var/run/docker \\
  55. -v /dev:/dev \\
  56. -v /etc/rexray/config.yml:/etc/rexray/config.yml \\
  57. openstackmagnum/rexray:alpine
  58. ExecStop=/usr/bin/docker stop rexray
  59. [Install]
  60. WantedBy=multi-user.target
  61. EOF
  62. chown root:root /etc/systemd/system/rexray.service
  63. chmod 644 /etc/systemd/system/rexray.service
  64. systemctl daemon-reload
  65. fi
  66. echo "starting rexray..."
  67. systemctl enable rexray
  68. systemctl --no-block start rexray