Supported Built-in Functions in Network Intent
Network Intent supports built-in functions to define compound variables, compound tables, or Formula Columns to convert predefined variables in terms of variable types, units, values, etc.
The following table lists the built-in functions that will provide you the overview of the functions.
![]() |
Note: For the functions Sum, Average, Min, and Max, their return values are in the type of float. So they must be assigned to float variables; otherwise, the assignment will fail. |
Function Spec | Description | Sample Function Call |
number IPStringToNumber (string ip) | Convert an IP address from string format to an integer. Masked IP address is allowed, e.g., “192.168.91.1/28”. Note: Returning “-1” if the input is not a valid IP address. | IPStringToNumber(“192.168.91.1”) Return: 3232258817 |
string IPNumberToString (number ip) | Convert an IP address from integer format to string format. Note: Returning NULL (“”) represents error. | IPNumberToString(3232258817) Return: “192.168.91.1” |
number PercentageToNumber (string percent) | Convert a percentage as a text to a float number. Note: Returning “-1” if the input is not a valid percentage. | PercentageToNumber(“50%”) Return: 50 |
number ByteConverter (string input) | Convert storage units (such as KB, MB, GB, etc.) to byte. Note:
| ByteConverter(“35MB”) Return: 36,700,160 Bytes (35x1024x1024) |
string NumberToString (number input) | Convert a number to string format. Note: Returning NULL (“”) if the input is not a valid number. | NumberToString(5) Return: "5" |
number StringToNumber (string input) | Convert a string-type number to a number-type. Note: Returning "-1" if the input string is not a valid number. | NumberToString(“19”) Return: 19 |
string IPToHostname (string ip) | Convert an IP address to the hostname. The input can be an IP address or a masked IP address such as “192.168.91.1/28”. Note:
| IPtoHostname(“192.168.91.1”) Return: “R1” |
string TrimRight (string original, string trimChars) | Trim one or more characters on the right side of a given string and return the trimmed string. If the designated character is left blank, it will be identified as a space character. Note: Returning original input string if the trim fails. | TrimRight(“4.03,” ”,”) Return: “4.03” |
string TrimLeft (string original, string trimChars) | Trim one or more characters on the left side of a given string and return the trimmed string. If the designated character is left blank, it will be identified as a space character. Note: Returning original input string if the trim fails. Note: Returning original input string if the trim fails. | TrimLeft(”-4.03”, ”-“) Return: “4.03” |
string Replace (string original, string old, string new) | Replace one character with another in a given string and return the replaced string. Note: Returning the original input string if the replacement fails. | Replace(”2020-8-23”, “-”, “/“) Return: “2020/8/23” |
string FormatMAC (string mac_address) | Get formatted MAC address Note: Returning original MAC address if the format fails. | FormatMAC(“D8-67-D9-86-59-40”) Return: “d867.d986.5940” |
string IPToInterfaceName (string ipaddr) | Obtain a device interface full name by using a given IP address. Masked IP address is allowed, e.g., “192.168.91.1/24”. Note: Returning NULL(“”) if the input is not a valid IP address. If an IP address is configured in more than one interface, return the full name of one interface randomly. | IPtoInterfaceName(“192.168.91.1”) Return: “FastEthernet1/1” |
string InterfaceShortToFull (string hostname, string shortname) | Obtain an interface full Note: Returning NULL (“”) if the input is not a valid interface name. | InterfaceShortToFull(“R1”,”Ether2/1”) Return: “Ehternet2/1” |
number Find (string str, string substr) | Find one or more characters with another in a given string. Note: Returning “-1” if nothing is found. | Find(”router ospf 100”, “ospf”) Return: 1(True) or 0(False) |
number GetTableRowCount (string tableName) | Obtain a table rows count by using a given table name Note: Returning “-1” if | GetTableRowCount(“ospf_nbrs”) Return: 32 |
string|number Delta ( variable_name) | Get the delta between the variables current and last. Note: Only applies to variables of type number Note: Returning “-1” if the calculation failed. | Delta($intf_traffic) Return: 0 |
string IPToSubnet(ip) | Return the subnet of an IP address. Masked IP address is allowed, e.g., “192.168.91.1/24" , "192.168.91.1 255.255.255.255.0". Note:
| IPToSubnet("192.168.100.15/28") Return: 192.168.100.0/28 |
string MACToVendor(string mac_address) | Return the vendor information about a device by MAC address. Note: Returning NULL(“”) if the input is not a valid MAC address. | MACToVendor("AAAA.1111.2222.4444") Return: Cisco |
string SNToDevice(string serial_number) | Return a device object by its serial number. Note: Returning NULL(“”) if the input is not a valid serial number. | SNToDevice("SNX1992") Return: BJ*POP |
number Average (table table, string column_name) | Returns the average(arithmetic mean) of a set of value Note: Returning “-1” if the input is not a valid number array. | Average($bgp,"bgp_routes") Return: 10 |
number Sum (table table, string column_name) | Returns the sum in a set of values. Note: Returning “-1” if the input is not a valid number array. | Sum($bgp, "bgp_routes") Return: 11 |
number Max (table table, string column_name) | Returns the largest value in a set of values. Note: Returning “-1” if the input is not a valid number array. | Max($intfs, "traffic") Return: 12 |
number Min (table table, string column_name) | Returns the minimum value in a set of values. Note: Returning “-1” if the input is not a valid number array. | Min($intfs, "traffic") Return: 13 |
number CompareDate(string target_date) | Compare target date with the current time. Note: Returning “0” if the target data is earlier than the current time; otherwise returns "1". | CompareDate("$end_of_sale_date") Return: 0 or 1 |
number Round(number number) | Return number rounded to two digits precision after the decimal point. Note: Returning “-1” if the input is not a valid number. | Round (36.8732994298449) Return: 36.87 |
string FormalizeIntfStatus(string intf_status) | Return formalized interface status information based on the given interface status information. | FormalizeIntfStatus("up") Return: "UP" |
number CalcTrafficBps(number traffic_byte, number sys_time) | Calculate interface traffic (bit) based on given traffic (byte) data and system uptime information. Note: RFC 1213 defines sysUp Time as a 32-bit counter in 1/100 second. | CalcTrafficBit(191941437745628,3282115859) Return: 1000 |
string FormalizeTrafficInfo(number traffic_bit, number traffic_utilization) | Return formalized interface traffic and traffic utilization string based on given traffic (bit) and utilization information. | FormalizeTrafficInfo($traffic_in_bit,$traffic_utilization) Return: "%.1f Kbps, <0.1%" |
string CalcTrafficInfoRaw(string traffic_in_byte_variable, string sys_uptime_variable , string bandwidth_variable) | Return formalized interface traffic and traffic utilization string based on given traffic (byte), system uptime, and bandwidth information. Note:
| CalcTrafficInfoRaw($trafic_byte,$sys_uptime,$bandwidth) Return: "%.1f Kbps, <0.1%" |
number CalcTrafficUtilization(number traffic_bit, number bandwidth) | Calculate interface utilization based on given traffic (bit) and bandwidth information. Note: The format of bandwidth is GAUGE32. | CalcTrafficUtilization($traffic_in_bit,10000000000) Return: 100 |
string Trim(string original, string trimchars) | Trim characters before/after specified characters. If the “trimchars” value is "", the null characters (including null rows) before/after a specified character are removed. If the “trimchars” value is inputted, only the specified character is trimmed. | Trim($str,"") Return: "policy-map qos class videopolice 40960000 conform-action transmit exceed-action drop" |
string GetTimeString(number offset, number timeunit) | Get a certain time before the current time and return the time with string. If the offset value is "0", the current time will be returned with string. The value of timeunit can be set as 0/1/2, respectively representing min/hour/day. | GetTimeString(1, 1) Return: "08/09/2023 11:34:00" |
Device Device(string Hostname) | Create a device object with an existing device for further operation. Note: IP address can also be passed in as hostname variable, which will be automatically recognized and converted. | Device(“BJ*POP”) Return: device |
bool DoesDeviceExist(string Hostname) | Check whether a device still exists in the current domain. Note: IP address can also be passed in as hostname variable. | DoesDeviceExist(“BJ*POP”) Return: True/False |
Interface Interface(string Hostname, string InterfaceName, string InterfaceType="Interface") | Create a device interface object with an existing interface for further operation. Users can enter the following string or number as InterfaceType:
| Interface(“BJ*POP”, “ethernet0/0”, 1) Return: interface |
Interface InterfaceByIP(string IPAddress) | Create a device interface object with an existing interface IP for further operation. If there are duplicated IPs, use the first matching one. IPv4 and IPv6 addresses will be automatically identified. | InterfaceByIP(“10.8.1.30”) Return: interface |
bool DoesInterfaceExist(string Hostname, string InterfaceName) | Check whether an interface still exists in the current domain. | DoesInterfaceExist(“BJ*POP”, “ethernet0/0”) Return: True/False |
Path Path(string ApplicationName, string PathName) | Create a path object with an existing path defined in domain for further operation. Creating new paths is not supported. | Path(“EmailService”, “ClienttoDNS”) Return: path |
Map NewMap (string FullPath) | Create a new map object with specified full path of the target map file. Creating function map is not supported. | NewMap (“Files/Private/DeviceNeighbor”) Return: map |
Map Map(string FullPath) | Create a map object with an existing map for further operation. Only support normal maps, not support function maps. | Map (“Files/Public/OpenTopo”) Return: map |
DeleteMap(string FullPath) | Delete an existing normal map with specified full path of the map file. Not support function maps here. | DeleteMap (“Files/Public/OpenTopo”) Return: N/A |
Site NewSite (string Name, string FullPathOfParent, bool IsLeafSite) | Create a new site.
| NewSite (“Netbrain-MultiSource”, “My Network/Traditional-DC”, True) Return: site |
Site Site (string Name, string FullPathOfParent) | Create a site object with an existing site for further operation. | Site (“Cisco-WLC-Lab”, “My Network/Traditional-DC”) Return: site |
Map GetSiteOverviewMap() | Get the overview map of all sites. | GetSiteOverviewMap() Return: map |
DeviceGroup NewDeviceGroup (string Name, string Folder) | Create a new device group. | NewDeviceGroup (“BGPDevices”, “BGP”) Return: devicegroup |
DeviceGroup DeviceGroup (string FullPath) | Create a device group object with an existing device group for further operation. | DeviceGroup (“Device Group/Shared Device Groups/BGP/BGP Devices”) Return: devicegroup |
File NewFile (string FileName, string Folder, string Type="Text") | Create a new text file in NetBrain files.
| NewFile (“OpenTopo”, “Files/Public”, "Text") Return: file |
File File (string FullPath, string Type="Text") | Create a file object with an existing file for further operation. | File (“Files/Public”, "Text") Return: file |
int ConvertToInt(var) float ConvertToFloat(var) string ConvertToString(var) bool ConvertToBool(var) | Convert the input variable to specified type and each function supports 4 types of variables.
| ConvertToFloat(“2.1”) Return: 2.1 |
list<string> SplitString(string input, string SeparatorChars) | Split the input into multiple strings based on one or more given separator chars. | SplitString(“device1 device2 device3”, “ ”) Return: {device1,device2,device3} |
int GetListElementCount(List) | Get the element count of a specified list. | GetListElementCount(List) Return: 6 |
int VerifyGoldenConfig(string FullPath_Of_Golden_Rule,string DeviceName,bool RefreshConfigFile=true) | See Built-in Functions for Follow-up Remediation for more information. | |
Table GetGoldenConfigCheckResult(string FullPath_Of_Golden_Rule, string DeviceName, bool OnlyInstanceWithAlert=True) | ||
Table ReadAsTable(string columnMappings) | Read data from a CSV file and map it to the intent table variable based on the defined relationship. How Column Mappings Work: Define the mapping columns from the CSV, separating them with commas (,). The position numbers of the columns will correspond to those of the table variable columns. If you don't want to map certain columns in the table, leave their positions as null. | ReadAsTable("Column 1, , CSVcolumn3, ,CSVcolumn2,CSVcolumn4") Return: table data for intent table variable |