#!/bin/bash # Create OpenStack heat template file cat < ${heat_template} heat_template_version: 2013-05-23 description: Simple template to deploy a single compute instance parameters: instance_name: type: string label: Instance Name description: Name of the instance to be used key: type: string label: Key Name description: Name of key-pair to be used for compute instance image_name: type: string label: Image ID description: Image to be used for compute instance flavor_name: type: string label: Instance Type description: Type of instance (flavor) to be used public_net_id: type: string label: Netid description: public NetId public_net_subnet: type: string label: subnet description: public subnet NetId onap_sg: type: string default: default volume_name: type: string default: onap_offline_build_volume volume_size: type: number default: 400 resources: VMwithvolume_0_private_port: type: OS::Neutron::Port properties: network: { get_param: public_net_id } fixed_ips: [{"subnet": { get_param: public_net_subnet }}] security_groups: - { get_param: onap_sg } VMwithvolume_0: type: OS::Nova::Server properties: name: { get_param: instance_name } availability_zone: nova key_name: { get_param: key } image: { get_param: image_name } flavor: { get_param: flavor_name } networks: - port: { get_resource: VMwithvolume_0_private_port } user_data_format: RAW user_data: str_replace: params: __mount_dir__: "aa" template: | #!/bin/bash set -e while [ ! -e /dev/vdb ]; do echo Waiting for volume /dev/sdb to attach; sleep 1; done echo "Partitions not formated, format it as ext4" # yes /dev/disk/by-id/, partprobe and hdparm show it is there, but no it is is not ready sleep 1 mkfs.ext4 /dev/vdb file -sL /dev/disk/by-id/* mkdir -pv /tmp # mount on reboot echo "/dev/vdb /tmp ext4 defaults,nofail 0 0" >> /etc/fstab # mount now mount /tmp cinder_volume: type: OS::Cinder::Volume properties: name: { get_param: volume_name } size: { get_param: volume_size } volume_attachment: type: OS::Cinder::VolumeAttachment properties: volume_id: { get_resource: cinder_volume } instance_uuid: { get_resource: VMwithvolume_0 } mountpoint: /dev/vdb EOF