Upload and Manage Content¶
The section shows how to upload content to Pulp.
Bear in mind that the attached snippets utilize pulp_http
. Refer to
Workflows to learn more about these utilities and the required
tools (httpie
and jq
).
Create a repository¶
If you don’t already have a repository called foo
, create one:
pulp_http --body POST $BASE_ADDR/pulp/api/v3/repositories/cookbook/cookbook/ name=foo
export REPO_HREF=$(http $BASE_ADDR/pulp/api/v3/repositories/cookbook/cookbook/?name=foo | jq -r '.results[0].pulp_href')
Response:
{
"description": null,
"latest_version_href": "/pulp/api/v3/repositories/cookbook/cookbook/bfd18a84-3b55-44c0-9566-7878fa73f67e/versions/0/",
"name": "foo",
"pulp_created": "2020-08-31T18:55:45.422914Z",
"pulp_href": "/pulp/api/v3/repositories/cookbook/cookbook/bfd18a84-3b55-44c0-9566-7878fa73f67e/",
"remote": null,
"versions_href": "/pulp/api/v3/repositories/cookbook/cookbook/bfd18a84-3b55-44c0-9566-7878fa73f67e/versions/"
}
Upload local cookbooks to Pulp¶
As a simple example, let’s download two cookbooks from the Chef Supermarket and
upload them into our foo
repository.
Download ‘ubuntu’ and ‘apt’ cookbooks into the current directory (the ‘ubuntu’ cookbooks depends on the ‘apt’ cookbook):
curl -Lo ubuntu-2.0.1.tgz https://supermarket.chef.io:443/api/v1/cookbooks/ubuntu/versions/2.0.1/download``
curl -Lo apt-7.0.0.tgz https://supermarket.chef.io:443/api/v1/cookbooks/apt/versions/7.0.0/download``
Now, we create a cookbook content unit (which represent a cookbook in Pulp) for each file, respectively:
pulp_http --form POST $BASE_ADDR/pulp/api/v3/content/cookbook/cookbooks/ name="ubuntu" file@ubuntu-2.0.1.tgz
export UBUNTU_CONTENT_HREF=$(http $BASE_ADDR/pulp/api/v3/content/cookbook/cookbooks/?name=ubuntu | jq -r '.results[0].pulp_href')
Response (finished task status):
{
"child_tasks": [],
"created_resources": [
"/pulp/api/v3/content/cookbook/cookbooks/ba13f4e9-93fd-405e-aad2-dd37bf7c8f80/"
],
"error": null,
"finished_at": "2020-08-31T18:55:46.846807Z",
"name": "pulpcore.app.tasks.base.general_create",
"parent_task": null,
"progress_reports": [],
"pulp_created": "2020-08-31T18:55:46.507982Z",
"pulp_href": "/pulp/api/v3/tasks/825345fc-e823-405a-8d0d-d970761fc99b/",
"reserved_resources_record": [
"/pulp/api/v3/artifacts/a91321d9-bd6f-408b-a094-f841925bf75b/"
],
"started_at": "2020-08-31T18:55:46.747676Z",
"state": "completed",
"task_group": null,
"worker": "/pulp/api/v3/workers/714038d7-7077-43c5-b980-c9be814dcaa0/"
}
And for the apt cookbook:
pulp_http --form POST $BASE_ADDR/pulp/api/v3/content/cookbook/cookbooks/ name="apt" file@apt-7.0.0.tgz
export APT_CONTENT_HREF=$(http $BASE_ADDR/pulp/api/v3/content/cookbook/cookbooks/?name=apt | jq -r '.results[0].pulp_href')
Response (finished task status):
{
"child_tasks": [],
"created_resources": [
"/pulp/api/v3/content/cookbook/cookbooks/5a7814d6-b3da-4363-a510-04ac097d4df2/"
],
"error": null,
"finished_at": "2020-08-31T18:55:48.556499Z",
"name": "pulpcore.app.tasks.base.general_create",
"parent_task": null,
"progress_reports": [],
"pulp_created": "2020-08-31T18:55:48.251165Z",
"pulp_href": "/pulp/api/v3/tasks/935b9ae7-910d-4a54-8269-e71abd647f67/",
"reserved_resources_record": [
"/pulp/api/v3/artifacts/6690ae77-b88f-4586-a99a-03404535974e/"
],
"started_at": "2020-08-31T18:55:48.456306Z",
"state": "completed",
"task_group": null,
"worker": "/pulp/api/v3/workers/714038d7-7077-43c5-b980-c9be814dcaa0/"
}
Add content to repository foo
¶
Once we have content unit(s), they can be added and removed and from to repositories, creating a new repository version (which will be the latest version):
pulp_http POST $BASE_ADDR$REPO_HREF'modify/' add_content_units:="[\"$UBUNTU_CONTENT_HREF\",\"$APT_CONTENT_HREF\"]"
export LATEST_VERSION_HREF=$(http $BASE_ADDR$REPO_HREF | jq -r '.latest_version_href')
Response (finished task status):
{
"child_tasks": [],
"created_resources": [
"/pulp/api/v3/repositories/cookbook/cookbook/bfd18a84-3b55-44c0-9566-7878fa73f67e/versions/1/"
],
"error": null,
"finished_at": "2020-08-31T18:55:50.281814Z",
"name": "pulpcore.app.tasks.repository.add_and_remove",
"parent_task": null,
"progress_reports": [],
"pulp_created": "2020-08-31T18:55:49.950397Z",
"pulp_href": "/pulp/api/v3/tasks/1abcec8b-a38b-4133-a033-94ca73971aa9/",
"reserved_resources_record": [
"/pulp/api/v3/repositories/cookbook/cookbook/bfd18a84-3b55-44c0-9566-7878fa73f67e/"
],
"started_at": "2020-08-31T18:55:50.201119Z",
"state": "completed",
"task_group": null,
"worker": "/pulp/api/v3/workers/714038d7-7077-43c5-b980-c9be814dcaa0/"
}
One Shot upload¶
TODO