5.3. Uploading Content to the Satellite Server

This section outlines how to use the Satellite 6 API to upload and import large files to your Satellite Server. This process involves four steps:

  1. Create an upload request.
  2. Upload the content.
  3. Import the content.
  4. Delete the upload request.

The maximum file size that you can upload is 2MB. For information about uploading larger content, see Uploading Content Larger than 2 MB.

Procedure

  1. Create the upload request. Ensure you modify the example parameters to suit your deployment.

    Example request:

    $ curl --header "Accept:application/json,version=2" \
    --header "Content-Type:application/json" \
    --request POST --insecure \
    --user sat_username:sat_password  --data "{}" \
    https://satellite.example.com/katello/api/repositories/3/content_uploads

    This command returns the upload_id.

    Example response:

    {"upload_id":"0be156b1-f373-4cad-89d0-924f8f4491d2","_href":"/pulp/api/v2/content/uploads/0be156b1-f373-4cad-89d0-924f8f4491d2/"}

    Note the upload_id for uploading the content.

  2. Upload your content. Ensure you use the correct MIME type when you upload data. The API uses the application/json MIME type for the majority of requests to Satellite 6. Combine the upload_id, MIME type, and other parameters to upload content.

    Example request:

    $ curl --header "Accept:application/json,version=2" \
    --header "Content-Type:multipart/form-data" \
    --request PUT --insecure --user sat_username:sat_password \
    --data-urlencode "content@/home/sat6user/rpmbuild/RPMS/noarch/python-scripttest-1.1.1-1.fc21.noarch.rpm" \
    --data-urlencode offset=0 \
    https://satellite.example.com/katello/api/repositories/3/content_uploads/0be156b1-f373-4cad-89d0-924f8f4491d2
  3. After you have uploaded the content to the Satellite Server, you need to import it into the appropriate repository. Until you complete this step, the Satellite Server does not detect the new content.

    Example request:

    $ curl --header "Accept:application/json,version=2" \
    --header "Content-Type:application/json" \
    --request PUT --insecure \
    --user sat_username:sat_password \
    --data "{\"uploads\":[\"0be156b1-f373-4cad-89d0-924f8f4491d2\"]}" \
    https://satellite.example.com/katello/api/repositories/3/import_uploads
  4. After you have successfully uploaded and imported your content, you can delete the upload request. This frees any temporary disk space that data is using during the upload.

    Example request:

    $ curl --header "Accept:application/json,version=2" \
    --header "Content-Type:application/json" \
    --request DELETE --insecure \
    --user sat_username:sat_password --data "{}" \
    https://satellite.example.com/katello/api/repositories/3/content_uploads/0be156b1-f373-4cad-89d0-924f8f4491d2

Uploading Content Larger than 2 MB

The following example demonstrates how to split a large file into chunks, create an upload request, upload the individual files, import them to Satellite, and then delete the upload request. Note that this example uses sample content, host names, user names, and file names.

  1. Use the following example to split your file into 2MB chunks:

    $ split --bytes 2MB --numeric-suffixes --suffix-length=1 \
    theforeman-foreman-5.0.1.tar.gz foreman_module.
  2. View the resulting files:

    $ ls -la theforeman-foreman-5.0.1.tar.gz foreman_module.*
    -rw-r--r--. 1 root root 50000 Nov  4 04:42 foreman_module.0
    -rw-r--r--. 1 root root 32928 Nov  4 04:42 foreman_module.1
    -rw-r--r--. 1 root root 82928 Nov  4 04:41 theforeman-foreman-5.0.1.tar.gz
  3. Create an upload request.

    Example request:

    $ curl --header "Accept:application/json,version=2" \
    --header "Content-Type:application/json" \
    --request POST --insecure --user sat_username:sat_password --data "{}" \
    https://ibm-vm01.example.com/katello/api/repositories/2/content_uploads

    Example response:

    {"upload_id":"9585528f-07ad-4bb1-9c80-ccece249b2b7","_href":"/pulp/api/v2/content/uploads/9585528f-07ad-4bb1-9c80-ccece249b2b7/"}

    Note the upload_id for uploading the content.

  4. Upload the file chunks to Satellite Server. Notice the use of the offset parameter in this example and how it relates to the file size:

    Example request:

    $ curl --header "Accept:application/json,version=2" \
    --header "Content-Type:multipart/form-data" \
    --request PUT --insecure --user sat_username:sat_password \
    --data-urlencode "content@foreman_module.0" \
    --data-urlencode offset=0 \
    https://ibm-vm01.example.com/katello/api/repositories/2/content_uploads/9585528f-07ad-4bb1-9c80-ccece249b2b7
  5. Import the complete upload to the repository:

    $ curl --header "Accept:application/json,version=2" \
    --header "Content-Type:application/json" \
    --request PUT --insecure --user sat_username:sat_password \
    --data "{\"upload_ids\":[\"9585528f-07ad-4bb1-9c80-ccece249b2b7\"]}" \
    https://ibm-vm01.example.com/katello/api/repositories/2/import_uploads
  6. Delete the upload request:

    $ curl --header "Accept:application/json,version=2" \
    --header "Content-Type:application/json" \
    --request DELETE --insecure --user sat_username:sat_password --data "{}" \
    https://ibm-vm01.example.com/katello/api/repositories/2/content_uploads/9585528f-07ad-4bb1-9c80-ccece249b2b7
  7. On Satellite Server, check the transferred file:

    # ls -la /var/lib/pulp/content/puppet_module/theforeman-foreman-5.0.1.tar.gz
    -rw-r--r--. 1 apache apache 82928 Nov  4 04:55 /var/lib/pulp/content/puppet_module/theforeman-foreman-5.0.1.tar.gz
  8. Verify that the initial file is the same as the transferred by comparing them:

    $ cmp /var/lib/pulp/content/puppet_module/theforeman-foreman-5.0.1.tar.gz \
    theforeman-foreman-5.0.1.tar.gz