|
|
楼主 |
发表于 2017-11-20 16:47:30
|
显示全部楼层
示例 1. K2 \ z! x( j r
以下示例是一个用于部署单个虚拟系统的简单 Heat 模板,该示例限制为此模板中硬编码的映像、密钥和虚拟硬件样板值的单一组合:8 N8 f0 I) z% o) x7 {' l4 X5 j. @
heat_template_version: 2013-05-23- b; R, Z5 l( R* C' f, v7 x: g
5 J. X; g4 N! ^! N0 D* b2 }' L& ]
description: Simple template to deploy a single compute instance with hardcoded values; C0 q, m4 V+ j9 J, X; B. ?
, D& B6 l1 z# z8 v1 V2 r
resources:( O, C; B- x. w# \7 Z1 J
my_instance:
: q7 o# V; }. [! z8 b+ N' t type: OS::Nova::Server- V) P4 Z i0 \) j5 |* K, a5 U
properties:
: n! k! P( u$ V( k4 i key_name: my_key_pair_1; z" [& C+ O: R) O# t1 s& {" I- L
image: cirros-0.3.1-x86_64
1 d( U9 f- _3 F7 @* C* l flavor: m1.tiny
$ \8 ?0 R6 B& f8 TCopy) X) b) }; N5 b' q
示例 2( o$ d3 z3 e+ ~9 w% P
以下示例是一个 Heat 模板,它使用参数来部署单个虚拟系统,因此可以复用于其他配置:
! {/ L0 y5 F4 L# }4 Uheat_template_version: 2013-05-23: z6 \6 k% Z2 C: ?
description: Simple template to deploy a single compute instance with parameters8 D) q* B* H* n
: Y5 P. r0 B- E9 c+ E. ?parameters:. h4 B7 C$ D2 X/ b7 c
key_name:4 M) Q4 t/ w0 N0 j; J8 S
type: string8 }9 U8 e8 c& v6 Y
label: Key Name3 R4 R9 E6 t& ^- s% L
description: Name of key-pair to be used for compute instance
7 W3 O. D, v- [3 R7 R q image_id:! Z& W+ ~, z' c3 J
type: string
8 G) [8 f& _3 U/ \ label: Image ID
- m# h0 X( O& ?3 x$ w description: Image to be used for compute instance( b- y, K- v* G* r8 \9 C
instance_type:1 _; k6 W; ^# s/ \+ b$ s
type: string
' Q' x& B; ]9 X label: Instance Type1 A+ W6 B" o7 ^, |
description: Type of instance (flavor) to be used
7 o/ W8 h+ j6 b6 m5 Tresources:
' w. H0 ]9 p: p! `' E5 C6 U2 ~( u. s my_instance:/ R, |8 w* r$ e) j4 p) v7 J5 t
type: OS::Nova::Server" `' j9 [1 ~- Y; q% E0 s$ b
properties:5 c; l; w# }7 \' M, h
key_name: { get_param: key_name }
% P! M: o0 @7 X( n1 k) [* b image: { get_param: image_id }
{+ W% @" Q# R flavor: { get_param: instance_type }
t' |, K6 L6 V1 c6 Z! k. M; QCopy9 z- |6 E! E& F) @& x
示例 3
8 C# }2 ]: a0 X" b7 O以下示例是一个简单的 Heat 模板,它通过使用参数的查找注释来部署具有两个虚拟机实例的堆栈:7 M5 E* f% R: a' w% r
heat_template_version: 2013-05-236 g9 T* H, G4 J. X6 q) B
6 u9 [" d2 v( z8 Tdescription: Simple template to deploy a stack with two virtual machine instances8 m# `6 W) ?2 t$ o! w( c U |$ }
; i1 `$ M6 x/ V# J" r3 Rparameters:0 ?4 {3 |/ d7 w, }) L
image_name_1:
' e" K9 T& e% j- n; V0 L9 Y type: string
/ M# y3 f4 ]6 F6 t3 e- u label: Image Name # [& d2 k" N5 D/ A1 \' t
description: SCOIMAGE Specify an image name for instance1
7 N3 f j! @! J8 W. u5 I$ G default: cirros-0.3.1-x86_64# Q4 d; W/ ~7 ~
image_name_2:
D" g* y4 e% ~: S% H type: string % Y+ @+ F; `( J& h5 _' q
label: Image Name
0 m% @% P, I9 E description: SCOIMAGE Specify an image name for instance2
! V5 n5 r! f( T default: cirros-0.3.1-x86_64
* z$ [$ o$ P$ n/ V1 B: {, v network_id:& y0 z C$ l+ e
type: string% Z/ k; Q3 z# M7 b5 {. T3 y
label: Network ID- c4 J$ s$ U/ H; I6 M
description: SCONETWORK Network to be used for the compute instance, F! L: i+ F1 \/ l0 P; e
, B: n: F. {, z7 @
resources: : l5 f- ^; n4 }% @2 {- o
my_instance1:
4 ~+ Z* A5 z8 J9 }" q) C type: OS::Nova::Server
# u' Y/ Y/ e& t$ y; X properties:
. {. N0 ~, C. r1 E image: { get_param: image_name_1 } : R3 o- F8 _% ]: m
flavor: m1.small
% C2 P4 X N, Z6 U networks:& {0 S) `% [) L$ ]& W9 D, u- z1 p% z
- network : { get_param : network_id }7 L0 P( O: t1 l- ?( t9 k
my_instance2: 9 g% r$ y4 T5 I8 @6 o
type: OS::Nova::Server
6 _% |& P/ |; Y: c) ]0 {5 N properties:
! x/ C) Z; F/ w/ _) d image: { get_param: image_name_2 }
' I4 {5 V1 _8 U! Q/ m0 q+ i0 Z2 S flavor: m1.tiny* M7 Q5 g6 C3 Y
networks:
: I) J9 S* B0 f( k% n0 i$ m - network : { get_param : network_id }
7 h& b3 J0 @" a/ l; `8 M! h LCopy4 g$ f0 S( m, \: B2 z+ b
示例 4
6 b2 [! a+ c9 x) Z, [0 J7 d) [以下示例是一个简单的 Heat 模板,此模板通过使用 user_data 节来针对虚拟机设置 admin 密码:
9 X- X5 K. `# gheat_template_version: 2013-05-230 [/ j9 Q) V5 O& |. Z8 _: ]* n$ u
1 A1 I. Y8 r' pdescription: Simple template to set the admin password for a virtual machine5 Y B+ T' Z' Y# S
, z+ e7 l* x( t
parameters:
Z4 g2 H3 R+ x key_name:
! A& {' t1 u/ H% r( \9 E6 X type: string
) T/ V( M% ?0 Y" m label: Key Name8 Q' f% G2 U8 [- M. ]) b+ p: n
description: SCOKEY Name of the key pair to be used for the compute instance9 R4 ?' D& N% Q$ j4 q1 y
image_name: }. {' X; e0 H+ m2 U
type: string
. o2 [- L+ z* w5 {0 {: |" D$ Z$ Q label: Image Name+ ~+ G5 D" ~& l, V
description: SCOIMAGE Name of the image to be used for the compute instance4 D2 A/ O. f- }/ u- S
password:: y5 w( U6 B' ~
type: string
, x- N3 T0 {+ t+ y% {) @ label: password* A5 m& a+ V1 X$ ~2 V
description: admin password) L( x4 I& b2 @6 d; m( u
hidden: true
" A* J2 ^/ n% {! h( }* N; L- x' y8 K5 U% E0 b' I* A9 Z
* O6 F, h% q! z, @8 T
resources:
4 t5 o# Y( S3 f# M- r$ Y8 f my_instance:
2 L* O2 m3 A$ [6 r& q1 Q* O type: OS::Nova::Server- _9 M5 n: E. H) G6 ^& L
properties:
! j8 k( U" `) H# n key_name: { get_param: key_name }
( q% Z8 J% S% e8 V; n5 n7 q9 L admin_user: sampleuser
- m7 k" |9 m. b' V9 S7 Q image: { get_param: image_name }
4 R8 j8 r- O( k! ?. C1 h5 V flavor: m1.small
/ F k% D5 I: R/ F. S& ?5 Y, p user_data:
1 q" E8 z$ g- h( E( P, ` str_replace:7 t$ F! {, s7 q- k# o/ g
template: |
, @( b6 ?( _, L' a0 C6 Y #!/bin/bash
. \. V, o5 R, M g; G echo "Setting password to " $password
3 `. _) d$ y2 u5 T' G echo $password |passwd --stdin sampleuser
9 N, d" V7 P; ^5 I# |! p" y2 F% z0 {3 F8 f4 w2 F+ }
params:$ P5 `, H, m# }6 w* b
$password: { get_param: password }( F& V6 l% @# ]) `" W: n& V Z6 ?
Copy& T$ v# s, p4 P- V* ?* L
示例 5+ J: c7 G7 t4 l9 m, ]
以下示例是一个简单的 Heat 模板,此模板用于在您指定了要使用的存储连接组以及引导卷部署所在的存储模板的 PowerVC 上,部署 AIX 或 Linux on Power 服务器:
8 S; p5 u3 v' Y; G$ S- {' Yheat_template_version: 2013-05-23 / c9 {# q% A, a
description: Template to Deploy on NPIV v7k storage only
- N9 d$ x U/ F+ B& m$ Y y1 d: J# d, h% s: s
parameters:. P$ l: M) Z7 Z2 V1 C
network_id1:3 S, d) M$ I! S1 L0 x! Z: z
type: string
; ]+ q. q$ Z+ w6 Q& w description: SCONETWORK ID of the (nova) network a server should be deployed to.
+ [5 m' L" m/ f8 }2 G" x flavor_id:
0 N K: y5 U3 @6 d type: string8 x9 S: b4 u; J) a, R- A5 d
description: SCOFLAVOR The flavor to be applied to the server DatabaseTierVM.
* P" B% j# E7 G; ?2 [/ M image:
) w% |6 s( ?. a6 U6 q# s- j* O7 ` type: string" }6 \) M8 ^4 J+ V9 ~/ f
label: Image
# N2 Z& w0 n5 o/ y% Y* q5 C+ O' S description: SCOIMAGE The Image to be deployed3 G3 g0 c+ R1 a- e J; K2 V/ s7 X
resources:, a8 B$ i5 b6 ~4 a8 A- o+ s
heat:
( O: k. t4 _7 v type: OS::Nova::Server
3 H( Y( E O1 `1 U* e properties:# B, |' j% G+ ?% v9 Z
image: { get_param: image } |; M+ Z. |: T$ H: j
flavor: { get_param: flavor_id }
" Y3 r' q q9 n4 ^1 u availability_zone: D0EB* ^; @, a5 ]5 X) O3 ?8 }4 W
metadata: { selected-scg: d91acbbe-3d81-4279-b389-54b3ad4a1c8c, selected-storage-template: 0431b2f3-fea6-4aa5-b3fb-d0e82ccf5ebb }- O6 I- p6 F8 B; l1 H7 _1 t3 N
networks:
T; B) P1 z0 Y2 q) Y5 X* x - network : { get_param : network_id1 }
" d9 d- s2 h) _! U! Y ]/ C/ zCopy+ I; `" u9 d! ]/ E" v' {) ?
注:
1 P: T! E6 X! @ A. s您可以使用 OpenStack Dashboard 中的“主机聚集”面板为 PowerVM® 服务器创建可用性专区。 请先确保您创建的新可用性专区添加到相关域和项目,然后再尝试使用这些可用性专区。 您可以在要使用的映像的 Image_topology 中找到 selected-scg(存储连接组)和 selected-storage-template。 请在 OpenStack Controller 上运行 glance image-show <image id> 命令。 映像拓扑指定该特定映像所支持的存储连接组和存储模板。 |
|