I am obviously new to any kind of programming or scripting and I am beating my head against a wall trying to figure this out. Below is a config change template I've created to create a new Loopback interface on a Juniper SRX router using the 3rd octet as the 4th octet of the new interface. However, I am getting an error when executing the script and I'm not sure where I went wrong. The error is "Error: Entity IPAddress does not refer to a ManagementObject."
/*
.CHANGE_TEMPLATE_DESCRIPTION
This will create a loopback interface on a branch router using the 3rd octect of the LAN IP address..
.CHANGE_TEMPLATE_TAGS
SRX, JUNOS, JUNIPER
.PLATFORM_DESCRIPTION
Juniper Devices.
.PARAMETER_LABEL @ContextNode
NCM Node
.PARAMETER_DESCRIPTION @ContextNode
The node the template will operate on. All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.
.PARAMETER_LABEL @LoopSubnet
Loopback Subnet
.PARAMETER_DESCRIPTIONL @LoopSubnet
Enter the first 3 octects for the loopback subnet. The last octect will be modified by the script.
Example : 172.30.255.0..
*/
script CreateLoopbackInterface (
NCM.Nodes @ContextNode,
string @LoopSubnet
)
{
string @ThirdOctet
string @LoopIP
@ThirdOctet = GetOctet(@ContextNode.IPAddress, 2)
@LoopIP = SetOctet(@LoopSubnet, 3, @ThirdOctet)
}
// Enter configuration mode and create Loopback interface.
CLI
{
configure
set interfaces lo0 unit 0 family inet address @LoopIP
}
CLI
{
commit
exit
}}