#NEWLINE# def loaded( name , tag = 'latest' , source = None , source_hash = '' , force = False ) : #NEWLINE# #INDENT# "\n    Load an image into the local docker registry (`docker load`)\n\n    name\n        Name of the docker image\n\n    tag\n        tag of the image (defaults to 'latest')\n\n    source\n        The source .tar file to download to the minion, created by docker save\n        this source file can be hosted on either the salt master server,\n        or on an HTTP or FTP server.\n\n        If the file is hosted on a HTTP or FTP server then the source_hash\n        argument is also required\n\n        .. note::\n\n            See first the documentation for Salt `file.managed\n            <http://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html#salt.states.file.managed>`_\n\n    source_hash\n        This can be one of the following:\n            1. a source hash string\n            2. the URI of a file that contains source hash strings\n\n    force\n        Load even if the image exists\n    " #NEWLINE# inspect_image = __salt__ [ 'docker.inspect_image' ] #NEWLINE# image_name = _get_image_name ( name , tag ) #NEWLINE# image_infos = inspect_image ( image_name ) #NEWLINE# if ( image_infos [ 'status' ] and ( not force ) ) : #NEWLINE# #INDENT# return _valid ( name = name , comment = 'Image already loaded: {0}' . format ( image_name ) ) #NEWLINE# #UNINDENT# if __opts__ [ 'test' ] : #NEWLINE# #INDENT# comment = 'Image {0} will be loaded' . format ( image_name ) #NEWLINE# return _ret_status ( name = name , comment = comment ) #NEWLINE# #UNINDENT# tmp_filename = salt . utils . mkstemp ( ) #NEWLINE# __salt__ [ 'state.single' ] ( 'file.managed' , name = tmp_filename , source = source , source_hash = source_hash ) #NEWLINE# changes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if image_infos [ 'status' ] : #NEWLINE# #INDENT# changes [ 'old' ] = image_infos [ 'out' ] [ 'Id' ] #NEWLINE# remove_image = __salt__ [ 'docker.remove_image' ] #NEWLINE# remove_info = remove_image ( image_name ) #NEWLINE# if ( not remove_info [ 'status' ] ) : #NEWLINE# #INDENT# return _invalid ( name = name , comment = 'Image could not be removed: {0}' . format ( name ) ) #NEWLINE# #UNINDENT# #UNINDENT# load = __salt__ [ 'docker.load' ] #NEWLINE# returned = load ( tmp_filename ) #NEWLINE# image_infos = inspect_image ( image_name ) #NEWLINE# if image_infos [ 'status' ] : #NEWLINE# #INDENT# changes [ 'new' ] = image_infos [ 'out' ] [ 'Id' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return _invalid ( name = name , comment = 'Image {0} was not loaded into docker' . format ( image_name ) ) #NEWLINE# #UNINDENT# return _ret_status ( returned , name , changes = name )