#! /usr/bin/python
#########################
# by Jan-Philip Gehrcke
# 08-10-12
#########################

import os

print "================= a script to invoke ec2-bundle-vol ================="
print "     make sure that $EC2_PRIVATE_KEY, $EC2_CERT, $EC2_UID are set"
print "=====================================================================\n"
imageName = raw_input("image name: ")
imageDir = raw_input("image dir: ")

bundlecommand = "ec2-bundle-vol -k $EC2_PRIVATE_KEY -c $EC2_CERT -u $EC2_UID -r i386 --no-inherit" + " -d " + imageDir + " -p " + imageName

print "\ncommand:"
print bundlecommand + "\n"

while True: # wait for instring to be a known command
    while True: # wait for an errorfree input
        try:
            instring = raw_input("execute? (y/n): ")
            break
        except:
            pass
    if (instring == "y") or (instring == "n"): 
        break

if instring == "y": os.system(bundlecommand)
