CentOS 7
Sponsored Link

OpenStack Liberty : How to use Heat2015/11/19

 
How to use the OpenStack Orchestration Service (Heat).
This example is based on the environment like follows.
                                |
+------------------+            |            +------------------------+
| [ Control Node ] |            |            |    [ Network Node ]    |
|     Keystone     |10.0.0.30   |   10.0.0.50|    DHCP,L3,L2 Agent    |
|      Glance      |------------+------------|     Metadata Agent     |
|     Nova API     |eth0        |        eth0|    Heat API,API-CFN    |
|  Neutron Server  |            |            |       Heat Engine      |
+------------------+            |            +------------------------+
                            eth0|10.0.0.51
                      +--------------------+
                      |  [ Compute Node ]  |
                      |    Nova Compute    |
                      |      L2 Agent      |
                      +--------------------+

[1] Deploy Instances with Heat services and templates. The example below is on the Controle Node.
# create a template for test

[root@dlp ~(keystone)]#
vi sample-stack.yml
heat_template_version: 2014-10-16

description: Heat Sample Template

parameters:
  ImageID:
    type: string
    description: Image used to boot a server
  NetID:
    type: string
    description: Network ID for the server

resources:
  server1:
    type: OS::Nova::Server
    properties:
      name: "Heat_Deployed_Server"
      image: { get_param: ImageID }
      flavor: "m1.small"
      networks:
      - network: { get_param: NetID }

outputs:
  server1_private_ip:
    description: IP address of the server in the private network
    value: { get_attr: [ server1, first_address ] }

[root@dlp ~(keystone)]#
glance image-list

+--------------------------------------+---------+
| ID                                   | Name    |
+--------------------------------------+---------+
| 34beed31-2971-43f0-9c5a-d39d3df1d501 | CentOS7 |
+--------------------------------------+---------+

[root@dlp ~(keystone)]#
neutron net-list

+--------------------------------------+------------+--------------------------------------------------+
| id                                   | name       | subnets                                          |
+--------------------------------------+------------+--------------------------------------------------+
| 1ccd61ea-f82b-42a8-bc2e-03b9c38c62c7 | sharednet1 | 641dcbd3-1eb2-45ab-b8af-4fccf009c226 10.0.0.0/24 |
+--------------------------------------+------------+--------------------------------------------------+

[root@dlp ~(keystone)]#
Int_Net_ID=`neutron net-list | grep sharednet1 | awk '{ print $2 }'`
# create an instance from the template

[root@dlp ~(keystone)]#
heat stack-create -f sample-stack.yml -P "ImageID=CentOS7;NetID=$Int_Net_ID" Sample-Stack

+--------------------------------------+--------------+--------------------+---------------------+--------------+
| id                                   | stack_name   | stack_status       | creation_time       | updated_time |
+--------------------------------------+--------------+--------------------+---------------------+--------------+
| 896d7443-65b9-4855-9ca9-60317fca5c9c | Sample-Stack | CREATE_IN_PROGRESS | 2015-11-19T12:21:18 | None         |
+--------------------------------------+--------------+--------------------+---------------------+--------------+

# turn to "CREATE_COMPLETE" after few minutes later like follows

[root@dlp ~(keystone)]#
heat stack-list

+--------------------------------------+--------------+-----------------+---------------------+--------------+
| id                                   | stack_name   | stack_status    | creation_time       | updated_time |
+--------------------------------------+--------------+-----------------+---------------------+--------------+
| 896d7443-65b9-4855-9ca9-60317fca5c9c | Sample-Stack | CREATE_COMPLETE | 2015-11-19T12:21:18 | None         |
+--------------------------------------+--------------+-----------------+---------------------+--------------+

# the instance is running which is created from the Heat template

[root@dlp ~(keystone)]#
nova list

+-----------+----------------------+---------+------------+-------------+-----------------------+
| ID        | Name                 | Status  | Task State | Power State | Networks              |
+-----------+----------------------+---------+------------+-------------+-----------------------+
| 74a217fa- | CentOS_7             | SHUTOFF | -          | Shutdown    | sharednet1=10.0.0.202 |
| 945b1446- | Heat_Deployed_Server | ACTIVE  | -          | Running     | sharednet1=10.0.0.215 |
+-----------+----------------------+---------+------------+-------------+-----------------------+

# delete the instance likwe follows if you don't need

[root@dlp ~(keystone)]#
heat stack-delete Sample-Stack

+-----------+--------------+-----------------+---------------------+--------------+
| id        | stack_name   | stack_status    | creation_time       | updated_time |
+-----------+--------------+-----------------+---------------------+--------------+
| 896d7443- | Sample-Stack | CREATE_COMPLETE | 2015-11-19T12:21:18 | None         |
+-----------+--------------+-----------------+---------------------+--------------+

[root@dlp ~(keystone)]#
heat stack-list

+----+------------+--------------+---------------+
| id | stack_name | stack_status | creation_time |
+----+------------+--------------+---------------+
+----+------------+--------------+---------------+
[2]
The guide for writing templates are opened on the official site below.
⇒ http://docs.openstack.org/developer/heat/template_guide/index.html
Matched Content