Problem this snippet solves:
If you want to add or delete a single VLAN from a route domain without sending in the entire list of VLANs, you can use this CLI script.
How to use this snippet:
Sample REST calls:
curl -sk -u admin:admin -H "Content-Type: application/json" -X POST https://your-ip-address/mgmt/tm/cli/script -d '{"command":"run","name":"modifyRouteDomainVlans","utilCmdArgs":"myroutedomainname vlan3942 add"}'
curl -sk -u admin:admin -H "Content-Type: application/json" -X POST https://your-ip-address/mgmt/tm/cli/script -d '{"command":"run","name":"modifyRouteDomainVlans","utilCmdArgs":"myroutedomainname vlan3942 delete"}'
Code :
cli script /Common/modifyRouteDomainVlans {
proc script::run {} {
if { $tmsh::argc !=4 } {
exit 123
}
set zero [lindex $tmsh::argv 0]
set routeDomain [lindex $tmsh::argv 1]
set vlanName [lindex $tmsh::argv 2]
set command [lindex $tmsh::argv 3]
tmsh::modify /net route-domain [lindex $tmsh::argv 1] vlans [lindex $tmsh::argv 3] "{[lindex $tmsh::argv 2]}"
exit 0
}
}
Tested this on version:
13.0