读文章笔记:Creating a Project, Networks and VMs only using Heat

$ openstack --version
openstack 2.2.0
$ glance image-create --name cirros --file ./cirros-0.3.5-x86_64-disk.img --container-format bare --disk-format qcow2

1 要搭建的 Neutron 网络和虚拟机

读文章笔记:Creating a Project, Networks and VMs only using Heat_第1张图片
image.png

2 Heat Orchestration Template (HOT)

创建一个文本文件 simple_net.yaml,其内容非常直观的描述了上图中的网络和虚拟机。

heat_template_version: 2015-04-30

description: Simple template to deploy a network with two VMs.

resources:
   simple_net:
      type: OS::Neutron::Net
      properties:
         name: GREEN

   simple_subnet:
      type: OS::Neutron::Subnet
      properties:
         network_id: { get_resource: simple_net }
         name: 10_10_10
         cidr: 10.10.10.0/24

   VM1:
      type: OS::Nova::Server
      properties:
         name: VM1
         image: cirros
         flavor: m1.small
         networks:
            - network: { get_resource: simple_net }

   VM2:
      type: OS::Nova::Server
      properties:
         name: VM2
         image: cirros
         flavor: m1.small
         networks:
            - network: { get_resource: simple_net }

3 创建 stack

$ heat stack-create -f simple_net.yaml xxx
$ heat stack-list
+--------------------------------------+------------+-----------------+----------------------------+
| id                                   | stack_name | stack_status    | creation_time              |
+--------------------------------------+------------+-----------------+----------------------------+
| 56db34be-3336-4be1-8236-8b88539cb23e | xxx        | CREATE_COMPLETE | 2017-11-13T02:38:46.962819 |
+--------------------------------------+------------+-----------------+----------------------------+

$ neutron net-list --name GREEN
+-------------------------------+-------+-------------------------------+
| id                            | name  | subnets                       |
+-------------------------------+-------+-------------------------------+
| b7bf52b1-cbc2-41e4-a05b-      | GREEN | 83c35c90-8fba-                |
| 283f350be27d                  |       | 4f31-9923-5f7e2922beb8        |
|                               |       | 10.10.10.0/24                 |
+-------------------------------+-------+-------------------------------+

$ nova list
+--------------------------------------+------+--------+------------+-------------+------------------+
| ID                                   | Name | Status | Task State | Power State | Networks         |
+--------------------------------------+------+--------+------------+-------------+------------------+
| e85586f7-95ef-4de5-867f-ef81892c02c9 | VM1  | ACTIVE | -          | Running     | GREEN=10.10.10.3 |
| 8d61338e-0f48-4aeb-939d-bc0cd21867ce | VM2  | ACTIVE | -          | Running     | GREEN=10.10.10.4 |
+--------------------------------------+------+--------+------------+-------------+------------------+

通过 OpenStack 的 dash board 可以登陆 VM1 的串口终端,从 VM1 可以 ping VM2。

4 总结

创建这个 Neutron 网络,子网,还有 Nova 虚拟机的过程可以一步一步通过不同的命令来创建。Stack 就是把这些独立的步骤捆绑在一起的一个概念。

文章网址

https://linuxsimba.com/openstack-heat-network-testing

你可能感兴趣的:(读文章笔记:Creating a Project, Networks and VMs only using Heat)