def snapshot_created(name, ami_name, instance_name, wait_until_available=True, wait_timeout_seconds=300, **kwargs):
 ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
 if (not __salt__['boto_ec2.create_image'](ami_name=ami_name, instance_name=instance_name, **kwargs)):
  ret['comment'] = 'Failed to create new AMI {ami_name}'.format(ami_name=ami_name)
  ret['result'] = False
  return ret
 ret['comment'] = 'Created new AMI {ami_name}'.format(ami_name=ami_name)
 ret['changes']['new'] = {ami_name: ami_name}
 if (not wait_until_available):
  return ret
 starttime = time()
 while True:
  images = __salt__['boto_ec2.find_images'](ami_name=ami_name, return_objs=True, **kwargs)
  if (images and (images[0].state == 'available')):
   break
  if ((time() - starttime) > wait_timeout_seconds):
   if images:
    ret['comment'] = 'AMI still in state {state} after timeout'.format(state=images[0].state)
   else:
    ret['comment'] = 'AMI with name {ami_name} not found after timeout.'.format(ami_name=ami_name)
   ret['result'] = False
   return ret
  sleep(5)
 return ret

def snapshot_created ( name , ami_name , instance_name , wait_until_available = True , wait_timeout_seconds = 300 , ** kwargs ) : ret = { 'name' : name , 'result' : True , 'comment' : '' , 'changes' : { } } if ( not __salt__ [ 'boto_ec2.create_image' ] ( ami_name = ami_name , instance_name = instance_name , ** kwargs ) ) : ret [ 'comment' ] = 'Failed to create new AMI {ami_name}' . format ( ami_name = ami_name ) ret [ 'result' ] = False return ret ret [ 'comment' ] = 'Created new AMI {ami_name}' . format ( ami_name = ami_name ) ret [ 'changes' ] [ 'new' ] = { ami_name : ami_name } if ( not wait_until_available ) : return ret starttime = time ( ) while True : images = __salt__ [ 'boto_ec2.find_images' ] ( ami_name = ami_name , return_objs = True , ** kwargs ) if ( images and ( images [ 0 ] . state == 'available' ) ) : break if ( ( time ( ) - starttime ) > wait_timeout_seconds ) : if images : ret [ 'comment' ] = 'AMI still in state {state} after timeout' . format ( state = images [ 0 ] . state ) else : ret [ 'comment' ] = 'AMI with name {ami_name} not found after timeout.' . format ( ami_name = ami_name ) ret [ 'result' ] = False return ret sleep ( 5 ) return ret
create a snapshot from the given instance .