summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2013-06-20 14:11:36 +0200
committervarac <varacanero@zeromail.org>2013-06-20 14:11:36 +0200
commit6d12689be39d717330a6c774ea2e784f7fd7578a (patch)
tree897ea6af33bfdd94e9fcd623c6d9df14c525c653
parentc04dc197d1a37c9a354e02169f35f1167b7acadd (diff)
finished revert_instance_from_snapshot.sh
-rwxr-xr-xrevert_instance_from_snapshot.sh20
1 files changed, 13 insertions, 7 deletions
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 <instance>
-s <snapshot>
+ -k <keyname> 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' `