Show Table of Contents
4.6. Working with Life Cycle Environments
As explained in the Life Cycle Environments section of the Architecture Guide, application life cycles are divided into life cycle environments, which represent each stage of the application life cycle. Life cycle environments are linked to from an environment path. To create linked Life Cycle Environments using the API, make use of the
prior_id parameter.
You can find the built-in API reference for Life Cycle Environments at
https://satellite6.example.com/apidoc/v2/lifecycle_environments.html. The API routes include /katello/api/environments and /katello/api/organizations/:organization_id/environments.
You can list all the current Life Cycle Environments on your Satellite, for the default organization
1, as follows:
$curl -H "Accept:application/json,version=2" \-H "Content-Type:application/json" -X GET \-u sat_user:sat_password -k \https://satellite6.example.com/katello/api/organizations/1/environments | python -m json.tool
A newly installed Satellite would have an output with a section similar to the following:
output omitted "description": null, "id": 1, "label": "Library", "library": true, "name": "Library", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": false, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": null, "successor": null, output truncated
In the procedure below the default Library environment, with ID
1, is used as the starting point for creating Life Cycle Environments.
Procedure 4.3. Creating Linked Life Cycle Environments
- Choose an existing Life Cycle Environment that you want to use as a starting point. List the environment using its ID, in this case the environment with ID
1:$
curl -X GET -s -k -u sat_user:sat_password \https://satellite6.example.com/katello/api/environments/1 | python -m json.tooloutput omitted "id": 1, "label": "Library", output omitted "prior": null, "successor": null, output truncated - Create a new Life Cycle Environment using the
prioroption set to1:- Create a JSON file, for example,
life-cycle.json, with the following contents:{"organization_id":1,"label":"api-dev","name":"API Development","prior":1} - Enter a command as follows:
$
curl -H "Accept:application/json,version=2" \-H "Content-Type:application/json" -X POST \-u sat_user:sat_password -k \-d @life-cycle.json \https://satellite6.example.com/katello/api/environments \| python -m json.tooloutput omitted "description": null, "id": 2, "label": "api-dev", "library": false, "name": "API Development", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 1, "name": "Library" }, output truncated
In the command output you can see the ID for this Life Cycle Environment is2, and the Life Cycle Environment prior to this one is1. This signifies that Life Cycle Environment1and2are linked. The Life Cycle Environment ID2is used when creating a successor to this environment. - Create another Life Cycle Environment, using the
prioroption set to2:- Edit the previously created
life-cycle.json, updating thelabel,name, andpriorvalues:{"organization_id":1,"label":"api-qa","name":"API QA","prior":2} - Enter a command as follows:
$
curl -H "Accept:application/json,version=2" \-H "Content-Type:application/json" -X POST \-u sat_user:sat_password -k \-d @life-cycle.json \https://satellite6.example.com/katello/api/environments \| python -m json.tooloutput omitted "description": null, "id": 3, "label": "api-qa", "library": false, "name": "API QA", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 2, "name": "API Development" }, "successor": null, output truncated
In the command output you can see the ID for this Life Cycle Environment is3, and the Life Cycle Environment prior to this one is2. This signifies that Life Cycle Environment2and3are linked.
Updating a Life Cycle Environment
A Life Cycle Environment can be updated using a PUT command. For example:
$curl -H "Accept:application/json,version=2" \-H "Content-Type:application/json" -X POST \-u sat_user:sat_password -k \-d '{"description":"Quality Acceptance Testing"}' \https://satellite6.example.com/katello/api/environments/3 \| python -m json.tooloutput omitted "description": "Quality Acceptance Testing", "id": 3, "label": "api-qa", "library": false, "name": "API QA", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 2, "name": "API Development" }, output truncated
Deleting a Life Cycle Environment
A Life Cycle Environment can be deleted provided it has no successor. Therefore, delete them in reverse order using a command in the following format:
curl -X DELETE -s -k -u sat_user:sat_password https://satellite6.example.com/katello/api/environments/:id

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.