diff --git a/templates/test_nova.sh.erb b/templates/test_nova.sh.erb index f3a243b..012bd57 100644 --- a/templates/test_nova.sh.erb +++ b/templates/test_nova.sh.erb @@ -1,9 +1,9 @@ #!/bin/bash # # assumes that openstack credentails are set in this file -source <%= rc_file_path %> +source <%= @rc_file_path %> -<% if image_type == 'cirros' -%> +<% if @image_type == 'cirros' -%> # Grab an image. Cirros is a nice small Linux that's easy to deploy wget --quiet https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img @@ -38,9 +38,9 @@ fi nova --no-cache keypair-add --pub_key /tmp/id_rsa.pub key_cirros -instance_name='<%= image_type %>_test_vm' +instance_name='<%= @image_type %>_test_vm' -<% if quantum -%> +<% if @quantum -%> quantum net-create public --router:external=True quantum subnet-create --allocation-pool start=172.16.2.128,end=172.16.2.150 public 172.16.2.0/24 @@ -59,7 +59,7 @@ quantum router-gateway-set router1 $quantum_public_net nova --no-cache boot --flavor 1 --image $IMAGE_ID --key_name key_cirros --nic net-id=$quantum_net $instance_name <% else -%> - <% if floating_ip -%> + <% if @floating_ip -%> # create a security group so that we can allow ssh, http, and ping traffic # when we add a floating IP (assuming you are adding floating IPs) nova --no-cache secgroup-create nova_test 'Cirros test security group' @@ -69,30 +69,30 @@ nova --no-cache secgroup-add-rule nova_test icmp -1 -1 0.0.0.0/0 # request a floating IP address, and extract the address from the results message floating_ip=`nova --no-cache floating-ip-create | grep None | awk '{print $2}'` <% end -%> - # Boot the added image against the "1" flavor which by default maps to a micro instance. <% if floating_ip -%> Include the cirros_test group so our address will work when we add it later <% end %> -nova --no-cache boot --flavor 1 <% if floating_ip -%>--security_groups nova_test<% end %> --image ${IMAGE_ID} --key_name key_cirros $instance_name + # Boot the added image against the "1" flavor which by default maps to a micro instance. <% if @floating_ip -%> Include the cirros_test group so our address will work when we add it later <% end %> +nova --no-cache boot --flavor 1 <% if @floating_ip -%>--security_groups nova_test<% end %> --image ${IMAGE_ID} --key_name key_cirros $instance_name <% end -%> # let the system catch up -sleep <%= sleep_time %> +sleep <%= @sleep_time %> # Show the state of the system we just requested. nova --no-cache show $instance_name # wait for the server to boot -sleep <%= sleep_time %> +sleep <%= @sleep_time %> -<% if floating_ip -%> +<% if @floating_ip -%> # Now add the floating IP we reserved earlier to the machine. # if not quantum nova --no-cache add-floating-ip $instance_name $floating_ip # Wait and then try to SSH to the node, leveraging the private key # we generated earlier. -sleep <%= sleep_time %> +sleep <%= @sleep_time %> ssh $login_user@$floating_ip -i /tmp/id_rsa -o StrictHostKeyChecking=no hostname <% end -%> -<% if quantum %> +<% if @quantum %> # get port ip_addr=`nova show $instance_name | grep 'net1 network' | awk -F'|' '{print $3}'` port_id=`quantum port-list | grep $ip_addr | awk -F' ' '{print $2}'` @@ -100,7 +100,7 @@ floating_ip=`quantum floatingip-create --port_id $port_id $quantum_public_net | quantum security-group-rule-create --protocol icmp --direction ingress default quantum security-group-rule-create --protocol tcp --port-range-min 22 \ --port-range-max 22 --direction ingress default -sleep <%= sleep_time %> +sleep <%= @sleep_time %> ssh $login_user@$floating_ip -i /tmp/id_rsa -o StrictHostKeyChecking=no hostname <% end %> exit 0