(self, imagerepo, tag)
return files
Pull container with v1 API
Pull container with v1 API
Pull container with v1 API
def get_v1(self, imagerepo, tag):
        """Pull container with v1 API"""
        Msg().out("Info: v1 image id: %s" % (imagerepo), l=Msg.DBG)
        (hdr_data, images_array) = self.get_v1_repo(imagerepo)
        status = self.curl.get_status_code(hdr_data["X-ND-HTTPSTATUS"])
        if status == 401 or not images_array:
            Msg().err("Error: image not found or not authorized")
            return []
        try:
            endpoint = "http://" + hdr_data["x-docker-endpoints"]
        except KeyError:
            endpoint = self.index_url
        (tags_array) = self.get_v1_image_tags(endpoint, imagerepo)
        image_id = self._get_v1_id_from_tags(tags_array, tag)
        if not image_id:
            Msg().err("Error: image tag not found")
            return []
        if len(image_id) <= 8:
            image_id = self._get_v1_id_from_images(images_array, image_id)
            if not image_id:
                Msg().err("Error: image id not found")
                return []
        if not (self.localrepo.setup_tag(tag) and
                self.localrepo.set_version("v1")):
            Msg().err("Error: setting localrepo v1 tag and version")
            return []
        Msg().out("Info: v1 ancestry", image_id, l=Msg.DBG)
        (dummy, ancestry) = self.get_v1_image_ancestry(endpoint, image_id)
        if not ancestry:
            Msg().err("Error: ancestry not found")
            return []
        self.localrepo.save_json("ancestry", ancestry)
        Msg().out("Info: v1 layers", image_id, l=Msg.DBG)
        files = self.get_v1_layers_all(endpoint, ancestry)
        return files
def get_v1 ( self , imagerepo , tag ) : Msg ( ) . out ( "Info: v1 image id: %s" % ( imagerepo ) , l = Msg . DBG ) ( hdr_data , images_array ) = self . get_v1_repo ( imagerepo ) status = self . curl . get_status_code ( hdr_data [ "X-ND-HTTPSTATUS" ] ) if status == 401 or not images_array : Msg ( ) . err ( "Error: image not found or not authorized" ) return [ ] try : endpoint = "http://" + hdr_data [ "x-docker-endpoints" ] except KeyError : endpoint = self . index_url ( tags_array ) = self . get_v1_image_tags ( endpoint , imagerepo ) image_id = self . _get_v1_id_from_tags ( tags_array , tag ) if not image_id : Msg ( ) . err ( "Error: image tag not found" ) return [ ] if len ( image_id ) <= 8 : image_id = self . _get_v1_id_from_images ( images_array , image_id ) if not image_id : Msg ( ) . err ( "Error: image id not found" ) return [ ] if not ( self . localrepo . setup_tag ( tag ) and self . localrepo . set_version ( "v1" ) ) : Msg ( ) . err ( "Error: setting localrepo v1 tag and version" ) return [ ] Msg ( ) . out ( "Info: v1 ancestry" , image_id , l = Msg . DBG ) ( dummy , ancestry ) = self . get_v1_image_ancestry ( endpoint , image_id ) if not ancestry : Msg ( ) . err ( "Error: ancestry not found" ) return [ ] self . localrepo . save_json ( "ancestry" , ancestry ) Msg ( ) . out ( "Info: v1 layers" , image_id , l = Msg . DBG ) files = self . get_v1_layers_all ( endpoint , ancestry ) return files