Programmable Configlets enable you to dynamically generate configurations for your devices. By leveraging a combination of custom variables, loops, conditional statements, and built-in device functions, you can create flexible and reusable configurations. This guide explains how to use various functions in Programmable Configlets effectively.
To use device details inside configlet, please refer below table for available methods
| SI.NO | Command | Description |
|---|---|---|
|
1 |
$device.ip()
|
To get device ip address |
|
2 |
$device.hostname()
|
To get device hostname |
|
3 |
$device.imgfile()
|
To get image file |
|
4 |
$device.macaddr()
|
To get mac address |
|
5 |
$device.serialno()
|
To get serial number |
|
6 |
$device.ostype()
|
To get OS type of device |
|
7 |
$device.vendor()
|
To get device vendor |
|
8 |
$device.protocol()
|
To get device protocol |
|
9 |
$device.devicetype()
|
To get device type/personality |
|
10 |
$device.template()
|
To get device template |
|
11 |
$device.model()
|
To get device model |
|
12 |
$device.series()
|
To get device series |
|
13 |
$device.osversion()
|
To get the OS version of device |
| Functionalities | Syntax | Sample |
|---|---|---|
|
To split a string by a delimiter |
$util.split(String input, String regex)
|
$util.split("hostname,interface,ip_address",","); |
|
Converts a string number to an integer/bigIntObject |
|
|
|
Extracts a portion of a string/integer/long using regex (e.g., finding the progress percentage, ErrorCode from command output). |
|
|
|
To pause the execution of the script for a given number of seconds. |
$util.sleep(int seconds)
|
$util.sleep(5); |
|
To returns the current date(using a custom or default format). |
|
|
| Functionalities | Syntax |
|---|---|
| To get Server Ip | $server.ip() |
| To get Syslog port | $server.syslogport() |
Using common operators (&&, ||, ==, !=, >, <) for comparisons.
Arrays are treated as fixed-length lists, allowing list methods like:
Common string functions include: