Ejemplo n.º 1
0
def upload(
    pulp_ctx: PulpContext,
    entity_ctx: PulpFileContentContext,
    relative_path: str,
    file: IO[bytes],
    chunk_size: int,
) -> None:
    """Create a file content unit by uploading a file"""
    artifact_href = PulpArtifactContext(pulp_ctx).upload(file, chunk_size)
    content = {"relative_path": relative_path, "artifact": artifact_href}
    result = entity_ctx.create(body=content)
    pulp_ctx.output_result(result)
Ejemplo n.º 2
0
def create(
    pulp_ctx: PulpContext,
    entity_ctx: PulpFileContentContext,
    relative_path: str,
    sha256: str,
) -> None:
    """Create a file content unit from an existing artifact"""
    artifact = PulpArtifactContext(pulp_ctx).find(sha256=sha256)
    content = {
        "relative_path": relative_path,
        "artifact": artifact["pulp_href"]
    }
    task = entity_ctx.create(body=content)
    result = entity_ctx.show(task["created_resources"][0])
    pulp_ctx.output_result(result)