如果一次需要启动10个实例,手动一个一个的去套模版启动,相信也行太low了吧,openstack官方也为运维人员准备了强大的利器,那就是任务编排orchestration服务模块了,当然如果要想用好这一工具来帮我解决低级趣味的任务编排,还需要我们专业去学习一下heat模版语法了,在这里我只是带大家简单实现一下通过任务编排模版自动创建并启动一个实例,具体语法规则不这里不详细陈述。
controller节点安装配置
准备数据库
[root@controller ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5960
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE heat;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'localhost' \
-> IDENTIFIED BY 'HEAT_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%' \
-> IDENTIFIED BY 'HEAT_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye
[root@controller ~]#
创建用户并授权为管理员
[root@controller ~]# . admin-openrc
[root@controller ~]# openstack user create --domain default --password-prompt heat
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | 3ad6ac5f704c494e9f16b9e04ef745fe |
| enabled | True |
| id | f565ccc8e39148acaaa215c1b2afa796 |
| name | heat |
+-----------+----------------------------------+
[root@controller ~]# openstack role add --project service --user heat admin
[root@controller ~]#
创建 heat 和 heat-cfn 服务
[root@controller ~]# openstack service create --name heat \
> --description "Orchestration" orchestration
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Orchestration |
| enabled | True |
| id | 9c6f28bceaed4e509a714422c0020add |
| name | heat |
| type | orchestration |
+-------------+----------------------------------+
[root@controller ~]# openstack service create --name heat-cfn \
> --description "Orchestration" cloudformation
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Orchestration |
| enabled | True |
| id | 7e795b3ac8274b19ab02ce10ad76f0f5 |
| name | heat-cfn |
| type | cloudformation |
+-------------+----------------------------------+
[root@controller ~]#
创建 Orchestration 服务的 API接口
[root@controller ~]# openstack endpoint create --region RegionOne \
> orchestration public http://controller:8004/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 77ae53a11b8d4b49a40280cd1ee06156 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 9c6f28bceaed4e509a714422c0020add |
| service_name | heat |
| service_type | orchestration |
| url | http://controller:8004/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
> orchestration internal http://controller:8004/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | dd7de2064e684728b6296628e3b48adc |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 9c6f28bceaed4e509a714422c0020add |
| service_name | heat |
| service_type | orchestration |
| url | http://controller:8004/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
> orchestration admin http://controller:8004/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 61eedfaf02d54a06ba8dfeed253bdaae |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 9c6f28bceaed4e509a714422c0020add |
| service_name | heat |
| service_type | orchestration |
| url | http://controller:8004/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]#
[root@controller ~]# openstack endpoint create --region RegionOne \
> cloudformation public http://controller:8000/v1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 23cc7aac12964ffe992ce1e46e5fd1a7 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7e795b3ac8274b19ab02ce10ad76f0f5 |
| service_name | heat-cfn |
| service_type | cloudformation |
| url | http://controller:8000/v1 |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
> cloudformation internal http://controller:8000/v1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | c1cdaee0d73b4006926777e39f10e839 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7e795b3ac8274b19ab02ce10ad76f0f5 |
| service_name | heat-cfn |
| service_type | cloudformation |
| url | http://controller:8000/v1 |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
> cloudformation admin http://controller:8000/v1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 837f4cb29c2741cf9b23dbaffe6d39f1 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7e795b3ac8274b19ab02ce10ad76f0f5 |
| service_name | heat-cfn |
| service_type | cloudformation |
| url | http://controller:8000/v1 |
+--------------+----------------------------------+
[root@controller ~]#
为栈创建 heat 包含项目和用户的域
[root@controller ~]# openstack domain create --description "Stack projects and users" heat
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Stack projects and users |
| enabled | True |
| id | dbb18adb37e74e78bb5165f14efa3a25 |
| name | heat |
+-------------+----------------------------------+
[root@controller ~]#
在 heat 域中创建管理项目和用户的``heat_domain_admin``用户
[root@controller ~]# openstack user create --domain heat --password-prompt heat_domain_admin
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | dbb18adb37e74e78bb5165f14efa3a25 |
| enabled | True |
| id | 6131013190c84113a0316c8f9a0686fa |
| name | heat_domain_admin |
+-----------+----------------------------------+
[root@controller ~]#
授权 heat 域 中的 heat_domain_admin 用户拥有管理员权限
[root@controller ~]# openstack role add --domain heat --user-domain heat --user heat_domain_admin admin
[root@controller ~]#
创建 heat_stack_owner 用户
[root@controller ~]# openstack role create heat_stack_owner
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | e38522bfda184a17b1e5cfce7ea61b7e |
| name | heat_stack_owner |
+-----------+----------------------------------+
[root@controller ~]#
授权 heat_stack_owner 拥有demo域的管理权限
[root@controller ~]# openstack role add --project demo --user demo heat_stack_owner
[root@controller ~]#
创建 heat_stack_user 角色
Orchestration 会自动地分配 heat_stack_user 角色给在 stack 部署过程中创建的用户。默认情况下,这个角色会限制 API 的操作。为了避免冲突,请不要为用户添加 ``heat_stack_owner``角色
[root@controller ~]# openstack role create heat_stack_user
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | c4f1be2faa174a189db0d75a65753d91 |
| name | heat_stack_user |
+-----------+----------------------------------+
[root@controller ~]#
安装及修改配置文件
[root@controller ~]# yum install -y openstack-heat-api openstack-heat-api-cfn \
> openstack-heat-engine
[root@controller ~]# cp /etc/heat/heat.conf{,.bak}
[root@controller ~]# vim /etc/heat/heat.conf
[root@controller ~]# grep -v ^# /etc/heat/heat.conf | tr -s [[:space:]]
[DEFAULT]
rpc_backend = rabbit
heat_metadata_server_url = http://controller:8000
heat_waitcondition_server_url = http://controller:8000/v1/waitcondition
stack_domain_admin = heat_domain_admin
stack_domain_admin_password = HEAT_DOMAIN_ADMIN_PASS
stack_user_domain_name = heat
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = heat
password = HEAT_PASS
[auth_password]
[clients]
[clients_barbican]
[clients_ceilometer]
[clients_cinder]
[clients_designate]
[clients_glance]
[clients_heat]
[clients_keystone]
auth_uri = http://controller:35357
[clients_magnum]
[clients_manila]
[clients_mistral]
[clients_neutron]
[clients_nova]
[clients_sahara]
[clients_senlin]
[clients_swift]
[clients_trove]
[clients_zaqar]
[cors]
[cors.subdomain]
[database]
connection = mysql+pymysql://heat:HEAT_DBPASS@controller/heat
[ec2authtoken]
auth_uri = http://controller:5000/v2.0
[eventlet_opts]
[heat_api]
[heat_api_cfn]
[heat_api_cloudwatch]
[matchmaker_redis]
[oslo_messaging_amqp]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS
[oslo_middleware]
[oslo_policy]
[paste_deploy]
[profiler]
[revision]
[ssl]
[trustee]
auth_plugin = password
auth_url = http://controller:35357
username = heat
password = HEAT_PASS
user_domain_name = default
[root@controller ~]#
导入Orchestration数据库
[root@controller ~]# su -s /bin/sh -c "heat-manage db_sync" heat
2017-07-28 21:09:59.444 23666 INFO migrate.versioning.api [-] 27 -> 28...
2017-07-28 21:10:01.960 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:01.961 23666 INFO migrate.versioning.api [-] 28 -> 29...
2017-07-28 21:10:02.858 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:02.858 23666 INFO migrate.versioning.api [-] 29 -> 30...
2017-07-28 21:10:02.958 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:02.959 23666 INFO migrate.versioning.api [-] 30 -> 31...
2017-07-28 21:10:03.466 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:03.466 23666 INFO migrate.versioning.api [-] 31 -> 32...
2017-07-28 21:10:04.497 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:04.497 23666 INFO migrate.versioning.api [-] 32 -> 33...
2017-07-28 21:10:05.819 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:05.819 23666 INFO migrate.versioning.api [-] 33 -> 34...
2017-07-28 21:10:06.108 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:06.108 23666 INFO migrate.versioning.api [-] 34 -> 35...
2017-07-28 21:10:08.958 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:08.959 23666 INFO migrate.versioning.api [-] 35 -> 36...
2017-07-28 21:10:09.517 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:09.517 23666 INFO migrate.versioning.api [-] 36 -> 37...
2017-07-28 21:10:09.625 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:09.625 23666 INFO migrate.versioning.api [-] 37 -> 38...
2017-07-28 21:10:10.193 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:10.194 23666 INFO migrate.versioning.api [-] 38 -> 39...
2017-07-28 21:10:10.735 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:10.735 23666 INFO migrate.versioning.api [-] 39 -> 40...
2017-07-28 21:10:11.547 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:11.547 23666 INFO migrate.versioning.api [-] 40 -> 41...
2017-07-28 21:10:11.615 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:11.615 23666 INFO migrate.versioning.api [-] 41 -> 42...
2017-07-28 21:10:12.537 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:12.537 23666 INFO migrate.versioning.api [-] 42 -> 43...
2017-07-28 21:10:12.653 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:12.654 23666 INFO migrate.versioning.api [-] 43 -> 44...
2017-07-28 21:10:13.618 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:13.619 23666 INFO migrate.versioning.api [-] 44 -> 45...
2017-07-28 21:10:14.436 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:14.436 23666 INFO migrate.versioning.api [-] 45 -> 46...
2017-07-28 21:10:15.376 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:15.377 23666 INFO migrate.versioning.api [-] 46 -> 47...
2017-07-28 21:10:16.063 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:16.064 23666 INFO migrate.versioning.api [-] 47 -> 48...
2017-07-28 21:10:16.205 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:16.205 23666 INFO migrate.versioning.api [-] 48 -> 49...
2017-07-28 21:10:17.285 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:17.286 23666 INFO migrate.versioning.api [-] 49 -> 50...
2017-07-28 21:10:17.895 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:17.896 23666 INFO migrate.versioning.api [-] 50 -> 51...
2017-07-28 21:10:18.505 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:18.505 23666 INFO migrate.versioning.api [-] 51 -> 52...
2017-07-28 21:10:19.463 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:19.464 23666 INFO migrate.versioning.api [-] 52 -> 53...
2017-07-28 21:10:20.087 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:20.088 23666 INFO migrate.versioning.api [-] 53 -> 54...
2017-07-28 21:10:21.422 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:21.422 23666 INFO migrate.versioning.api [-] 54 -> 55...
2017-07-28 21:10:25.088 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:25.089 23666 INFO migrate.versioning.api [-] 55 -> 56...
2017-07-28 21:10:27.350 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:27.350 23666 INFO migrate.versioning.api [-] 56 -> 57...
2017-07-28 21:10:32.898 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:32.898 23666 INFO migrate.versioning.api [-] 57 -> 58...
2017-07-28 21:10:34.532 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:34.532 23666 INFO migrate.versioning.api [-] 58 -> 59...
2017-07-28 21:10:35.166 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:35.166 23666 INFO migrate.versioning.api [-] 59 -> 60...
2017-07-28 21:10:40.682 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:40.683 23666 INFO migrate.versioning.api [-] 60 -> 61...
2017-07-28 21:10:44.074 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:44.075 23666 INFO migrate.versioning.api [-] 61 -> 62...
2017-07-28 21:10:44.833 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:44.834 23666 INFO migrate.versioning.api [-] 62 -> 63...
2017-07-28 21:10:45.580 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:45.580 23666 INFO migrate.versioning.api [-] 63 -> 64...
2017-07-28 21:10:46.316 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:46.317 23666 INFO migrate.versioning.api [-] 64 -> 65...
2017-07-28 21:10:47.077 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:47.077 23666 INFO migrate.versioning.api [-] 65 -> 66...
2017-07-28 21:10:47.118 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:47.119 23666 INFO migrate.versioning.api [-] 66 -> 67...
2017-07-28 21:10:47.160 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:47.160 23666 INFO migrate.versioning.api [-] 67 -> 68...
2017-07-28 21:10:47.199 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:47.199 23666 INFO migrate.versioning.api [-] 68 -> 69...
2017-07-28 21:10:47.235 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:47.235 23666 INFO migrate.versioning.api [-] 69 -> 70...
2017-07-28 21:10:47.361 23666 INFO migrate.versioning.api [-] done
2017-07-28 21:10:47.361 23666 INFO migrate.versioning.api [-] 70 -> 71...
2017-07-28 21:10:47.585 23666 INFO migrate.versioning.api [-] done
[root@controller ~]# mysql -e "show tables from heat"
+---------------------+
| Tables_in_heat |
+---------------------+
| event |
| migrate_version |
| raw_template |
| resource |
| resource_data |
| service |
| snapshot |
| software_config |
| software_deployment |
| stack |
| stack_lock |
| stack_tag |
| sync_point |
| user_creds |
| watch_data |
| watch_rule |
+---------------------+
[root@controller ~]#
启用并启动Orchestration服务
root@controller ~]# systemctl enable openstack-heat-api.service \
> openstack-heat-api-cfn.service openstack-heat-engine.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-heat-api.service to /usr/lib/systemd/system/openstack-heat-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-heat-api-cfn.service to /usr/lib/systemd/system/openstack-heat-api-cfn.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-heat-engine.service to /usr/lib/systemd/system/openstack-heat-engine.service.
[root@controller ~]# systemctl start openstack-heat-api.service \
> openstack-heat-api-cfn.service openstack-heat-engine.service
[root@controller ~]# ss -tnl //Orchestration服务正常启动后会新增8000和8004端口
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:8776 *:*
LISTEN 0 128 *:25672 *:*
LISTEN 0 128 192.168.10.10:3306 *:*
LISTEN 0 128 127.0.0.1:11211 *:*
LISTEN 0 128 *:9292 *:*
LISTEN 0 128 *:4369 *:*
LISTEN 0 128 *:8000 *:*
LISTEN 0 128 *:9696 *:*
LISTEN 0 100 *:6080 *:*
LISTEN 0 128 *:8004 *:*
LISTEN 0 128 *:8774 *:*
LISTEN 0 128 *:22022 *:*
LISTEN 0 128 *:8775 *:*
LISTEN 0 128 *:9191 *:*
LISTEN 0 128 :::5000 :::*
LISTEN 0 128 :::5672 :::*
LISTEN 0 128 ::1:11211 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::8786 :::*
LISTEN 0 128 :::35357 :::*
LISTEN 0 128 :::22022 :::*
[root@controller ~]#
以管理员身份验证服务
[root@controller ~]# . admin-openrc
[root@controller ~]# openstack orchestration service list
+------------+-------------+--------------------------------------+------------+--------+----------------------------+--------+
| hostname | binary | engine_id | host | topic | updated_at | status |
+------------+-------------+--------------------------------------+------------+--------+----------------------------+--------+
| controller | heat-engine | 972db5de-71c8-4700-b11b-0f0d4c885d91 | controller | engine | 2017-07-28T13:17:39.000000 | up |
| controller | heat-engine | 69197de6-096a-4115-a349-b0a54b33d6fe | controller | engine | 2017-07-28T13:17:39.000000 | up |
| controller | heat-engine | b3223830-c9c9-4b5a-8cb5-8c658130854e | controller | engine | 2017-07-28T13:17:39.000000 | up |
| controller | heat-engine | 38e6f832-b5c4-42e8-9583-fe3c5768de89 | controller | engine | 2017-07-28T13:17:39.000000 | up |
| controller | heat-engine | ea4c17ca-24d2-412e-a4f5-2ca1eaf7ba50 | controller | engine | 2017-07-28T13:17:39.000000 | up |
| controller | heat-engine | 3948deb4-34c2-4536-9e3a-1964bb8668fd | controller | engine | 2017-07-28T13:17:39.000000 | up |
| controller | heat-engine | 29de671d-50bb-4ee1-8486-a2b6b22dfbeb | controller | engine | 2017-07-28T13:17:39.000000 | up |
| controller | heat-engine | 2fa7e7dd-70c9-4094-8686-4e727ae19913 | controller | engine | 2017-07-28T13:17:39.000000 | up |
+------------+-------------+--------------------------------------+------------+--------+----------------------------+--------+
[root@controller ~]#
创建一个模板
[root@controller ~]# vim demo-template.yml
[root@controller ~]# cat demo-template.yml
heat_template_version: 2016-04-08
description: Launch a basic instance with CirrOS p_w_picpath using the
``m1.nano`` 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:
p_w_picpath: cirros
flavor: m1.nano
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 ] }
[root@controller ~]#
创建一个stack
[root@controller ~]# . demo-openrc
[root@controller ~]# openstack network list
+--------------------------------------+-------------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+-------------+--------------------------------------+
| 3b9946b0-b55a-4cdf-a1e4-252a9557fd06 | selfservice | e51d7043-49ff-45ab-a407-6739e0974144 |
| 3bd7b504-e172-462b-a904-c7df815964b3 | provider | 7e8b9dbb-28a3-406d-b598-4837030cbba4 |
+--------------------------------------+-------------+--------------------------------------+
[root@controller ~]#
申明模版文件中所需要的变量
[root@controller ~]# export NET_ID=$(openstack network list | awk '/ provider / { print $2 }')
使用模版创建并启动一个栈
[root@controller ~]# openstack stack create -t demo-template.yml --parameter "NetID=$NET_ID" stack
+---------------------+----------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------------+----------------------------------------------------------------------------------------------------------+
| id | 32fe747c-5a3b-4e58-9b25-bd56d7cd9eeb |
| stack_name | stack |
| description | Launch a basic instance with CirrOS p_w_picpath using the ``m1.nano`` flavor, ``mykey`` key, and one network. |
| creation_time | 2017-07-29T02:29:13 |
| updated_time | None |
| stack_status | CREATE_IN_PROGRESS |
| stack_status_reason | Stack CREATE started |
+---------------------+----------------------------------------------------------------------------------------------------------+
[root@controller ~]# openstack stack list
+--------------------------------------+------------+--------------------+---------------------+--------------+
| ID | Stack Name | Stack Status | Creation Time | Updated Time |
+--------------------------------------+------------+--------------------+---------------------+--------------+
| 32fe747c-5a3b-4e58-9b25-bd56d7cd9eeb | stack | CREATE_IN_PROGRESS | 2017-07-29T02:29:13 | None |
+--------------------------------------+------------+--------------------+---------------------+--------------+
[root@controller ~]# openstack stack show 32fe747c-5a3b-4e58-9b25-bd56d7cd9eeb
+-----------------------+----------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-----------------------+----------------------------------------------------------------------------------------------------------------------+
| id | 32fe747c-5a3b-4e58-9b25-bd56d7cd9eeb |
| stack_name | stack |
| description | Launch a basic instance with CirrOS p_w_picpath using the ``m1.nano`` flavor, ``mykey`` key, and one network. |
| creation_time | 2017-07-29T02:29:13 |
| updated_time | None |
| stack_status | CREATE_COMPLETE |
| stack_status_reason | Stack CREATE completed successfully |
| parameters | NetID: 3bd7b504-e172-462b-a904-c7df815964b3 |
| | OS::project_id: 0200f6457da84abd9055a5c192386747 |
| | OS::stack_id: 32fe747c-5a3b-4e58-9b25-bd56d7cd9eeb |
| | OS::stack_name: stack |
| | |
| outputs | - description: Name of the instance. |
| | output_key: instance_name |
| | output_value: stack-server-byn23ksv35os |
| | - description: IP address of the instance. |
| | output_key: instance_ip |
| | output_value: 10.0.0.105 |
| | |
| links | - href: http://controller:8004/v1/0200f6457da84abd9055a5c192386747/stacks/stack/32fe747c-5a3b-4e58-9b25-bd56d7cd9eeb |
| | rel: self |
| | |
| disable_rollback | True |
| parent | None |
| tags | null |
| | ... |
| | |
| stack_user_project_id | 4677bcbb8f88481494a72a264e7f4727 |
| capabilities | [] |
| notification_topics | [] |
| timeout_mins | None |
| stack_owner | None |
+-----------------------+----------------------------------------------------------------------------------------------------------------------+
[root@controller ~]# openstack stack output show --all stack
+---------------+-------------------------------------------------+
| Field | Value |
+---------------+-------------------------------------------------+
| instance_name | { |
| | "output_value": "stack-server-byn23ksv35os", |
| | "output_key": "instance_name", |
| | "description": "Name of the instance." |
| | } |
| instance_ip | { |
| | "output_value": "10.0.0.105", |
| | "output_key": "instance_ip", |
| | "description": "IP address of the instance." |
| | } |
+---------------+-------------------------------------------------+
[root@controller ~]# openstack server list //实例创建后会自动启动
+--------------------------------------+---------------------------+---------+------------------------------------+
| ID | Name | Status | Networks |
+--------------------------------------+---------------------------+---------+------------------------------------+
| 1f0b1032-1fec-4333-b567-76c8a2434e73 | stack-server-byn23ksv35os | ACTIVE | provider=10.0.0.105 |
| a7c51098-20d7-4f01-b3b9-451694fddfb4 | selfservice-instance | SHUTOFF | selfservice=172.16.0.3, 10.0.0.104 |
| a8234b31-7acb-4f2c-abfc-34d8bfd76438 | provider-instance | SHUTOFF | provider=10.0.0.102 |
+--------------------------------------+---------------------------+---------+------------------------------------+
[root@controller ~]# openstack server show 1f0b1032-1fec-4333-b567-76c8a2434e73
+--------------------------------------+----------------------------------------------------------+
| Field | Value |
+--------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2017-07-29T02:29:36.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | provider=10.0.0.105 |
| config_drive | |
| created | 2017-07-29T02:29:25Z |
| flavor | m1.nano (0) |
| hostId | a33066b316f8685eaf842bff56b5d4806daae5ef486f84a9904f7e82 |
| id | 1f0b1032-1fec-4333-b567-76c8a2434e73 |
| p_w_picpath | cirros (9b0a7de0-6ff5-488b-9067-813e8a88de98) |
| key_name | mykey |
| name | stack-server-byn23ksv35os |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| project_id | 0200f6457da84abd9055a5c192386747 |
| properties | |
| security_groups | [{u'name': u'default'}] |
| status | ACTIVE |
| updated | 2017-07-29T02:29:37Z |
| user_id | deb3adea97e34fee9161a47940762a53 |
+--------------------------------------+----------------------------------------------------------+
[root@controller ~]# openstack stack delete --yes stack //删除stack
至此,已经使用了heat模版语言定义了一下简单的模版,并通过此模版成功启动一个实例,更多模版语法请自行参阅openstack官方提供的说明。
来源:oschina
链接:https://my.oschina.net/u/4259809/blog/4341689