StyleBook configuration

Use an ADC instance as the data source

You can use the managed ADC instances as data sources. The managed-adc is a built-in data source type that can be readily used as the data sources in ADM. Each managed ADC instance in ADM is a data source by default. You can start using these data sources in your StyleBooks if you need data from an existing ADC managed by ADM while creating configuration packs.

In the StyleBook definition, specify the datum built-in type parameter. So, you can use the data source types in your StyleBook. The StyleBook users can select a data source that can be used to retrieve data from that source.

Using the built-in data source without collection

parameters:
  -
    name: selected-adc
    label: Select an existing lbvserver
    type: datum
    required: true
    data-source:
      type: managed-adc
<!--NeedCopy-->

In the example, the datum parameter is used to select any ADC instance managed by ADM. The managed-adc built-in data source allows you to retrieve data from any ADC instance managed by NetScaler ADM.

In your StyleBook, you can access any configuration from the selected ADC instance. And, you can use that configuration while creating or updating configurations on the same ADC or a different ADC instance; it depends on the selected target ADC instance.

Select the collection from a data source:

In the selected ADC instance, to access a collection, use the following expression:

$parameters.selected-adc.collections.<collection-name>
<!--NeedCopy-->

Example:

$parameters.selected-adc.collections.lbvserver
<!--NeedCopy-->

This expression returns the list of lbvserver on the selected ADC instance. For example, you can iterate over this list to select a specific lbvserver that meets a certain condition.

Example StyleBook without collection

name: add-vservers-from-managed-adc-instances
namespace: com.citrix.adc.stylebooks
version: "1.0"
schema-version: "1.0"

import-stylebooks:
  -
    namespace: netscaler.nitro.config
    prefix: ns
    version: "10.5"

parameters:
    -
      name: selected-adc
      label: Select a custom datasource environment
      type: datum
      required: true
      data-source:
        type: "managed-adc"

components:
  -
    name: sslvserver-comp
    type: ns::sslvserver
    repeat: $parameters.selected-adc.collections.lbvserver
    repeat-item: lbvs
    repeat-condition: $lbvs.attributes.servicetype == "SSL"
    properties:
      name: $lbvs.attributes.name
      ssl2: DISABLED
      ssl3: DISABLED
      tls1: DISABLED
      tls11: ENABLED
      tls12: ENABLED
<!--NeedCopy-->

The configuration pack GUI displays the managed ADC instances by ADM and StyleBook users can select any ADC when creating or updating the configuration pack.

Built-in ADC data source without collection

This StyleBook uses the selected ADC by iterating over all the lbvserver. It selects the SSL virtual servers and sets the allowed version on each virtual server.

The following expression allows you to iterate through the list of lbvserver in the ADC instance.

repeat: $parameters.selected-adc.collections.lbvserver
<!--NeedCopy-->
  • collections: Refers to entity types on the ADC instance.

  • lbvserver: Refers to the list of load-balancing virtual servers in the ADC instance.

For each lbvserver that meets the condition (servicetype == SSL), it updates the SSL settings of the virtual servers to allow specific SSL versions.

Using the built-in data source with collection

parameters:
  -
    name: selected-lbvserver
    label: Select an existing ADC
    type: datum
    required: true
    data-source:
      type: managed-adc
      collection: lbvserver
<!--NeedCopy-->

In this example, the datum parameter is used to select both the ADC instance and lbvserver from the managed-adc data source type.

When you define a collection type in the parameters section, the StyleBook users can select the ADC instance and a specific entity from a collection on that instance.

Built-in ADC instance data source with collection

Select an attribute of the collection:

When the StyleBook user selects a virtual server, the following expression in your StyleBook can access any attribute of the selected item.

$parameters.selected-lbvserver.attributes.<attribute-name>
<!--NeedCopy-->

In this example, the selected datum is lbvserver. So, you can access any attribute of the ADC entity lbvserver such as name, servicetype, ipv46, and so on.

Example:

$parameters.selected-lbvserver.attributes.name
<!--NeedCopy-->

This expression retrieves the name of the selected load-balancing virtual server. For more information about the ADC entities (collections) and their attributes, see NetScaler NITRO API reference.

Select a list of the collection:

Apart from the StyleBook user selected item, you can also access any item from the same or different collections on the selected ADC instance. To access another collection on that ADC instance, use the following expression in the components section:

$parameters.selected-lbvserver.datasource.collections.<collection-name>
<!--NeedCopy-->

Example:

$parameters.selected-lbvserver.datasource.collections.csvserver
<!--NeedCopy-->

This expression returns the list of content-switching virtual servers from the selected ADC instance.

And, the following expression returns a list of all the bindings between lbvservers and servicegroups:

$parameters.selected-lbvserver.datasource.collections.lbvserver_servicegroup_binding
<!--NeedCopy-->

Example StyleBook with a collection

The following is an example StyleBook to demonstrate how to use the managed ADC instance as a data source:

---
name: bind-lb-to-servicegroup-using-ADC-as-datasource
namespace: com.citrix.adc.stylebooks
version: "1.1"
display-name: "HTTP/SSL LoadBalancing StyleBook with Service Binding"
description: "This stylebook defines a typical Load Balanced Application configuration where we allow the user to select an existing lbvserver on the ADC using datum type parameter. Then a servicegroup for the selected lb is created if it does not exist on the ADC. Finally, the selected lbvserver is bound to the service "
schema-version: "1.0"
import-stylebooks:
  -
    namespace: netscaler.nitro.config
    prefix: ns
    version: "10.5"

parameters:
  -
    name: selected-vserver
    label: "Select an Existing VServer"
    description: "Load Balancing Application Vservers to be bound to service on the ADC"
    type: datum
    required: true
    data-source:
      type: managed-adc
      collection: lbvserver
  -
    name: services
    label: Services
    type: object[]
    required: true
    parameters:
      -
        name: ip
        label: IP address
        type: ipaddress
        required: true
      -
        name: port
        label: Port
        type: tcp-port
        required: true

components:
  -
    name: servicegroup-discovery-comp
    type: object
    repeat: $parameters.selected-vserver.datasource.collections.servicegroup
    repeat-item: svcgrp
    repeat-condition: $svcgrp.attributes.servicegroupname ==  $parameters.selected-vserver.attributes.name + "-svcgrp"
    properties:
      servicegroupname: $svcgrp.attributes.servicegroupname
  -
    name: servicegroup-creation-if-not-exists-comp
    type: ns::servicegroup
    condition: not exists($components.servicegroup-discovery-comp)
    properties:
      servicegroupname: $parameters.selected-vserver.attributes.name + "-svcgrp"
      servicetype: $parameters.selected-vserver.attributes.servicetype
  -
    name: servicegroupmember-comp
    type: ns::servicegroup_servicegroupmember_binding
    repeat: $parameters.services
    repeat-item: service
    properties:
      servicegroupname: if-then-else($components.servicegroup-discovery-comp, $components.servicegroup-discovery-comp.properties.servicegroupname, $components.servicegroup-creation-if-not-exists-comp.properties.servicegroupname)
      ip: $service.ip
      port: $service.port
<!--NeedCopy-->

In this StyleBook, the components section checks for the service group name that matches the selected load-balancing virtual server name concatenated with svcgrp.

If the name of the selected load-balancing virtual server is lbv1, this StyleBook checks for the service group with the name lbv1-svcgrp. If it is not found, it creates a service group lbv1-svcgrp and binds with the lbv1 virtual server.

The following expression fetches the list of service groups in the ADC instance.

repeat: $parameters.selected-vserver.datasource.collections.servicegroup
<!--NeedCopy-->
  • datasource: Refers to the selected ADC instance managed by ADM.

  • collections: Refers to the entities in the ADC instance.

  • servicegroup: Refers to the service groups in the ADC instance.

Use an ADC instance as the data source