Exemplo n.º 1
0
    def relate_blob(self, dc):
        """
        Relate a Blob to a Manifest.

        Args:
            dc (pulpcore.plugin.stages.DeclarativeContent): dc for a Blob

        """
        related_dc = dc.extra_data.get('blob_relation')
        thru = BlobManifest(manifest=related_dc.content, manifest_blob=dc.content)
        try:
            thru.save()
        except IntegrityError:
            pass
Exemplo n.º 2
0
    def relate_blob(self, dc):
        """
        Relate a Blob to a Manifest.

        Args:
            dc (pulpcore.plugin.stages.DeclarativeContent): dc for a Manifest
        """
        related_dc_id_list = dc.extra_data.get('blob_rel')
        # find blob by id
        # We are relying on the order of the processed DC
        # Blobs should have passed through ContentSaver stage already
        blob_list = Blob.objects.filter(digest__in=related_dc_id_list)
        for blob in blob_list:
            thru = BlobManifest(manifest=dc.content, manifest_blob=blob)
            thru.save()
Exemplo n.º 3
0
def get_or_create_blob(layer_json, manifest, path):
    """
    Creates Blob from json snippet of manifest.json

    Args:
        layer_json (json): json
        manifest (class:`pulp_container.app.models.Manifest`): The manifest
        path (str): Path of the directory that contains layer

    Returns:
        class:`pulp_container.app.models.Blob`

    """
    try:
        blob = Blob.objects.get(digest=layer_json["digest"])
    except Blob.DoesNotExist:
        layer_file_name = "{}{}".format(path, layer_json["digest"][7:])
        layer_artifact = Artifact.init_and_validate(layer_file_name)
        layer_artifact.save()
        blob = Blob(digest=layer_json["digest"],
                    media_type=layer_json["mediaType"])
        blob.save()
        ContentArtifact(artifact=layer_artifact,
                        content=blob,
                        relative_path=layer_json["digest"]).save()
    if blob.media_type != MEDIA_TYPE.CONFIG_BLOB_OCI:
        BlobManifest(manifest=manifest, manifest_blob=blob).save()
    return blob
Exemplo n.º 4
0
    def relate_blob(self, dc):
        """
        Relate a Blob to a Manifest.

        Args:
            dc (pulpcore.plugin.stages.DeclarativeContent): dc for a Blob

        Returns:
            pulp_container.app.models.BlobManifest: A new BlobManifest object with the added
                reference to a Manifest object

        """
        related_dc = dc.extra_data.get("blob_relation")
        return BlobManifest(manifest=related_dc.content, manifest_blob=dc.content)