|
|
楼主 |
发表于 2017-11-20 16:47:30
|
显示全部楼层
示例 1: C& F+ V; |! w6 V& x1 p3 [ x
以下示例是一个用于部署单个虚拟系统的简单 Heat 模板,该示例限制为此模板中硬编码的映像、密钥和虚拟硬件样板值的单一组合:/ x n# a& y: X( F1 e7 o
heat_template_version: 2013-05-23* t0 f: x5 e' W
: H4 g5 e* p$ q- i8 idescription: Simple template to deploy a single compute instance with hardcoded values
& z2 p" T- v E/ i9 t4 P/ {* I* \
resources:9 T2 z5 d4 o8 x5 {6 M+ ]9 t
my_instance:
, _* h- N# B( u! A1 s, C+ z1 R# P/ g type: OS::Nova::Server+ O- \1 ?$ ^- ?; M( F7 F. s
properties:
6 s. @4 S" }0 \- k key_name: my_key_pair_1
g5 E! J% }& x- K8 E image: cirros-0.3.1-x86_64
: L9 Z9 e( @! Z" _1 Q; ^ flavor: m1.tiny
& m3 V1 P, B' a( OCopy
0 I" m) `1 Y! T示例 2/ Q' D% e* U1 `1 o7 {
以下示例是一个 Heat 模板,它使用参数来部署单个虚拟系统,因此可以复用于其他配置:
4 ~3 W) n, A- \heat_template_version: 2013-05-23. N, w- M! a9 j( C$ K
description: Simple template to deploy a single compute instance with parameters7 L9 Y& D" ~- [2 h K6 p, a
! J/ f8 X- K4 \& F R+ E9 y
parameters:
& s) u! r: A$ [7 y/ A; } key_name:
0 X* K3 s& w5 w8 i6 T0 s" n type: string
& a+ `, o& c- B! t label: Key Name: R/ p" p( o6 u4 P8 H
description: Name of key-pair to be used for compute instance
) P _6 ~# s0 J image_id:) t5 R0 ^- a5 B' x# ?, u2 `
type: string( t' ~+ |8 h/ \- R% {- f- s) u
label: Image ID
% x8 o1 M. s& l$ R9 i* ~ description: Image to be used for compute instance; y$ b- S j; M
instance_type:
4 X; k( I8 ^+ y5 y type: string/ e/ P; K: X* {" [ l; m
label: Instance Type
0 G5 k+ P% m# T( J' Q+ f description: Type of instance (flavor) to be used
9 D& ~6 O$ ]5 ^# A8 Sresources:! x1 X2 c8 M% K* ?3 p* b$ E
my_instance:
7 \# W! p1 [' ^' H4 [ `7 K" X( o type: OS::Nova::Server+ Y' J$ N7 W+ I1 a# U$ B
properties:# W! G' x& t3 D! X, W! Q6 M3 ~
key_name: { get_param: key_name }4 ~" R' e+ r2 p3 O# H4 E5 U
image: { get_param: image_id }
8 B# B% b3 P* v4 P flavor: { get_param: instance_type }
9 F5 V4 m" [; L. W7 NCopy
$ w& a ^& o! \8 C4 }- W6 {示例 3
% L% _8 m1 t* K' b6 x. c* D以下示例是一个简单的 Heat 模板,它通过使用参数的查找注释来部署具有两个虚拟机实例的堆栈:
7 ?1 L- J* l# g0 G( k2 A& Iheat_template_version: 2013-05-23- G4 ~6 \. }8 B$ j5 L* j4 \* K
" [2 s: v, P6 D# H
description: Simple template to deploy a stack with two virtual machine instances. B5 r' B) [3 N- b
7 g4 w. L1 `' U9 a+ |& |parameters:1 a8 `- b. o% D# p7 X
image_name_1:
1 F7 y& Y% T- Q type: string 8 N. _. {3 l# G, P- T
label: Image Name
# {0 i4 W* S( }( G+ \! ` description: SCOIMAGE Specify an image name for instance1 ! S6 J- O8 C: C$ H
default: cirros-0.3.1-x86_64
/ [0 f, `/ f& m% g0 e. [2 C image_name_2: , i, s, n. }$ ^- W W7 E
type: string 3 E; v# ]" U& G' g# m8 s
label: Image Name 4 X$ p9 `9 w8 U+ ^$ J" K
description: SCOIMAGE Specify an image name for instance2
8 y0 H8 P* s) Y4 o% B0 _ default: cirros-0.3.1-x86_64
# ^9 S- i/ k+ |& r8 K0 k m network_id:
9 j5 X. D l; a" Q* E% }# c T type: string
( w8 S9 H2 A" U2 `' C, y7 ~0 k8 [ label: Network ID) \9 p. Z6 i K1 M
description: SCONETWORK Network to be used for the compute instance% ^! _+ w& M, j+ W
. M- u, T: \3 a. N0 I0 yresources: & |9 N$ L) E5 \2 ^# E
my_instance1: 0 h$ q# P# X/ V3 f0 K: D7 P, k8 s# ]
type: OS::Nova::Server
2 \; g- s& e. \+ d. p$ g properties:
% Z" r' \, N& F! R image: { get_param: image_name_1 } K+ Q& c3 z9 e% q' h: d; O$ C
flavor: m1.small
& {9 E" W1 ]% i* A% Q/ u networks:
6 O* G% Q9 w) z* ~9 T7 Y4 C; I - network : { get_param : network_id }# N. [; z8 E$ ?1 }# ~
my_instance2:
: ~) j+ h7 u. Q! Y0 W3 F type: OS::Nova::Server . E3 J' v' H1 H' j# g# r1 o5 e- @
properties: 7 ?8 L( s# h- ]
image: { get_param: image_name_2 }
8 E% ~0 S! t0 J# _" O, m$ p flavor: m1.tiny2 t2 L' D1 l& V5 P
networks:
+ d! u4 P4 Q6 {0 Q - network : { get_param : network_id }$ T/ g; T3 }5 C+ \6 t7 r& r
Copy
* c; X! d! T3 n& S5 ^示例 4: h4 [+ A% e6 j( Z/ Z
以下示例是一个简单的 Heat 模板,此模板通过使用 user_data 节来针对虚拟机设置 admin 密码:' N |% W) G- K5 W& p& A
heat_template_version: 2013-05-23
; e, [8 H2 p0 @7 I. a* B: o$ z% h2 R+ s8 |. ^, N( r6 ?
description: Simple template to set the admin password for a virtual machine& W8 q4 n4 Y2 E% p4 N8 [0 r
9 Q, i6 L3 K) Q6 n6 I. u1 {
parameters:* c, N3 ?5 O+ r8 u, b
key_name:
. j1 Z. O! O. ~ type: string( d8 I, v C2 U3 o, i. W$ t" w! V
label: Key Name- i, M0 e4 V% d
description: SCOKEY Name of the key pair to be used for the compute instance
7 K3 ?9 x. ?$ T% ]0 J+ _ image_name:2 L. b l7 L( Z" R
type: string
: G3 y& f, C$ r3 P2 m label: Image Name
) d) O3 j1 l% s9 L; n description: SCOIMAGE Name of the image to be used for the compute instance; x) O2 q- z! K) C
password:" O- a9 O4 N# Y; ^. b+ M
type: string
& H+ b# T2 i/ {) E label: password
9 Y$ Q) ~ I5 l7 S$ S1 h description: admin password# @0 Z9 D/ w; E6 p( P; u* }
hidden: true! D/ E& z$ `) F! V- Z8 R) T
- I9 U! g* R) W6 D 8 E$ K4 w+ j) d0 D: W
resources:' X. N6 U" ]% }
my_instance:
( {6 v6 {5 c7 M3 \& |+ v1 v type: OS::Nova::Server1 M5 @: L9 n2 v- P
properties:
: S) j% p5 E1 h key_name: { get_param: key_name }% C) E5 |1 s# M' y& ]
admin_user: sampleuser8 |3 J: ]0 G2 {3 H' i
image: { get_param: image_name }
y# {2 z: ~8 ^6 V4 q. N, { flavor: m1.small! Y2 }! V g5 s. i1 n
user_data:: t( ? H+ M2 D* Y, M
str_replace: V) r7 C9 M9 v$ K5 v/ {+ Y
template: |5 _0 s1 z* `+ H5 X+ k
#!/bin/bash
7 U3 \ _% J2 Y c$ o' e* G" ^ echo "Setting password to " $password 2 p, ^% G+ F. L7 I
echo $password |passwd --stdin sampleuser
6 J% {5 h6 ?9 ^$ H+ _3 o1 q0 [ e5 u8 x8 r
params:
! I% }+ n% J# E* `" `6 R7 ]. d $password: { get_param: password }( G/ m: J) \' R) M. F9 A+ s
Copy! d; L: ]' S8 a8 {* p
示例 5( Y1 n$ E+ {$ i5 H$ W+ Q2 g
以下示例是一个简单的 Heat 模板,此模板用于在您指定了要使用的存储连接组以及引导卷部署所在的存储模板的 PowerVC 上,部署 AIX 或 Linux on Power 服务器:
' c/ M* o7 U% jheat_template_version: 2013-05-23
* v) D5 I2 D$ `2 `) h- z7 Y& H! b* M& Zdescription: Template to Deploy on NPIV v7k storage only, C( \ t8 O8 Z& ~" \ h
) o# ^) j! F5 M. U8 m7 k
parameters:
% l, D3 e1 p6 ?* I network_id1:
5 O6 l& @7 ?/ @" R( d( [ type: string
# A* L, |) T( b' w3 }* ] N description: SCONETWORK ID of the (nova) network a server should be deployed to.
. Z2 ?* x; w. d+ _ flavor_id:7 L1 {# A% n- |: p; v+ `7 r, {; z
type: string2 z, W( D% x- r3 v% k, h
description: SCOFLAVOR The flavor to be applied to the server DatabaseTierVM." W( m! r) m+ [
image:6 G5 [& n6 J4 b& E
type: string
) [, k+ ^, S1 ~% p3 T- K label: Image9 `/ K) h! q; Y3 ? h
description: SCOIMAGE The Image to be deployed. p* B0 Z: j9 D: [* D# [- a' _
resources:2 Q/ E6 \; o1 [# r
heat:0 Y4 B$ M2 L A1 O2 N! k
type: OS::Nova::Server. } m, v+ q; q# y9 ]5 D9 }4 m
properties:
% k" X2 E2 h; L3 l5 W" @% \/ s image: { get_param: image }
, i# }8 C) T# M- J2 I8 O6 E flavor: { get_param: flavor_id }! l* Y! O/ V, u. r# ^+ c' T
availability_zone: D0EB' |8 f5 [) M$ J7 U% }$ k5 B3 X% e
metadata: { selected-scg: d91acbbe-3d81-4279-b389-54b3ad4a1c8c, selected-storage-template: 0431b2f3-fea6-4aa5-b3fb-d0e82ccf5ebb }
) K# B1 V: n2 h$ s& L) { networks:
) W' p+ r- Q1 m' J$ E - network : { get_param : network_id1 }
; H3 O/ N' x7 T/ _Copy9 ~3 Z+ a8 Y! _, k/ ~6 b! E
注:
2 P; `, z/ B' v3 [/ g您可以使用 OpenStack Dashboard 中的“主机聚集”面板为 PowerVM® 服务器创建可用性专区。 请先确保您创建的新可用性专区添加到相关域和项目,然后再尝试使用这些可用性专区。 您可以在要使用的映像的 Image_topology 中找到 selected-scg(存储连接组)和 selected-storage-template。 请在 OpenStack Controller 上运行 glance image-show <image id> 命令。 映像拓扑指定该特定映像所支持的存储连接组和存储模板。 |
|