|
|
楼主 |
发表于 2017-11-20 16:47:30
|
显示全部楼层
示例 12 ?) T/ m4 }5 E) |# P; r
以下示例是一个用于部署单个虚拟系统的简单 Heat 模板,该示例限制为此模板中硬编码的映像、密钥和虚拟硬件样板值的单一组合:
, m# |- y& c" |+ u7 Gheat_template_version: 2013-05-231 r. n! y' R/ ^2 G
. }1 K+ ?" @0 t4 L0 Y
description: Simple template to deploy a single compute instance with hardcoded values
P/ r2 i, A1 o5 ] q4 v* m, ~! Z. l' G$ G: U, G. J
resources:
7 J6 Q/ G! x3 `+ }+ O my_instance:
5 L" H: m1 b/ I type: OS::Nova::Server
+ q0 J8 |/ v$ D, j1 m# N! H0 }! H properties:1 E" l4 p0 g2 I$ v$ W
key_name: my_key_pair_10 i. n3 m5 D/ m9 K! M4 ?' l1 w
image: cirros-0.3.1-x86_64
5 I$ M, a( T7 w) A7 {& ?% S- T8 D flavor: m1.tiny; d8 `( W7 f3 G2 ?" ?4 C5 r
Copy
7 [$ c6 L1 A' ?4 i0 G) o示例 2: B& s! S0 ]' G0 p. ^6 t6 `
以下示例是一个 Heat 模板,它使用参数来部署单个虚拟系统,因此可以复用于其他配置: G' O0 `+ i; R& B9 @* }
heat_template_version: 2013-05-23
& C7 L2 ` Z* _/ o S7 m3 Adescription: Simple template to deploy a single compute instance with parameters
0 {. u6 s& a }% m, H
! Y. Z8 Q- k Q6 p; Aparameters:
$ x4 A% _4 \% i$ ?% Q4 D% v key_name:
* U5 l/ E. _. P% U+ o, \ type: string
# r1 ~1 m: X( R" G7 b/ Y# V label: Key Name' [# d) o6 d' |
description: Name of key-pair to be used for compute instance
+ ^1 v& ^0 t. V, X5 l image_id:
! ]7 g4 y5 u+ \5 O% j! m# P type: string
- O2 K+ o. I' f4 d x label: Image ID
0 g: _; Z. ?! ?7 h* X description: Image to be used for compute instance
5 P( X/ ]$ x) U' i1 `- D& L8 V; i6 b instance_type:4 d' Z& |! A# G) W2 J# g0 }
type: string5 p0 ~8 v/ Z9 k: a) m
label: Instance Type
+ @5 I1 q7 F; A! [ H# }( b description: Type of instance (flavor) to be used8 [2 e/ J- y7 W4 }& b5 Z
resources:. I5 P; v' s# P1 p
my_instance:! h6 z+ _! ?' W& y4 R6 `( V" Z2 Z
type: OS::Nova::Server
! Y( B, y7 E6 }8 R properties:
2 v9 S; P+ i- i' ?5 h4 m+ q key_name: { get_param: key_name }' I J( }- ]% G/ m$ R
image: { get_param: image_id }3 Q) G2 f- w2 ]/ @2 H/ O2 O
flavor: { get_param: instance_type }
* d" c+ ^3 w: b! n- PCopy( Q6 T) z# q0 Z! } D3 E3 B
示例 3; Y5 n' `& \* B$ b8 @
以下示例是一个简单的 Heat 模板,它通过使用参数的查找注释来部署具有两个虚拟机实例的堆栈:( k( h2 s2 V; q
heat_template_version: 2013-05-23
7 J' e0 ~. J' ~9 K. I# H2 X7 I G$ C8 S; |
description: Simple template to deploy a stack with two virtual machine instances
$ n" H' R2 }" S, { Q9 p+ S$ k1 K; M8 Z; d: W( g! ]
parameters:* X( ]/ V* P0 E1 {2 T+ O l5 I" S
image_name_1: ) T* T3 I: U& U4 \
type: string
* Y+ n+ V$ l& v& f label: Image Name
H: C5 @- {+ l/ Q/ G description: SCOIMAGE Specify an image name for instance1
+ u4 l9 \2 S, P default: cirros-0.3.1-x86_64% g9 J' X7 g! h/ L7 ^/ F
image_name_2: * f0 ~+ j" A4 t( a0 b$ O
type: string " }- b# L. l9 p
label: Image Name
7 Q& A3 @# ?; s- i* b description: SCOIMAGE Specify an image name for instance2
) W& m! {/ {" Q6 L0 D" W default: cirros-0.3.1-x86_64 & b& H+ I5 ^; ~+ Q! A
network_id:
6 M$ ?6 V1 h* G/ v6 F7 v! V type: string
5 |6 c' [- r' Q5 o C! U. S label: Network ID3 V( M9 y# U' X: O9 x9 s( f
description: SCONETWORK Network to be used for the compute instance
5 n) p' W& p2 Y4 O' {# l( z: P8 A) q# J
resources: : V+ o0 J% ^6 \- N1 i
my_instance1:
1 [ B3 o' T j) j+ o type: OS::Nova::Server
. I, W D9 E3 Y4 A) t properties:
9 q6 N" N* H+ a& K. s( V/ l/ S image: { get_param: image_name_1 } . X" V/ w, W5 B q) I: w3 a4 n
flavor: m1.small
. J* d# a; g$ T networks:, M* I: t/ a( s# }& Y
- network : { get_param : network_id }
$ U3 N- p! G1 L) F9 \( j: _ my_instance2:
" J7 g `& }- q% S% I/ b type: OS::Nova::Server
- c( m! [0 {- W2 ?& f properties: . i1 U3 X1 ^' x) W" }9 `/ J0 W
image: { get_param: image_name_2 }
* C, l1 r* ?' t+ f flavor: m1.tiny. j% P, \; z2 M9 F# _+ l
networks:
; o$ L3 Q9 s- a# ]+ @% C - network : { get_param : network_id }
& f6 y) Q- W8 @9 T4 ?' NCopy
% b2 }8 }5 s- B6 P3 f* ^3 ~! |示例 4# G+ V4 i) d/ R# E b8 X2 C0 h8 j
以下示例是一个简单的 Heat 模板,此模板通过使用 user_data 节来针对虚拟机设置 admin 密码:0 d1 B. e" r4 t h& b3 S
heat_template_version: 2013-05-23
! ?; h7 u; ~/ k$ Z1 d0 z, Z; A Q! z6 C$ g h7 H/ g; V2 b+ h
description: Simple template to set the admin password for a virtual machine
* K" K2 s5 Q4 _. z' X
' _+ }: q$ h f+ H9 Jparameters:3 E- C H. T0 L
key_name:
' `" j' u) I# ?- D: P% i$ l2 @9 f type: string
! A/ I F% e' Q4 M( M label: Key Name( ^2 X8 s% T! I3 w" e3 y
description: SCOKEY Name of the key pair to be used for the compute instance
6 [; T% [7 g. L( a/ R: F, y image_name:+ {- ?3 x( E( Z
type: string
% y, n9 m0 l& D( a" z' M label: Image Name% l5 [3 V, |. s4 |
description: SCOIMAGE Name of the image to be used for the compute instance. ]3 n- D5 r& C- p) A. n
password:" A5 p. X7 G2 c E" l' q& ~
type: string' }7 Q; Z1 ` s' u7 r9 U
label: password
& B$ H, S H: y1 w9 F! h. H' L description: admin password
" F5 R% ~& @3 s7 h$ z, q. | hidden: true: s% ]+ O2 b5 K1 x$ R8 Y7 o6 p
/ J3 M( ]8 Z9 O0 T
! S' O$ r# a& A% }& F
resources:
- @* \% E! B6 o+ q7 A$ s V my_instance:
( [: g3 J6 e/ } type: OS::Nova::Server$ m7 t& G' @. e9 }5 S! C' C
properties:9 z! m t4 w: K% s
key_name: { get_param: key_name }
0 y+ ]. h2 D3 T; _9 ]" a admin_user: sampleuser
2 J0 J/ s$ u( \: N- ]0 Z; A4 ~ image: { get_param: image_name }
* I! z7 j1 s* r2 S flavor: m1.small
6 e) e1 f, ^# L& v( d4 H$ t* d user_data:
% y9 K9 w! g0 f/ a% I. ]7 D str_replace:
7 `6 H$ [$ H! k2 f0 O, y template: |' X. \/ J/ N. w9 P
#!/bin/bash4 G8 y4 a$ R% o7 B( g9 b
echo "Setting password to " $password
9 y) Y8 y6 d+ C) a$ r echo $password |passwd --stdin sampleuser* e4 _5 K' B7 P8 V
# Q3 m* G" s1 |
params:
- I- l: x. M% E, n. L h0 [5 m $password: { get_param: password }6 f9 k/ k. H- ~/ c! p+ a9 a
Copy
/ E8 y6 o4 {, C8 u6 G0 q5 E& R) K示例 5# s& c3 {1 O2 k! J9 D) P) Z
以下示例是一个简单的 Heat 模板,此模板用于在您指定了要使用的存储连接组以及引导卷部署所在的存储模板的 PowerVC 上,部署 AIX 或 Linux on Power 服务器:
( Y8 `$ ~+ o' l$ rheat_template_version: 2013-05-23 % w( ?6 n% F4 ?2 b
description: Template to Deploy on NPIV v7k storage only l# s( b: a* B5 w' p( Q
# O6 l( n8 C) H0 P$ D/ k% }parameters:3 m" j/ T6 H8 v. u! X* ^ W
network_id1:2 h+ @/ y; Q/ Y1 s: g$ X; ~/ z
type: string
1 f, d% C S; c" } description: SCONETWORK ID of the (nova) network a server should be deployed to.
" @/ Z7 C+ |, h" E! T5 Q: M flavor_id:$ N2 I3 O- f! k" A* C& X0 u5 Y
type: string0 N7 j7 {- o4 L
description: SCOFLAVOR The flavor to be applied to the server DatabaseTierVM.
! q8 G9 v% T7 Z/ p3 J1 O! ? image:
8 W* `! R4 x: J& F3 y& w4 r G type: string
! f3 C# v& g6 l label: Image
! _" O" u3 V5 N8 u description: SCOIMAGE The Image to be deployed
9 q8 G) M" K# z/ X3 b- Sresources:# u, q" c9 V" H" ?+ `( I4 R
heat:
1 w& r1 A, \: k" M type: OS::Nova::Server) w' Q4 P: l. s+ o" s/ W. v) `# z
properties:+ S& C) H& E7 S1 w" I8 l3 q
image: { get_param: image }6 ~( P, z: k" z6 F4 U- g8 o( V2 u' |
flavor: { get_param: flavor_id }3 D [! V- m2 s5 _
availability_zone: D0EB
- P4 x3 i) l4 o X metadata: { selected-scg: d91acbbe-3d81-4279-b389-54b3ad4a1c8c, selected-storage-template: 0431b2f3-fea6-4aa5-b3fb-d0e82ccf5ebb }+ p% X$ q4 i3 r, U7 k% W. Y3 W& x
networks:
( A3 ?/ t$ {: ]1 A; { - network : { get_param : network_id1 }4 k% X# ~- ?+ \5 c' P
Copy
; V, o; }8 N" o. ^2 O注:/ m' S( R2 H4 u, Y1 }" n
您可以使用 OpenStack Dashboard 中的“主机聚集”面板为 PowerVM® 服务器创建可用性专区。 请先确保您创建的新可用性专区添加到相关域和项目,然后再尝试使用这些可用性专区。 您可以在要使用的映像的 Image_topology 中找到 selected-scg(存储连接组)和 selected-storage-template。 请在 OpenStack Controller 上运行 glance image-show <image id> 命令。 映像拓扑指定该特定映像所支持的存储连接组和存储模板。 |
|