def import_(source, image, api_response=False):
 (repo_name, repo_tag) = _get_repo_tag(image)
 path = __salt__['container_resource.cache_file'](source)
 time_started = time.time()
 response = _image_wrapper('import_image', path, repository=repo_name, tag=repo_tag)
 ret = {'Time_Elapsed': (time.time() - time_started)}
 _clear_context()
 if (not response):
  raise CommandExecutionError('Import failed for {0}, no response returned from Docker API'.format(source))
 elif api_response:
  ret['API_Response'] = response
 errors = []
 for item in response:
  try:
   item_type = next(iter(item))
  except StopIteration:
   continue
  if (item_type == 'status'):
   _import_status(ret, item, repo_name, repo_tag)
  elif (item_type == 'errorDetail'):
   _error_detail(errors, item)
 if ('Id' not in ret):
  msg = 'Import failed for {0}'.format(source)
  if errors:
   msg += '. Error(s) follow:\n\n{0}'.format('\n\n'.join(errors))
  raise CommandExecutionError(msg)
 return ret

def import_ ( source , image , api_response = False ) : ( repo_name , repo_tag ) = _get_repo_tag ( image ) path = __salt__ [ 'container_resource.cache_file' ] ( source ) time_started = time . time ( ) response = _image_wrapper ( 'import_image' , path , repository = repo_name , tag = repo_tag ) ret = { 'Time_Elapsed' : ( time . time ( ) - time_started ) } _clear_context ( ) if ( not response ) : raise CommandExecutionError ( 'Import failed for {0}, no response returned from Docker API' . format ( source ) ) elif api_response : ret [ 'API_Response' ] = response errors = [ ] for item in response : try : item_type = next ( iter ( item ) ) except StopIteration : continue if ( item_type == 'status' ) : _import_status ( ret , item , repo_name , repo_tag ) elif ( item_type == 'errorDetail' ) : _error_detail ( errors , item ) if ( 'Id' not in ret ) : msg = 'Import failed for {0}' . format ( source ) if errors : msg += '. Error(s) follow:\n\n{0}' . format ( '\n\n' . join ( errors ) ) raise CommandExecutionError ( msg ) return ret
imports content from a local tarball or a url as a new docker image source content to import .