pulp_example Plugin
This is the pulp_example Plugin for Pulp Project
3.0+. It is an example of
how to use the Pulp Plugin API to add a custom content type to Pulp.
All REST API examples bellow use httpie to perform the requests.
Install pulpcore
Follow the installation instructions provided with pulpcore.
Install pulp_example plugin
From source
- sudo -u pulp -i
- source ~/pulpvenv/bin/activate
- git clone https://github.com/pulp/pulp_example.git
- cd pulp_example
- python setup.py develop
- pulp-manager makemigrations pulp_example
- pulp-manager migrate pulp_example
- django-admin runserver
- sudo systemctl restart pulp_worker@1
- sudo systemctl restart pulp_worker@2
Install from PyPI
- sudo -u pulp -i
- source ~/pulpvenv/bin/activate
- pip install pulp-example
- pulp-manager makemigrations pulp_example
- pulp-manager migrate pulp_example
- django-admin runserver
- sudo systemctl restart pulp_worker@1
- sudo systemctl restart pulp_worker@2
Create a repository foo
$ http POST http://localhost:8000/api/v3/repositories/ name=foo
Add an importer to repository foo
pulp_example provides two importer types: example-asyncio and
example-futures. Only one importer can be associated with the
repository.
An example-asyncio importer can be added to the repository foo:
$ http POST http://localhost:8000/api/v3/repositories/foo/importers/example-asyncio/ name='bar' download_policy='immediate' sync_mode='mirror' feed_url='https://repos.fedorapeople .org/pulp/pulp/demo_repos/test_file_repo/PULP_MANIFEST'
{
"_href": "http://localhost:8000/api/v3/repositories/foo/importers/example-asyncio/bar/",
...
}An example-futures importer can be added to the repository foo:
$ http POST http://localhost:8000/api/v3/repositories/foo/importers/example-futures/ name='bar' download_policy='immediate' sync_mode='mirror' feed_url='https://repos.fedorapeople .org/pulp/pulp/demo_repos/test_file_repo/PULP_MANIFEST'
{
"_href": "http://localhost:8000/api/v3/repositories/foo/importers/example-futures/bar/",
...
}Add an example Publisher to repository foo
$ http POST http://localhost:8000/api/v3/repositories/foo/publishers/example/ name=bar
{
"_href": "http://localhost:8000/api/v3/repositories/foo/publishers/example/bar/",
...
}Add a Distribution to Publisher bar
$ http POST http://localhost:8000/api/v3/repositories/foo/publishers/example/bar/distributions/ name='baz' base_path='foo' auto_updated=true http=true https=true
Sync repository foo using importer bar
example-asyncio importer:
http POST http://localhost:8000/api/v3/repositories/foo/importers/example-asyncio/bar/sync/
example-futures importer:
http POST http://localhost:8000/api/v3/repositories/foo/importers/example-futures/bar/sync/
Upload foo.tar.gz to Pulp
Create an Artifact by uploading the file to Pulp.
$ http --form POST http://localhost:8000/api/v3/artifacts/ file@./foo.tar.gz
{
"_href": "http://localhost:8000/api/v3/artifacts/7d39e3f6-535a-4b6e-81e9-c83aa56aa19e/",
...
}Create example content from an Artifact
Create a file with the json bellow and save it as content.json.
{
"digest": "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c",
"path": "foo.tar.gz",
"artifacts": {"foo.tar.gz":"http://localhost:8000/api/v3/artifacts/7d39e3f6-535a-4b6e-81e9-c83aa56aa19e/"}
}$ http POST http://localhost:8000/api/v3/content/example/ < content.json
{
"_href": "http://localhost:8000/api/v3/content/example/a9578a5f-c59f-4920-9497-8d1699c112ff/",
"artifacts": {
"foo.tar.gz": "http://localhost:8000/api/v3/artifacts/7d39e3f6-535a-4b6e-81e9-c83aa56aa19e/"
},
"digest": "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c",
"notes": {},
"path": "foo.tar.gz",
"type": "example"
}Add content to repository foo
$ http POST http://localhost:8000/api/v3/repositorycontents/ repository='http://localhost:8000/api/v3/repositories/foo/' content='http://localhost:8000/api/v3/content/example/a9578a5f-c59f-4920-9497-8d1699c112ff/'
Create a Publication using Publisher bar
Dispatch the Publish task
$ http POST http://localhost:8000/api/v3/repositories/foo/publishers/example/bar/publish/
[
{
"_href": "http://localhost:8000/api/v3/tasks/fd4cbecd-6c6a-4197-9cbe-4e45b0516309/",
"task_id": "fd4cbecd-6c6a-4197-9cbe-4e45b0516309"
}
]Check status of a task
$ http GET http://localhost:8000/api/v3/tasks/82e64412-47f8-4dd4-aa55-9de89a6c549b/
Download foo.tar.gz from Pulp
$ http GET http://localhost:8000/content/foo/foo.tar.gz