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:
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] (#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.
-
In Applications > Configuration > Data Sources.
-
Select Data Source Type.
-
Specify the Name and Description for the data source type.
-
Click Create.
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.
-
Go to Applications > Configuration > Data Sources.
-
Click Add.
-
Specify the Data Source Name, Data Source Type, and Description.
-
Click Create.
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.
-
Go to Applications > Configuration > Data Sources.
-
Select Collection Types.
-
Click Add.
-
Specify the Name for a collection type.
-
Select the Data source Type.
-
Add the attribute name and its type.
-
Click Create.
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.
-
Go to Applications > Configuration > Data Sources.
-
In Collection Types, select the collection type to which you want to add collections.
-
Specify the Name for a collection.
-
Select the Data Source.
-
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.
-
Click Create.
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 config pack GUI displays the applicable data sources and StyleBook users can select any of them to create a config pack.
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.