Dynamic Routing Configuration via iControl REST (IMISH configuration via cli script)

Problem this snippet solves:

If you want to configure IMISH via iControl, this can be done via cli script.

How to use this snippet:

First, you need to enable the desired routing protocol via iControl REST. This can be accomplished by modifying the /mgmt/tm/net/route-domain/~Common~yourroutedomain object natively. Once enabled, you cannot speak directly to IMISH (as of 13.0 HF2), but you can create a cli script and pass variables to it, then write that to a temporary file and have IMISH suck it in.


You can call this script and pass arguments via iControl REST.

 

Example call:

curl -sk -H 'content-type: application/json' -u myuser:mypass https://192.168.0.3/mgmt/tm/cli/script -d '{"command":"run","name":"bgp_configuration","utilCmdArgs":"1.11.1.1 65117"}'  


Code :

cli script bgp_configuration {  
proc script::init {} {  
}  
  
proc script::run {} {  
    set neighboraddr [lindex $tmsh::argv 1]  
    set asnumber [lindex $tmsh::argv 2]  
    set imishscript [open "/var/tmp/imish_script.tmp" "w"]  
    puts $imishscript "enable"  
    puts $imishscript "configure terminal"  
    puts $imishscript "router bgp $asnumber"  
    puts $imishscript "neighbor $neighboraddr remote-as $asnumber"  
    puts $imishscript "neighbor $neighboraddr activate"  
    puts $imishscript "neighbor $neighboraddr soft-reconfiguration inbound"  
    puts $imishscript "neighbor $neighboraddr timers 10 30"  
    puts $imishscript "neighbor $neighboraddr timers connect 10"  
    puts $imishscript "end"  
    puts $imishscript "write mem"  
    close $imishscript  
    exec imish -f /var/tmp/imish_script.tmp  
}  
  
proc script::help {} {  
}  
  
proc script::tabc {} {  
}  
    total-signing-status not-all-signed  
}

Tested this on version:

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