Orchestration

Orchestration

テンプレートの作成

Orchestration サービスは、テンプレートを使用してスタックを記述します。テンプレート言語の詳細を知るには、Heat developer documentationTemplate Guide を参照してください。

  • demo-template.yml を以下の内容で作成します。

    heat_template_version: 2015-10-15
    description: Launch a basic instance with CirrOS image using the
                 ``m1.tiny`` flavor, ``mykey`` key,  and one network.
    
    parameters:
      NetID:
        type: string
        description: Network ID to use for the instance.
    
    resources:
      server:
        type: OS::Nova::Server
        properties:
          image: cirros
          flavor: m1.tiny
          key_name: mykey
          networks:
          - network: { get_param: NetID }
    
    outputs:
      instance_name:
        description: Name of the instance.
        value: { get_attr: [ server, name ] }
      instance_ip:
        description: IP address of the instance.
        value: { get_attr: [ server, first_address ] }
    

スタックの作成

demo-template.yml テンプレートを使用してスタックを作成します。

  1. demo クレデンシャルを読み込み、非管理プロジェクトとして以下の手順を実行します。

    $ . demo-openrc
    
  2. 利用可能なネットワークを確認します。

    $ openstack network list
    +--------------------------------------+-------------+--------------------------------------+
    | ID                                   | Name        | Subnets                              |
    +--------------------------------------+-------------+--------------------------------------+
    | 4716ddfe-6e60-40e7-b2a8-42e57bf3c31c | selfservice | 2112d5eb-f9d6-45fd-906e-7cabd38b7c7c |
    | b5b6993c-ddf9-40e7-91d0-86806a42edb8 | provider    | 310911f6-acf0-4a47-824e-3032916582ff |
    +--------------------------------------+-------------+--------------------------------------+
    

    注釈

    この出力は環境により異なる場合があります。

  3. ネットワークの ID が入った NET_ID 環境変数を設定します。ネットワーク provider を使用した例:

    $ export NET_ID=$(openstack network list | awk '/ provider / { print $2 }')
    
  4. プロバイダーネットワーク上に CirrOS インスタンスが 1 つあるスタックを作成します。

    $ openstack stack create -t demo-template.yml --parameter "NetID=$NET_ID" stack
    +--------------------------------------+------------+--------------------+---------------------+--------------+
    | ID                                   | Stack Name | Stack Status       | Creation Time       | Updated Time |
    +--------------------------------------+------------+--------------------+---------------------+--------------+
    | dbf46d1b-0b97-4d45-a0b3-9662a1eb6cf3 | stack      | CREATE_IN_PROGRESS | 2015-10-13T15:27:20 | None         |
    +--------------------------------------+------------+--------------------+---------------------+--------------+
    
  5. しばらくした後、スタックが正常に作成されたことを確認します。

    $ openstack stack list
    +--------------------------------------+------------+-----------------+---------------------+--------------+
    | ID                                   | Stack Name | Stack Status    | Creation Time       | Updated Time |
    +--------------------------------------+------------+-----------------+---------------------+--------------+
    | dbf46d1b-0b97-4d45-a0b3-9662a1eb6cf3 | stack      | CREATE_COMPLETE | 2015-10-13T15:27:20 | None         |
    +--------------------------------------+------------+-----------------+---------------------+--------------+
    
  6. インスタンスの名前と IP アドレスを表示して、 OpenStack クライアントの出力と比較します。

    $ openstack stack output show --all stack
    [
      {
        "output_value": "stack-server-3nzfyfofu6d4",
        "description": "Name of the instance.",
        "output_key": "instance_name"
      },
      {
        "output_value": "10.4.31.106",
        "description": "IP address of the instance.",
        "output_key": "instance_ip"
      }
    ]
    
    $ openstack server list
    +--------------------------------------+---------------------------+--------+---------------------------------+
    | ID                                   | Name                      | Status | Networks                        |
    +--------------------------------------+---------------------------+--------+---------------------------------+
    | 0fc2af0c-ae79-4d22-8f36-9e860c257da5 | stack-server-3nzfyfofu6d4 | ACTIVE | public=10.4.31.106              |
    +--------------------------------------+---------------------------+--------+---------------------------------+
    
  7. スタックを削除します。

    $ openstack stack delete --yes stack
    
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.