#NEWLINE# def save( image , filename ) : #NEWLINE# #INDENT# "\n    .. versionadded:: 2015.5.0\n\n    Save the specified image to filename from docker\n    e.g. `docker save image > filename`\n\n    image\n        name of image\n\n    filename\n        The filename of the saved docker image\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' docker.save arch_image /path/to/save/image\n    " #NEWLINE# status = base_status . copy ( ) #NEWLINE# ok = False #NEWLINE# try : #NEWLINE# #INDENT# _info = _get_image_infos ( image ) #NEWLINE# ok = True #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# _invalid ( status , id_ = image , comment = 'docker image {0} could not be found.' . format ( image ) , out = traceback . format_exc ( ) ) #NEWLINE# #UNINDENT# if ok : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# dockercmd = [ 'docker' , 'save' , '-o' , filename , image ] #NEWLINE# ret = __salt__ [ 'cmd.run' ] ( dockercmd ) #NEWLINE# if ( isinstance ( ret , dict ) and ( 'retcode' in ret ) and ( ret [ 'retcode' ] != 0 ) ) : #NEWLINE# #INDENT# return _invalid ( status , id_ = image , out = ret , comment = 'Command to save image {0} to {1} failed.' . format ( image , filename ) ) #NEWLINE# #UNINDENT# _valid ( status , id_ = image , out = ret , comment = 'Image save success' ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# _invalid ( status , id_ = image , comment = 'Image not saved.' , out = traceback . format_exc ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# return status