blob: 765ad9446ed01140025e9d48914b6e6676c4f46a [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
3ubuntu_name=${OS_IMAGE:-"trusty-server-cloudimg-amd64-disk1"}
4export OS_IMAGE=$ubuntu_name
5ubuntu_glance=`openstack image list -c Name -f value | grep "$ubuntu_name"`
6ubuntu_file=/tmp/ubuntu.img
7
8sec_group_name=${OS_SEC_GROUP:-"onap-ssh-secgroup"}
9export OS_SEC_GROUP=$sec_group_name
10sec_group_list=`openstack security group list -c Name -f value | grep "$sec_group_name"`
11
12if [[ -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"
18fi
19
20if [[ -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"
23fi