(self, imagetag_list, imagefile)
return status
Save a set of image tags to a file similarly to docker save
Save a set of image tags to a file similarly to docker save
Save a set of image tags to a file similarly to docker save
def save(self, imagetag_list, imagefile):
        """Save a set of image tags to a file similarly to docker save
        """
        tmp_imagedir = FileUtil("save").mktmp()
        try:
            os.makedirs(tmp_imagedir)
        except (IOError, OSError):
            return False
        structure = dict()
        structure["manifest"] = []
        structure["repositories"] = dict()
        status = False
        for (imagerepo, tag) in imagetag_list:
            status = self._save_image(imagerepo, tag, structure, tmp_imagedir)
            if not status:
                Msg().err("Error: save image failed:", imagerepo + ':' + tag)
                break
        if status:
            self.localrepo.save_json(tmp_imagedir + "/manifest.json",
                                     structure["manifest"])
            self.localrepo.save_json(tmp_imagedir + "/repositories",
                                     structure["repositories"])
            if not FileUtil(tmp_imagedir).tar(imagefile):
                Msg().err("Error: save image failed in writing tar", imagefile)
                status = False
        else:
            Msg().err("Error: no images specified")
        FileUtil(tmp_imagedir).remove(recursive=True)
        return status
def save ( self , imagetag_list , imagefile ) : tmp_imagedir = FileUtil ( "save" ) . mktmp ( ) try : os . makedirs ( tmp_imagedir ) except ( IOError , OSError ) : return False structure = dict ( ) structure [ "manifest" ] = [ ] structure [ "repositories" ] = dict ( ) status = False for ( imagerepo , tag ) in imagetag_list : status = self . _save_image ( imagerepo , tag , structure , tmp_imagedir ) if not status : Msg ( ) . err ( "Error: save image failed:" , imagerepo + ':' + tag ) break if status : self . localrepo . save_json ( tmp_imagedir + "/manifest.json" , structure [ "manifest" ] ) self . localrepo . save_json ( tmp_imagedir + "/repositories" , structure [ "repositories" ] ) if not FileUtil ( tmp_imagedir ) . tar ( imagefile ) : Msg ( ) . err ( "Error: save image failed in writing tar" , imagefile ) status = False else : Msg ( ) . err ( "Error: no images specified" ) FileUtil ( tmp_imagedir ) . remove ( recursive = True ) return status