(self, tarfile, imagerepo, tag, move_tarball=True)
return layer_id
Import a tar file containing a simple directory tree possibly
        created with Docker export and create local image
Import a tar file containing a simple directory tree possibly
        created with Docker export and create local image
Import a tar file containing a simple directory tree possibly created with Docker export and create local image
def import_toimage(self, tarfile, imagerepo, tag, move_tarball=True):
        """Import a tar file containing a simple directory tree possibly
        created with Docker export and create local image"""
        if not os.path.exists(tarfile) and tarfile != '-':
            Msg().err("Error: tar file does not exist: ", tarfile)
            return False
        self.localrepo.setup_imagerepo(imagerepo)
        tag_dir = self.localrepo.cd_imagerepo(imagerepo, tag)
        if tag_dir:
            Msg().err("Error: tag already exists in repo:", tag)
            return False
        tag_dir = self.localrepo.setup_tag(tag)
        if not tag_dir:
            Msg().err("Error: creating repo and tag")
            return False
        if not self.localrepo.set_version("v1"):
            Msg().err("Error: setting repository version")
            return False
        layer_id = Unique().layer_v1()
        layer_file = self.localrepo.layersdir + '/' + layer_id + ".layer"
        json_file = self.localrepo.layersdir + '/' + layer_id + ".json"
        if move_tarball:
            try:
                os.rename(tarfile, layer_file)
            except(IOError, OSError):
                pass
        if not os.path.exists(layer_file):
            if not FileUtil(tarfile).copyto(layer_file):
                Msg().err("Error: in move/copy file", tarfile)
                return False
        self.localrepo.add_image_layer(layer_file)
        self.localrepo.save_json("ancestry", [layer_id])
        container_json = self.create_container_meta(layer_id)
        self.localrepo.save_json(json_file, container_json)
        self.localrepo.add_image_layer(json_file)
        Msg().out("Info: added layer", layer_id, l=Msg.INF)
        return layer_id
def import_toimage ( self , tarfile , imagerepo , tag , move_tarball = True ) : if not os . path . exists ( tarfile ) and tarfile != '-' : Msg ( ) . err ( "Error: tar file does not exist: " , tarfile ) return False self . localrepo . setup_imagerepo ( imagerepo ) tag_dir = self . localrepo . cd_imagerepo ( imagerepo , tag ) if tag_dir : Msg ( ) . err ( "Error: tag already exists in repo:" , tag ) return False tag_dir = self . localrepo . setup_tag ( tag ) if not tag_dir : Msg ( ) . err ( "Error: creating repo and tag" ) return False if not self . localrepo . set_version ( "v1" ) : Msg ( ) . err ( "Error: setting repository version" ) return False layer_id = Unique ( ) . layer_v1 ( ) layer_file = self . localrepo . layersdir + '/' + layer_id + ".layer" json_file = self . localrepo . layersdir + '/' + layer_id + ".json" if move_tarball : try : os . rename ( tarfile , layer_file ) except ( IOError , OSError ) : pass if not os . path . exists ( layer_file ) : if not FileUtil ( tarfile ) . copyto ( layer_file ) : Msg ( ) . err ( "Error: in move/copy file" , tarfile ) return False self . localrepo . add_image_layer ( layer_file ) self . localrepo . save_json ( "ancestry" , [ layer_id ] ) container_json = self . create_container_meta ( layer_id ) self . localrepo . save_json ( json_file , container_json ) self . localrepo . add_image_layer ( json_file ) Msg ( ) . out ( "Info: added layer" , layer_id , l = Msg . INF ) return layer_id