For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

TMSH CLI script that adds/deletes a single VLAN to a VCMP Guest

Problem this snippet solves:

You can call these via iControl REST to take advantage of adding/deleting a single VLAN from a VCMP guest without needing to send in the entire list of VLANs.


How to use this snippet:

Sample REST call:

 

curl -sk -u admin:admin -H "Content-Type: application/json" -X POST https://your-ip-address/mgmt/tm/cli/script -d '{"command":"run","utilCmdArgs":"addVlan vlan394 myvcmpguest.local"}'  


Code :

cli script /Common/addVlan {  
proc script::init {} {  
}  
  
 proc script::run {} {  
 if { $tmsh::argc != 3 } {  
 exit 123  
}  
 set zero [lindex $tmsh::argv 0]  
 set vcmpGuest [lindex $tmsh::argv 1]  
 set vlanName [lindex $tmsh::argv 2]  
 tmsh::modify vcmp guest $vcmpGuest vlans add "{ $vlanName }"  
 exit 0  
}  
  
 proc script::help {} {  
}  
 proc script::tabc {} {  
}  
}  

cli script /Common/delVlan {  
proc script::init {} {  
}  
  
 proc script::run {} {  
 if { $tmsh::argc != 3 } {  
 exit 123  
}  
 set zero  [lindex $tmsh::argv 0]  
 set vcmpGuest [lindex $tmsh::argv 1]  
 set vlanName [lindex $tmsh::argv 2]  
 tmsh::modify vcmp guest $vcmpGuest vlans delete "{ $vlanName }"  
 exit 0  
}  
 proc script::help {} {  
}  
}

Tested this on version:

12.1
Published Aug 13, 2019
Version 1.0
No CommentsBe the first to comment