tmsh::include

Description

Runs the Tcl command eval on the specified script. The system evaluates the script at a global level, and all procedures in the included script are available to any other procedure. You must have previously created the script that is being included using the command edit cli script name. Version 11.0 and later does not recognize tmsh::include in the script::init section but does in script::run

Syntax

tmsh::include [script name]

Examples

### Script of procedures to be imported with tmsh::include in following script

cli script http_profiles.tcl {
proc create''http''profile { name } {
   # this would also contain other standard settings that the org/group
   # wants to use
   tmsh::create /ltm profile http $name ramcache disabled compress disabled
}

proc create_http_ramcache_profile { name } {
   # this would contain other standard ramcache settings that the org/group
   # wants to use
   tmsh::create /ltm profile http $name ramcache enabled
}

proc create_http_compression_profile { name } {
   # this would contain other standard ramcache settings that the org/group
   # wants to use
   tmsh::create /ltm profile http $name ramcache disabled compress enabled
}
}


### Script utilizing functions from http_profiles.tcl

proc script::run {} {

   # a library of proc's that create custom/pre-configured profiles
   tmsh::include http_profiles.tcl

   if {$tmsh::argc != 5} {
       puts "usage: <app name> <address:port> <server addr start> <server count>"
       exit
   }

   set app_name [lindex $tmsh::argv 1]
   set addr [lindex $tmsh::argv 2]
   set first_server [lindex $tmsh::argv 3]
   set server_count [lindex $tmsh::argv 4]

   tmsh::begin_transaction

   # create a pool and pool members for the app,
   # this block would be a candidate for being included from another script
   # like http_profiles.tcl was
   scan $first_server "%d.%d.%d.%d:%d" a b c d p
   set members ""
   for {set x 0} {$x < $server_count} {incr x} {
       set members "$members $a.$b.$c.$d:$p"
       incr d
       if { $d > 255 } {
           set d 0
           incr c
           if { $c > 255 } {
               set c 0
               incr b
               if { $b > 255 } {
                   set b 0
                   incr a
               }
           }
       }
   }
   tmsh::create /ltm pool $app_name members replace-all-with "{ $members }"

   # this proc is in http_profiles.tcl
   create_http_profile $app_name

   tmsh::create /ltm virtual $app_name \
       destination $addr \
       pool $app_name \
       profiles replace-all-with "{ $app_name }"

   # all updates in the script are commited at this point, if any of the
   # updates fails to validate, all updates are rolled back
   tmsh::commit_transaction
}

}