CentOS 7
Sponsored Link

OpenStack Mitaka : How to use Heat2016/05/12

 
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: 2016-04-08

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    |
+--------------------------------------+---------+
| cd41a1b9-9ba6-4681-9310-e4befaf71fa5 | CentOS7 |
+--------------------------------------+---------+

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

+--------------------------------------+---------+-------------------------------------------------------+
| id                                   | name    | subnets                                               |
+--------------------------------------+---------+-------------------------------------------------------+
| 550b379c-90f6-4cff-8063-88167dc7c568 | ext_net | 702832ef-4de5-41ba-9c2c-de2450d15ab0 10.0.0.0/24      |
| a8705bd3-c2de-4526-aa7c-2c4605a6edf4 | int_net | f29ee9fd-7bae-40d8-8d4c-a1340092f258 192.168.100.0/24 |
+--------------------------------------+---------+-------------------------------------------------------+

[root@dlp ~(keystone)]#
Int_Net_ID=`neutron net-list | grep int_net | 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 |
+--------------------------------------+--------------+--------------------+---------------------+--------------+
| 66b7f3f2-9fb3-4b7c-adf8-b1be85990a6e | Sample-Stack | CREATE_IN_PROGRESS | 2016-05-12T12:49:03 | 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 |
+--------------------------------------+--------------+-----------------+---------------------+--------------+
| 66b7f3f2-9fb3-4b7c-adf8-b1be85990a6e | Sample-Stack | CREATE_COMPLETE | 2016-05-12T12:49:03 | 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                          |
+--------------------------------------+----------------------+---------+------------+-------------+-----------------------------------+
| 4e232450-4cae-47ba-a19a-1c59e3cbc91b | CentOS_7             | SHUTOFF | -          | Shutdown    | int_net=192.168.100.3, 10.0.0.201 |
| 7b91f594-100d-4d84-a78b-952c6a1abb98 | Heat_Deployed_Server | ACTIVE  | -          | Running     | int_net=192.168.100.4             |
+--------------------------------------+----------------------+---------+------------+-------------+-----------------------------------+

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

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

Are you sure you want to delete this stack(s) [y/N]?
y

+--------------------------------------+--------------+-----------------+---------------------+--------------+
| id                                   | stack_name   | stack_status    | creation_time       | updated_time |
+--------------------------------------+--------------+-----------------+---------------------+--------------+
| 66b7f3f2-9fb3-4b7c-adf8-b1be85990a6e | Sample-Stack | CREATE_COMPLETE | 2016-05-12T12:49:03 | 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