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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. set -e
  3. # Image size in GB
  4. IMAGE_SIZE=150
  5. # Fill this with for example: 10.0.0.0/24
  6. YOUR_NETWORK_IP=""
  7. # Fill this with for example: 10.0.0.151
  8. NFS_SERVER_IP=""
  9. # Fill in your key name in Nova
  10. SSH_KEY_NAME=""
  11. # Fill in the hostname you wish to use for this NFS server
  12. MY_HOSTNAME=""
  13. # Name of your local lan as returned by "quantum net-list"
  14. LOCAL_LAN_NAME=""
  15. if [ -z "${YOUR_NETWORK_IP}" ] || [ -z "${NFS_SERVER_IP}" ] || [ -z "${SSH_KEY_NAME}" ] || [ -z "${MY_HOSTNAME}" ] || [ -z "${LOCAL_LAN_NAME}" ] ; then
  16. echo "parameters not configured in the script $0"
  17. exit 1
  18. fi
  19. NEUTRON=`which neutron`
  20. if [ -z "${NEUTRON}" ] ; then
  21. NEUTRON=`which quantum`
  22. fi
  23. if [ -z "${NEUTRON}" ] ; then
  24. echo "Please install neutron (or quantum) client"
  25. exit 1
  26. fi
  27. build-openstack-debian-image -r wheezy \
  28. -e nfs-kernel-server,nfs-common \
  29. -hs ./customize
  30. if ! [ -e version ] ; then
  31. echo 0 > version
  32. fi
  33. VERSION=`cat version`
  34. VERSION=$(( ${VERSION} + 1 ))
  35. echo ${VERSION} >version
  36. #
  37. rm debian-wheezy-7.0.0-3-amd64.raw
  38. mv debian-wheezy-7.0.0-3-amd64.qcow2 wheezy-nfs-${VERSION}.qcow2
  39. echo "Uploading image to Glance..."
  40. glance image-create --name="Wheezy NFS ${VERSION}" --disk-format=qcow2 --container-format=bare --file wheezy-nfs-${VERSION}.qcow2
  41. echo "Creating cinder disk out of the Glance image..."
  42. IMAGE_ID=`glance image-list | grep "Wheezy NFS ${VERSION}" | awk '{print $2}'`
  43. cinder create --image-id ${IMAGE_ID} --display-name "Wheezy NFS ${VERSION}" ${IMAGE_SIZE}
  44. echo "Deleting Glance image..."
  45. glance image-delete ${IMAGE_ID}
  46. echo -n "Waiting for Cinder image to become bootable."
  47. CINDER_IMAGE_BOOTABLE=`cinder list | grep "Wheezy NFS 4" | awk '{print $14}'`
  48. while [ "${CINDER_IMAGE_BOOTABLE}" != "true" ] ; do
  49. sleep 2
  50. echo -n "."
  51. done
  52. echo " done!"
  53. # Creates a static (fixed) IP ${NFS_SERVER_IP} in the quantum setup
  54. echo "Creating quantum static IP..."
  55. SUBNET_ID=`quantum subnet-list | grep ${YOUR_NETWORK_IP} | awk '{print $2}'`
  56. NET_ID=`quantum net-list | grep ${LOCAL_LAN_NAME} | awk '{print $2}'`
  57. quantum port-create --fixed-ip subnet_id=${SUBNET_ID},ip_address=${NFS_SERVER_IP} ${NET_ID}
  58. # Create a new VM using the "boot from volume" option
  59. echo "Booting instance..."
  60. IP_ONE=`quantum port-list | grep ${NFS_SERVER_IP} | awk '{print $2}'`
  61. BLOCK_DEV_ID=`nova volume-list | grep "Wheezy NFS ${VERSION}" | awk '{print $2}'`
  62. nova boot --block_device_mapping vda=${BLOCK_DEV_ID}::5:False --flavor 3 --nic port-id=${IP_ONE} --key-name ${SSH_KEY_NAME} ${MY_HOSTNAME}
  63. echo "All done. You can now wait until your NFS server becomes"
  64. echo "available. Note that it may take a lot of time, since its"
  65. echo "HDD image in Cinder will be resized at the first boot."