openstack heat template之stack管理

创建heat stack:

$ git clone https://git.openstack.org/openstack/heat-templates

$ 设置默认的flavor,image,admin_pass,使用如下命令指定连接cloud的key的名字

$ openstack stack create --template heat-templates/hot/hello_world.yaml --parameter "key_name=ohn-12" MYSTACK
+---------------------+---------------------------------------------------------------------------------------------------------------------+
| Field               | Value                                                                                                               |
+---------------------+---------------------------------------------------------------------------------------------------------------------+
| id                  | 1850b4cd-6df6-4db7-98e0-84fa71df2cf9                                                                                |
| stack_name          | MYSTACK                                                                                                             |
| description         | Hello world HOT template that just defines a single server. Contains just base features to verify base HOT support. |
|                     |                                                                                                                     |
| creation_time       | 2019-01-09T09:33:35Z                                                                                                |
| updated_time        | None                                                                                                                |
| stack_status        | CREATE_IN_PROGRESS                                                                                                  |
| stack_status_reason | Stack CREATE started                                                                                                |
+---------------------+---------------------------------------------------------------------------------------------------------------------+
 

更新heat stack:

$ openstack stack update --template heat-templates/hot/hello_world.yaml --parameter "key_name=ohn-12" MYSTACK
+---------------------+---------------------------------------------------------------------------------------------------------------------+
| Field               | Value                                                                                                               |
+---------------------+---------------------------------------------------------------------------------------------------------------------+
| id                  | 1850b4cd-6df6-4db7-98e0-84fa71df2cf9                                                                                |
| stack_name          | MYSTACK                                                                                                             |
| description         | Hello world HOT template that just defines a single server. Contains just base features to verify base HOT support. |
|                     |                                                                                                                     |
| creation_time       | 2019-01-09T09:33:35Z                                                                                                |
| updated_time        | 2019-01-10T03:06:05Z                                                                                                |
| stack_status        | UPDATE_IN_PROGRESS                                                                                                  |
| stack_status_reason | Stack UPDATE started                                                                                                |
+---------------------+---------------------------------------------------------------------------------------------------------------------+
 

查看stack:

 $ openstack stack show MYSTACK

输出stack 名字、描述、parameters、outputs等信息。

heat template相关问题:

Q1: "openstack stack list" is not a command

A: pip3 install python-heatclient

Openstack manage stacks: https://docs.openstack.org/ocata/user-guide/cli-create-and-manage-stacks.html

Q2: $ openstack stack create --template heat-templates/hot/hello_world.yaml --parameter "key_name=hz-ohn-12" MYSTACK
ERROR: Remote error: DiscoveryFailure Could not determine a suitable URL for the plugin
[u'

A: 修改openrc.sh中的OS_AUTH_URL=http://os-ohn-12.eecloud.nsn-net.net:5000/v3 为=http://os-ohn-12.eecloud.nsn-net.net:5000/v2.0

Q3:Conflict: resources.server: Multiple possible networks found, use a Network ID to be more specific.

A:增加network部分:networks: { get_param: networks }

Q4: $ openstack stack update --template heat-templates/hot/hello_world.yaml --parameter "key_name=hz-ohn-12" MYSTACK
ERROR: 'unicode' object has no attribute 'get'

A:修改network部分

      networks:
          - network: { get_param: network_id }

猜你喜欢

转载自blog.csdn.net/neu_xiaolu/article/details/86154252