update test file to work with quantum

This commit is contained in:
Dan Bode
2012-10-13 19:49:35 -07:00
parent 8200961537
commit d8747ed6e7
2 changed files with 16 additions and 8 deletions

View File

@@ -18,7 +18,8 @@ class openstack::test_file(
$rc_file_path = '/root/openrc',
$image_type = 'cirros',
$sleep_time = '15',
$floating_ip = true
$floating_ip = true,
$quantum = true
) {
file { $path:

View File

@@ -24,9 +24,9 @@ wget http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd6
glance add name="precise-amd64" is_public=true container_format=ovf disk_format=qcow2 < precise-server-cloudimg-amd64-disk1.img
# Caputre the Image ID so taht we can call the right UUID for this image
IMAGE_ID=`glance index | grep 'precise-amd64' | head -1 | awk -F' ' '{print $1}'`
<% end -%>
login_user='ubuntu'
<% end -%>
# create a pub/priv keypair
ssh-keygen -f /tmp/id_rsa -t rsa -N ''
@@ -34,21 +34,28 @@ ssh-keygen -f /tmp/id_rsa -t rsa -N ''
#add the public key to nova.
nova --no-cache keypair-add --pub_key /tmp/id_rsa.pub key_cirros
<% if floating_ip -%>
instance_name='<%= image_type %>_test_vm'
<% if quantum -%>
quantum net-create net1
quantum subnet-create net1 10.0.0.0/24
quantum_net=`quantum net-list | grep net1 | awk -F' ' '{print $2}'`
nova --no-cache boot --flavor 1 --image $IMAGE_ID --key_name key_cirros --nic net-id=$quantum_net $instance_name
<% else -%>
<% 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'
nova --no-cache secgroup-add-rule nova_test tcp 22 22 0.0.0.0/0
nova --no-cache secgroup-add-rule nova_test tcp 80 80 0.0.0.0/0
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 -%>
instance_name='<%= image_type %>_test_vm'
# 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 %>
<% 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
<% end -%>
# let the system catch up
sleep <%= sleep_time %>