TMSH CLI script to add/remove a single VLAN from a route-domain (iControl-callable)
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.0Published Aug 13, 2019
Version 1.0G-Rob
Employee
F5 Solutions Engineer focused on cloud, automation, modern apps and excellent customer-focused service.G-Rob
Employee
F5 Solutions Engineer focused on cloud, automation, modern apps and excellent customer-focused service.1 Comment
- John_Alam
Employee
Gregory, this is a great post. It would be helpful if you include the response from the REST POST. The response should indicate the result.