讀古今文學網 > OpenStack系統架構設計實戰 > 6.4.5 輸出參數 >

6.4.5 輸出參數

輸出參數outputs是模板被執行後的輸出,如果模板執行失敗,會返回模板默認的失敗提示信息;如果執行成功,則執行模板定義的參數信息。這些輸出信息可以來自模板執行的任何一個階段產生的輸出,定義如下:

outputs: <parameter name>: description: <description> value: <parameter value>

以上是模板的整體結構,在模板定義過程中,HOT還提供了一系列的函數,用於豐富模板定義,如ref函數支持資源引用,get_param函數支持參數獲取,get_attr獲取資源輸出數據等。

一個完整的模板定義如下:

heat_template_version: 2013-05-23description: Simple template to deploy a single compute instanceparameters: image_id: type: string label: Image ID description: Image to be used for compute instance flavor: type: string label: Instance Type description: Type of instance (flavor) to be usedresources: my_instance: type: OS::Nova::Server properties:image: { get_param: image_id }flavor: { get_param: flavor }outputs: instance_ip: description: The IP address of the deployed instance value: { get_attr: [my_instance, first_address] }