开始之前
您必须完成以下事项:
已创建要在云中部署其映像的系统的统一归档文件 (unified archive, UA)。确保在创建 UA 之前,在该系统中包括 cloudbase-init 软件包。
有关创建 UA 的说明,请参阅《在 Oracle Solaris 中使用统一归档文件进行系统恢复和克隆》指南中的“使用统一归档文件”一章。此指南位于 Operating Systems Documentation(操作系统文档)中您 Oracle Solaris 版本相应的库中。
在 Heat 模板的用户数据部分中,提供用户数据信息。将模板另存为 *.yaml 文件。
# heat stack-create -f yaml-template \ -P key_name=your key name;image=image name\ private_net=name of tenant private network stack-name
以下示例显示将通过 Cloudbase-Init 处理的 Heat 模板。需要提供的信息以粗体显示,为方便起见标记了用户数据信息。模板的名称是 test.yaml。
heat_template_version: 2013-05-23 description: HOT template to deploy one server into an existing neutron tenant network and assign a floating IP address so it's routable from the public network. parameters: key_name:Server1Key type: string description: Name of keypair to assign to server image:Solaris Non-global Zone type: string description: Name of image to use for server flavor:8 type: string description: Flavor to use for server default: 1 public_net: type: string description: Name or ID of public network for which floating IP address will be allocated default: oracle private_net:HR type: string description: Name or ID of private network into which server is deployed resources: server1: type: OS::Nova::Server properties: name: { get_param: 'OS::stack_name' } image: { get_param: image } flavor: { get_param: flavor } key_name: { get_param: key_name } networks: - port: { get_resource: server1_port } user_data_format: RAW---------- 用户数据部分开始 ---------- user_data: str_replace: template: | #!/bin/ksh print "This is a test." server1_port: type: OS::Neutron::Port properties: network: { get_param: private_net } server1_floating_ip: type: OS::Neutron::FloatingIP properties: floating_network: { get_param: public_net } port_id: { get_resource: server1_port } outputs: server1_private_ip: description: IP address of server1 in private network value: { get_attr: [ server1, first_address ] } server1_public_ip: description: Floating IP address of server1 in public network value: { get_attr: [ server1_floating_ip, floating_ip_address ] }
要部署模板,请键入以下内容:
# heat stack-create -f test.yaml -P key_name=Server1Key \ -P image=Solaris Non-global Zone\ ...-P flavor=8 -P private_net=HR teststack
请注意,命令中每个选项的特定值来自 test.yaml 模板文件中的信息。公共网络是 oracle,这是缺省值。