Components
The Components construct in a StyleBook is considered as the most important section in the StyleBook. In this section, you define the configuration objects that have to be created. Using this construct, you can build one or multiple configuration objects of the same type.
The components construct can use the input provided in the parameters section to adapt the configuration generated by the StyleBook. This is an optional section, although most StyleBooks have a components section.
The following table describes the main attributes of a component.
Attribute | Description |
---|---|
name | The name of the component. You can specify an alphanumeric name. The name must begin with an alphabet, and can include additional alphabets, numbers, hyphen (-), or underscore (_). |
description | A description of the role of this component in the StyleBook. |
type | The type determines what properties this component provides. Components have two kind of types: Built-in type: This type is provided by the system and you do not have to define it, for example, the NITRO entity types “lbvserver” or “servicegroup.” When a component has a built-in type attribute, it creates a configuration object of that type on the NetScaler. For example, if a component refers to the built-in type “lbvserver,” this component creates a load balancing virtual server on the NetScaler instance that is the target of the configuration. Composite type: This type refers to an existing StyleBook that you created and imported into NetScaler Console. When a component has a composite type attribute, it creates all the configuration objects, which are specified in the referenced StyleBook, on the NetScaler instance that is the target of the configuration. This enables you to combine multiple StyleBooks where each StyleBook creates a part of the final configuration. For more information about composite StyleBooks, see Create a Composite StyleBook. |
properties | The sub-attributes that can be used for a component type attribute. The properties that are valid for a component are dictated by its type. For a built-in type, these are the properties or attributes of the corresponding Nitro object. For a component whose type is another StyleBook, that is, a composite type, the properties correspond to the parameters defined in that StyleBook. |
Example:
components:
-
name: my-lbvserver-comp
type: ns::lbvserver
properties:
name: $parameters.name
servicetype: HTTP
ipv46: $parameters.ip
port: 80
lbmethod: $parameters.lb-alg
<!--NeedCopy-->
In this example, you have defined a component called my-lbvserver-comp. This component is of type ns::lbvserver (a built-in type), where “ns” is the prefix that refers to the namespace netscaler.nitro.config and version 10.5 that you had specified in the import-stylebooks section, and “lbvserver” is a NITRO resource in this namespace.
The properties in this section include four mandatory and one optional attribute (lbmethod) of the “lbvserver” resource and allows you to specify values for these attributes. In this example, you are specifying static values for servicetype and port while the name, ipv46, and lbmethod properties get their values from the input parameters. You refer to the parameter names defined in the parameters section by using $parameters.<name> notation, for example, $parameters.ip.
Note
You have to use lower case for the attribute names of NITRO resource types (its component properties). Otherwise, the import of a StyleBook will fail.