Application Delivery Management

这篇文章已经过机器翻译.放弃

创建复合样本

样书一个重要的强大功能是它们可以用作其他样书的构建块。样书 可以导入到另一个样书中,可以将其称为第二个样书的组件使用的 类型 ,类似于 Nitro 内置样书。

例如,您可以使用您在上一节中构建的 basic-lb-config 样书来构建另一本名为 composite-example 的样书。要使用“basic-lb-config”样书,必须在新样书的 import-样书部分将其导入。

构建您的样书

新样书类似如下:

name: composite-example namespace: com.example.stylebooks version: "0.1" display-name: Load Balancing Virtual Server (HTTP/RoundRobin) description: This StyleBook defines a RoundRobin load balancing configuration with a monitor. schema-version: "1.0" import-stylebooks: - namespace: netscaler.nitro.config version: "10.5" prefix: ns - namespace: com.example.stylebooks version: "0.1" prefix: stlb parameters: - name: name type: string label: Application Name description: Give a name to the application configuration. required: true - name: ip type: ipaddress label: Application Virtual IP (VIP) description: The Application VIP that clients access required: true - name: svc-servers type: ipaddress[] label: Application Server IPs description: The IP addresses of all the servers of this application required: true - name: response-code type: string[] label: List of Response Codes description: List of Response Codes - Provide a list of response codes in integer. components: - name: basic-lb-comp type: stlb::basic-lb-config description: This component's type is another StyleBook that builds the NetScaler lbvserver, servicegroups and services configuration objects. properties: name: $parameters.name ip: $parameters.ip svc-servers: $parameters.svc-servers - name: monit-comp type: ns::lbmonitor description: This component is a basic Nitro type (a Builtin StyleBook) that builds the NetScaler monitor configuration object. properties: monitorname: $parameters.name + "-mon" type: HTTP respcode: $parameters.response-code httprequest: "'GET /'" lrtm: ENABLED secure: "YES" components: - name: monit-svcgrp-bind-comp type: ns::servicegroup_lbmonitor_binding properties: servicegroupname: $components.basic-lb-comp.outputs.servicegroup-comp.properties.servicegroupname monitor_name: $parent.properties.monitorname

在 import-样书部分,使用 basic-lb-config 样书的命名空间和版本将其导入,引用时加前缀“stlb”。

在 components 部分,定义了两个组件。第一个组件的类型为 stlb:: basic-lb-config,其中“basic-lb-config”是您在样书中为创建 基本负载平衡配置而创建的样书的名称。为此组件定义的数据对应于 basic-lb-config 样书中声明的必需参数。但是,您可以使用样书的任何参数(包括必填参数和可选参数)。与其重新构建 lbvserver、服务组以及服务和服务组绑定,不如将完成所有这些操作的样书作为组件导入,然后使用它在新的样书中创建这些配置对象。

样书添加第二个组件“monit-comp”(使用 Nitro 资源“lbmonitor”(内置样书)的属性)来创建监视器配置对象。它还有子组件“monit-svcgrp-bind-comp”用来创建绑定配置对象,该对象将监视器绑定到第一个组件中创建的服务组。由于在“basic-lb-config”样书中创建的 servicegroup 组件是作为输出公开的,因此此样书可以使用表达式 $components.basic-lb-comp.outputs.servicegroup-comp 来访问它。此示例说明导入样书如何能够使用 outputs 部分来访问原本无法访问的被导入样书中的组件。

接下来,将样书内容复制并粘贴到文本编辑器中,然后将该文件保存为 composite-example.yaml。在 Citrix ADM 中导入文件之前,请务必验证 YAML 内容。然后,将其导入 Citrix ADM 并使用此样书创建一个或多个配置。

Citrix 建议您使用样本中的内置 YAML 验证程序来验证和导入 YAML 内容。

本内容的正式版本为英文版。部分 Cloud Software Group 文档内容采用了机器翻译,仅供您参考。Cloud Software Group 无法控制机器翻译的内容,这些内容可能包含错误、不准确或不合适的语言。对于从英文原文翻译成任何其他语言的内容的准确性、可靠性、适用性或正确性,或者您的 Cloud Software Group 产品或服务沿用了任何机器翻译的内容,我们均不作任何明示或暗示的保证,并且适用的最终用户许可协议或服务条款或者与 Cloud Software Group 签订的任何其他协议(产品或服务与已进行机器翻译的任何文档保持一致)下的任何保证均不适用。对于因使用机器翻译的内容而引起的任何损害或问题,Cloud Software Group 不承担任何责任。
创建复合样本