Created
August 1, 2016 16:58
-
-
Save johnsom/0b68396b4a68e6840f82169bcb816b4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function wait_for_nova_active { | |
echo "Waiting for $1 to become ACTIVE..." | |
status=$(nova show $1 | awk '/status/ {print $4}') | |
while [ "$status" != "ACTIVE" ] | |
do | |
sleep 1 | |
status=$(nova show $1 | awk '/ status/ {print $4}') | |
if [ $status == "ERROR" ] | |
then | |
echo "$1 ERRORED. Exiting." | |
exit 1; | |
fi | |
done | |
} | |
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 | |
nova secgroup-add-rule default tcp 80 80 0.0.0.0/0 | |
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 | |
# Boot some instances | |
NOVA_BOOT_ARGS="--key-name octavia_ssh_key --image $(glance image-list | awk '/ cirros-0.3.3-x86_64-disk / {print $2}') --flavor 1 --nic net-id=$(neutron net-list | awk '/ private / {print $2}')" | |
nova boot ${NOVA_BOOT_ARGS} webserver1 | |
wait_for_nova_active webserver1 | |
sleep 10 | |
webserver1ip=$(nova show webserver1 | awk '/private network/ {a = substr($5, 0, length($5)-1); if (a ~ "\\.") print a; else print $6}') | |
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /etc/octavia/.ssh/octavia_ssh_key /scripts/newcountingwebserver.sh cirros@\[$webserver1ip\]:/home/cirros | |
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /etc/octavia/.ssh/octavia_ssh_key -q cirros@$webserver1ip "screen -d -m sh newcountingwebserver.sh" | |
nova boot ${NOVA_BOOT_ARGS} webserver2 | |
wait_for_nova_active webserver2 | |
sleep 10 | |
webserver2ip=$(nova show webserver2 | awk '/private network/ {a = substr($5, 0, length($5)-1); if (a ~ "\\.") print a; else print $6}') | |
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /etc/octavia/.ssh/octavia_ssh_key /scripts/newcountingwebserver.sh cirros@\[$webserver2ip\]:/home/cirros | |
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /etc/octavia/.ssh/octavia_ssh_key -q cirros@$webserver2ip "screen -d -m sh newcountingwebserver.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment