From 6d12689be39d717330a6c774ea2e784f7fd7578a Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 20 Jun 2013 14:11:36 +0200 Subject: finished revert_instance_from_snapshot.sh --- revert_instance_from_snapshot.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'revert_instance_from_snapshot.sh') diff --git a/revert_instance_from_snapshot.sh b/revert_instance_from_snapshot.sh index 373b8b1..705d055 100755 --- a/revert_instance_from_snapshot.sh +++ b/revert_instance_from_snapshot.sh @@ -3,10 +3,11 @@ # following prerequisites are needed # - all keys must be present to current user (use add_keys script to import) +# Todo: How do we add more keys with the nova cli ? + +# 2 cpus, 10gb disk, 1024 ram flavor='testing' secgroup='Bitmask' -keys='--key_name varac --key_name drebs --key_name kwadronaut --key_name micah --key_name elijah' - usage() { @@ -19,17 +20,19 @@ OPTIONS: -h Show this message -i -s + -k add sshkey -v verbose mode EOF } -set -- $(getopt hi:s:v "$@") +set -- $(getopt hi:s:k:v "$@") while [ $# -gt 0 ] do case "$1" in (-h) usage; exit 1 ;; (-i) instance="$2"; shift;; (-s) snapshot="$2"; shift;; + (-k) key="$2"; shift;; (--) shift; break;; (-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;; (*) break;; @@ -37,7 +40,7 @@ do shift done -if [[ -z $instance ]] || [[ -z $snapshot ]] +if [[ -z $instance ]] || [[ -z $snapshot ]] || [[ -z $key ]] then usage exit 1 @@ -69,11 +72,14 @@ echo "Deleting $instance" nova delete $instance echo -echo "Booting $instance from snapshot $snap" -result=`nova boot --image $snapshot --flavor $flavor --security-groups $secgroup $keys $instance` +echo "Booting $instance from snapshot $snap with boot cmd:" +boot_cmd="nova boot --image $snapshot --flavor $flavor --security-groups $secgroup --key_name $key $instance" +echo $boot_cmd +result=`$boot_cmd` # unfortunatly unformatted -#echo $result +#echo $result > /tmp/result +echo $result newid=`echo "$result" | grep '| id ' | cut -d '|' -f 3 | sed 's/ //g' ` -- cgit v1.2.3