def wait_for_available( ec2_conn, volume_id ):
    """
        Given a volume id, wait for its state to change to "available".
    """
    print "Waiting for {} available state".format( volume_id )
    while True:
        volumes = ec2_conn.get_all_volumes( volume_ids=[ volume_id ] )
        print "Current status is {}".format( volumes[0].status )
        if volumes[0].status != 'available':
            print "Sleeping for 5 seconds"
            time.sleep(5)
        else:
            break