Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | ubuntu_name=${OS_IMAGE:-"trusty-server-cloudimg-amd64-disk1"} |
| 4 | export OS_IMAGE=$ubuntu_name |
| 5 | ubuntu_glance=`openstack image list -c Name -f value | grep "$ubuntu_name"` |
| 6 | ubuntu_file=/tmp/ubuntu.img |
| 7 | |
| 8 | sec_group_name=${OS_SEC_GROUP:-"onap-ssh-secgroup"} |
| 9 | export OS_SEC_GROUP=$sec_group_name |
| 10 | sec_group_list=`openstack security group list -c Name -f value | grep "$sec_group_name"` |
| 11 | |
| 12 | if [[ -z $ubuntu_glance ]]; then |
| 13 | if [ ! -f $ubuntu_file ]; then |
| 14 | curl http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img -o "$ubuntu_file" |
| 15 | fi |
| 16 | |
| 17 | openstack image create --disk-format raw --container-format bare --public --file $ubuntu_file "$ubuntu_name" |
| 18 | fi |
| 19 | |
| 20 | if [[ -z $sec_group_list ]]; then |
| 21 | openstack security group create "$sec_group_name" |
| 22 | openstack security group rule create --protocol tcp --remote-ip 0.0.0.0/0 --dst-port 22:22 "$sec_group_name" |
| 23 | fi |