How to: Create and Use Custom Fields in ZPE Cloud

How to: Create and Use Custom Fields in ZPE Cloud

Custom fields is a way to make your profiles/templates more dynamic.  A custom field is similar to a variable in that it can have different values depending on the scope of the field.  You can create a custom field under "Profiles::Custom Fields".  Select NEW to create a new custom field



Provide a name, value, and scope.  The name does not have to be unique.  Using a fields with same name allows for variability based on the scope.  For example, you can have a field named 'primary_dns' with different scopes and depending on the context of the target device, the value will be determined by the closest matching scope. Below is a table describing the scopes and what they apply to and the precedence in the cased the custom field name is the same.

Context

Applies To

Precedence

Global

Everything: all groups, all sites, all devices

Last

Group

Any device in the specified group

Third

Site

Any device in the specified site

Second

Device

Only to the specified device

First


In the following scenario:



NYC-BSR-01 and NYC-BSR-02 are in Site: NYC

NYC-GSR-01 is not in any site


Value of primary_dns when used in a profile and applied to NYC-BSR-01: 1.1.1.1

Value of primary_dns when used in a profile and applied to NYC-GSR-01: 8.8.8.8

Value of primary_dns when used in a profile and applied to NYC-BSR-02: 10.1.0.10


To use the custom variable in your templates/profiles, you create a "Dynamic Template" by setting the "Dynamic Template" checkbox for the template, and then enclose the variable names with double curly braces: {{primary_dns}}.

Below is sample dynamic template that uses custom fields.

  1. set /settings/date_and_time server={{mt_ntp_server}}
    set /settings/network_settings hostname={{mt_hostname}}
    set /settings/network_connections/ETH1 ipv4_mode=static
    set /settings/network_connections/ETH1 ipv4_address={{mt_eth1_address}}
    set /settings/network_connections/ETH1 ipv4_bitmask={{mt_eth1_bitmask}}