Citrix Application Delivery Management 服务

创建复合样本

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

例如,您可以使用您在上一节中构建的基本 Lb-配置样本来构建另一个名为合成示例的样本。要使用“basic-lb-config”样本,必须在新样本的 import-stylebooks 部分将其导入。

构建您的样本

新样本类似如下:

name:composite-examplenamespace:com.example.stylebooksversion:"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.configversion:"10.5"prefix:ns-namespace:com.example.stylebooksversion:"0.1"prefix:stlbparameters:-name:nametype:stringlabel:Application Namedescription:Give a name to the application configuration.required:true-name:iptype:ipaddresslabel:Application Virtual IP (VIP)description:The Application VIP that clients accessrequired:true-name:svc-serverstype:ipaddress[]label:Application Server IPsdescription:The IP addresses of all the servers of this applicationrequired:true-name:response-codetype:string[]label:List of Response Codesdescription:List of Response Codes - Provide a list of response codes in integer.components:-name:basic-lb-comptype:stlb::basic-lb-configdescription:This component's type is another StyleBook that builds the NetScaler lbvserver, servicegroups and services configuration objects.properties:name:$parameters.nameip:$parameters.ipsvc-servers:$parameters.svc-servers-name:monit-comptype:ns::lbmonitordescription:This component is a basic Nitro type (a Builtin StyleBook) that builds the NetScaler monitor configuration object.properties:monitorname:$parameters.name + "-mon"type:HTTPrespcode:$parameters.response-codehttprequest:"'GET/'"lrtm:ENABLEDsecure:"YES"components:-name:monit-svcgrp-bind-comptype:ns::servicegroup_lbmonitor_bindingproperties:servicegroupname:$components.basic-lb-comp.outputs.servicegroup-comp.properties.servicegroupnamemonitor_name:$parent.properties.monitorname

在 import-stylebook 部分,您可以使用作为前缀stlb引用的命名空间和版本导入 basic-lb-config 样书。

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

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

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

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

创建复合样本