5.2. ライフサイクル環境との作業

Satellite は、アプリケーションのライフサイクルを、ライフサイクル環境に分割します。ライフサイクル環境は、アプリケーションのライフサイクルの各ステージを表します。ライフサイクル環境は、環境パスからリンクされます。リンクされたライフサイクル環境を API で作成するには、prior_id パラメーターを使用します。

https://satellite.example.com/apidoc/v2/lifecycle_environments.html で、ライフサイクル環境に関する、同梱の API リファレンスを確認できます。API ルートには /katello/api/environments および /katello/api/organizations/:organization_id/environments が含まれます。

注記

以下の要求例では、python3 を使用して Satellite Server からの応答をフォーマットしています。RHEL 7 およびそれ以前の一部のシステムでは、python3 の代わりに python を使用する必要があります。

ライフサイクル環境の表示

以下の API 呼び出しを使用して、Satellite にある ID が 1 のデフォルトの組織に対する現在の全ライフサイクル環境を表示します。

要求例:

$ curl --header "Accept:application/json" \
--header "Content-Type:application/json" \
--request GET --user sat_username:sat_password --insecure \
https://satellite.example.com/katello/api/organizations/1/environments \
| python3 -m json.tool`

応答例:

      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

ライフサイクル環境のリンク作成

以下の例を使用して、ライフサイクル環境のパスを作成します。

以下の手順では、ID が 1 のデフォルトのライブラリー環境が、ライフサイクル環境作成の開始点として使用されています。

  1. 開始点として使用する既存のライフサイクル環境を選択します。その ID を使用して環境を表示します。今回の例では、ID が 1 の環境を使用します。

    要求例:

    $ curl --request GET --user sat_username:sat_password --insecure \
    https://satellite.example.com/katello/api/environments/1 \
    | python3 -m json.tool

    応答例:

    	output omitted
       "id": 1,
       "label": "Library",
    	output omitted
        "prior": null,
        "successor": null,
      output truncated
  2. 以下のコンテンツを含めて、life-cycle.json などの JSON ファイルを作成します。

    {"organization_id":1,"label":"api-dev","name":"API Development","prior":1}
  3. prior オプションを 1 に設定して、ライフサイクル環境を作成します。

    要求例:

    $ curl --header "Accept:application/json" \
    --header "Content-Type:application/json" \
    --request POST --user sat_username:sat_password --insecure \
    --data @life-cycle.json \
    https://satellite.example.com/katello/api/environments \
    | python3 -m json.tool

    応答例:

          output 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

    以下のコマンドの出力では、ライフサイクル環境の ID が 2 で、その 1 つ前のライフサイクル環境は 1 であると分かります。ID が 2 のライフサイクル環境を使用して、この環境の後継を作成します。

  4. 以前作成した life-cycle.json ファイルを編集して、labelnameprior の値を更新します。

    {"organization_id":1,"label":"api-qa","name":"API QA","prior":2}
  5. prior オプションを 2 に設定して、ライフサイクル環境を作成します。

    要求例:

    $ curl --header "Accept:application/json" \
    --header "Content-Type:application/json" \
    --request POST --user sat_username:sat_password --insecure \
    --data @life-cycle.json \
    https://satellite.example.com/katello/api/environments \
    | python3 -m json.tool

    応答例:

          output 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

    以下のコマンドの出力では、ライフサイクル環境の ID が 3 で、その 1 つ前のライフサイクル環境は 2 であると分かります。

ライフサイクル環境の更新

PUT コマンドを使用して、ライフサイクル環境を更新できます。

以下の要求例では、ID が 3 のライフサイクル環境の説明を更新します。

要求例:

$ curl --header "Accept:application/json" \
--header "Content-Type:application/json" \
--request POST --user sat_username:sat_password --insecure \
--data '{"description":"Quality Acceptance Testing"}' \
https://satellite.example.com/katello/api/environments/3 \
| python3 -m json.tool

応答例:

      output 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

ライフサイクル環境の削除

後継がない前提でライフサイクル環境を削除できます。このような理由から、以下の形式のコマンドを使用して、逆順にライフサイクル環境を削除します。

要求例:

$ curl --request DELETE --user sat_username:sat_password --insecure \
https://satellite.example.com/katello/api/environments/:id