StyleBook configuration

Parameters-default-sources construct

You can use this construct to reuse parameter definitions from other StyleBooks.

Consider a scenario where a parameter or a group of parameters is used repeatedly in multiple StyleBooks. To avoid redefining these parameters, each time you want to create a new StyleBook, you can define them once, and then import their definitions into the StyleBooks that need these parameters by using the parameters-default-sources construct.

For example, if many of your StyleBooks need to configure a virtual IP, you might have to define the same parameters related to virtual IPs in each new StyleBook you create. Instead, you can create a separate StyleBook called, for example, vip-params where you define all the parameters related to it as shown in the following example:

     -

     name: vip-params

     namespace: com.acme.commontypes

     version: "1.0"

     description: This StyleBook defines a typical virtual IP config.

     private: true

     schema-version: "1.0"

     parameters:

       -

           name: lb-appname

           label: Load Balanced Application Name

          description: Name of the Load Balanced application

           type: string

           required: true

       -

           name: lb-virtual-ip

           label: Load Balanced App Virtual IP address

           description: Virtual IP address representing the Load Balanced application

           type: ipaddress

           required: true

       -

           name: lb-virtual-port

           label: Load Balanced App Virtual Port

           description: TCP port representing the Load Balanced application

           type: tcp-port

           default: 80

       -

           name: lb-service-type

           label: Load Balanced App Protocol

           description: Protocol used for the Load Balanced application.

           type: string

           default: HTTP

           required: true

           allowed-values:

                - HTTP

                - SSL

                - TCP
<!--NeedCopy-->

Then, you can create other StyleBooks that use these parameters

     -

     name: acme-biz-app

     namespace: com.acme.stylebooks

     version: "1.0"

     description: This stylebook defines the NetScaler configuration for Biz App

     schema-version: "1.0"

     import-stylebooks:

       -

          namespace: com.acme.commontypes

          prefix: cmtypes

          version: "1.0"

     **parameters-default-sources:**

**            - cmtypes::vip-params**

     parameters:

         -

           name: monitorname

           label: Monitor Name

           description: Name of the monitor

           type: string

           required: true

         -

           name: type

           label: Monitor Type

           description: Type of the monitor

           type: string

           required: true

           allowed-values:

             - PING

             - TCP

             - HTTP

             - HTTP-ECV

             - TCP-ECV

             - HTTP-INLINE
<!--NeedCopy-->

In the StyleBook, acme-biz-app, first, the namespace and version of the vip-params StyleBook is imported by using the “import-stylebooks” section. Then the parameters-default-sources construct is added, and the StyleBook name, that is, vip-params is specified. This parameter has the same effect as defining the parameters of the vip-params StyleBook directly in this StyleBook.

You can include parameters from multiple StyleBooks because the parameters-default-sources is a list, and each item in the list is expected to be a StyleBook.

In addition to including parameters from other StyleBooks, you can also define your own parameters by using the parameters section. The complete list of parameters of the StyleBook is the combination of parameters included from other StyleBooks and parameters defined in this StyleBook. Therefore, the expression $parameters refers to this combination of parameters.

If a parameter is defined both in an imported StyleBook and in the current StyleBook, the definition in the current StyleBook overrides the definition imported from another StyleBook. You can use this approach effectively by customizing a few of the imported parameters if necessary, while using the rest of the imported parameters as they are.

The parameters-default-sources construct can also be used in nested parameters as shown:

parameters:

    -

      name: vip-details

      label: Virtual IP details

      description: Details of the Virtual IP

      type: object

      required: true

      parameters-default-sources:

              - cmtypes::vip-params
<!--NeedCopy-->

This approach is similar to having the parameters of the StyleBook vip-params added directly as child parameters of the vip-details parameter in this StyleBook.

Parameters-default-sources construct

In this article