StyleBook configuration

Use custom data sources

Along with managed NetScaler instances as a data source, you can define and use custom data sources if the input data is repeatedly used for creating multiple configurations. You can save the input data in NetScaler Console as a data source. And, you can modify StyleBooks to consume this data without requiring StyleBook users to provide inputs repeatedly.

Before using a custom data source in your StyleBook definition, do the following to define a custom data source:

  1. Add a data source type.
  2. Add a data source.
  3. Add a collection type.
  4. Add a collection.

After adding a data source, you can use this data source to in the StyleBook definition. For more information, see Use custom data sources in the StyleBook definition.

Add a data source type

Specify a data source type to distinguish the source from which data is retrieved.

  1. In Applications > Configuration > Data Sources.

  2. Select Data Source Type.

  3. Specify the Name and Description for the data source type.

  4. Click Create.

Data source type

In this example, the data source type is set to Environment. This type can be used to define the application environments as data sources.

Add a data source

Define a data source for a specific data source type.

  1. Go to Applications > Configuration > Data Sources.

  2. Click Add.

  3. Specify the Data Source Name, Data Source Type, and Description.

  4. Click Create.

Custom data source

In this example, the Production environment is added as a data source.

Add a collection type

Add a collection type to describe the type of data that can be stored in a collection.

  1. Go to Applications > Configuration > Data Sources.

  2. Select Collection Types.

  3. Click Add.

  4. Specify the Name for a collection type.

  5. Select the Data source Type.

  6. Add the attribute name and its type.

  7. Click Create.

Collection type

In this example, the App-virtual-servers collection type has four attributes. So, the collection that you want to store must have these attributes of the set data types.

Add a collection

Add collections respective to the selected collection type.

  1. Go to Applications > Configuration > Data Sources.

  2. In Collection Types, select the collection type to which you want to add collections.

  3. Specify the Name for a collection.

  4. Select the Data Source.

  5. Add data to the collection. You can either add data one by one or upload a CSV file.

    If you are uploading a CSV file, ensure the column names are matching with the attribute names of the collection type.

  6. Click Create.

Collections

Use custom data source without collection

The following parameters section explains how to define a custom data source in the StyleBook definition without collection.

parameters:
    -
      name: selected-environment
      label: Select a custom datasource environment
      type: datum
      required: true
      data-source:
        type: "Environment"
<!--NeedCopy-->

The configuration pack GUI displays the applicable data sources and StyleBook users can select any of them to create a configuration pack.

Custom data source without collection

In this example, it uses the Production data source to retrieve data.

In the Environment data source type, to access the App-virtual-servers collection type, use the following expression:

$parameters.selected-environment.collections.App-virtual-servers
<!--NeedCopy-->

Example Snippet:

components:
  -
    name: lbvserver-comp
    type: ns::lbvserver
    repeat: $parameters.selected-environment.collections.App-virtual-servers
    repeat-item: app
    properties:
      name: $app.attributes.Name + "-lb"
      ipv46: ip($app.attributes.IPv46 )
      port: $app.attributes.Port
      servicetype: $app.attributes.Protocol
    components:

      -
        name: servicegroup-comp
        type: ns::servicegroup
        properties:
          servicegroupname: $parent.properties.name + "-svcgrp"
          servicetype: $parent.properties.servicetype

        components:
          -
            name: lbvserver-svg-binding
            type: ns::lbvserver_servicegroup_binding
            properties:
              name: $parent.parent.properties.name
              servicegroupname: $parent.properties.servicegroupname
<!--NeedCopy-->

Use custom data sources with collection

The following parameters section explains how to define a custom data source in the StyleBook definition. It allows StyleBook users to select a specific item of a collection.

parameters:
  -
    name: selected-app-vserver
    label: Select a collection from the datasource
    type: datum
    required: true
    data-source:
      type: Environment
      collection: App-virtual-servers
<!--NeedCopy-->

In this example, the datum parameter is used to define the custom data source. It uses the Production data source to retrieve data from the App-virtual-servers collection type.

In the Environment data source type, to access the protocol from the App-virtual-servers collection, use the following expression:

$parameters.selected-app-vserver.attributes.Protocol
<!--NeedCopy-->

Example snippet:

components:
  -
    name: lbvserver-comp
    type: ns::lbvserver
    properties:
      name: $parameters.selected-app-vserver.attributes.Name
      ipv46: $parameters.selected-app-vserver.attributes.IPv46
      port: $parameters.selected-app-vserver.attributes.Port
      servicetype: $parameters.selected-app-vserver.attributes.Protocol
<!--NeedCopy-->

When you define a collection type in the parameters section, the StyleBook users can select the data source and collection.

Use custom data sources