(self, imagerepo, tag)
return files
Pull container with v2 API
Pull container with v2 API
Pull container with v2 API
def get_v2(self, imagerepo, tag):
        """Pull container with v2 API"""
        files = []
        (hdr_data, manifest) = self.get_v2_image_manifest(imagerepo, tag)
        status = self.curl.get_status_code(hdr_data["X-ND-HTTPSTATUS"])
        if status == 401:
            Msg().err("Error: manifest not found or not authorized")
            return []
        if status != 200:
            Msg().err("Error: pulling manifest:")
            return []
        try:
            if not (self.localrepo.setup_tag(tag) and
                    self.localrepo.set_version("v2")):
                Msg().err("Error: setting localrepo v2 tag and version")
                return []
            self.localrepo.save_json("manifest", manifest)
            Msg().out("Info: v2 layers: %s" % (imagerepo), l=Msg.DBG)
            if "fsLayers" in manifest:
                files = self.get_v2_layers_all(imagerepo,
                                               manifest["fsLayers"])
            elif "layers" in manifest:
                if "config" in manifest:
                    manifest["layers"].append(manifest["config"])
                files = self.get_v2_layers_all(imagerepo,
                                               manifest["layers"])
            else:
                Msg().err("Error: layers section missing in manifest")
        except (KeyError, AttributeError, IndexError, ValueError, TypeError):
            pass
        return files
def get_v2 ( self , imagerepo , tag ) : files = [ ] ( hdr_data , manifest ) = self . get_v2_image_manifest ( imagerepo , tag ) status = self . curl . get_status_code ( hdr_data [ "X-ND-HTTPSTATUS" ] ) if status == 401 : Msg ( ) . err ( "Error: manifest not found or not authorized" ) return [ ] if status != 200 : Msg ( ) . err ( "Error: pulling manifest:" ) return [ ] try : if not ( self . localrepo . setup_tag ( tag ) and self . localrepo . set_version ( "v2" ) ) : Msg ( ) . err ( "Error: setting localrepo v2 tag and version" ) return [ ] self . localrepo . save_json ( "manifest" , manifest ) Msg ( ) . out ( "Info: v2 layers: %s" % ( imagerepo ) , l = Msg . DBG ) if "fsLayers" in manifest : files = self . get_v2_layers_all ( imagerepo , manifest [ "fsLayers" ] ) elif "layers" in manifest : if "config" in manifest : manifest [ "layers" ] . append ( manifest [ "config" ] ) files = self . get_v2_layers_all ( imagerepo , manifest [ "layers" ] ) else : Msg ( ) . err ( "Error: layers section missing in manifest" ) except ( KeyError , AttributeError , IndexError , ValueError , TypeError ) : pass return files