Forum Discussion

Alscion_68122's avatar
Alscion_68122
Icon for Nimbostratus rankNimbostratus
Mar 11, 2011

Can't use variable for vlan selection during route domain creation?

Hello World,

 

 

I have to create several route demain and associate 2 vlans per route domain with tmsh script.

 

 

 

- I try it making a for loop for my total number of route domain to create.

 

- I select the right partition (successfully created previously)

 

- I create my route-domain and want to select a vlan previously created. My vlans are incremented and their name contain a number. I want to be able to use this incrementation to select my vlans for route-domain creation. BUT, it seems to be impossible to use variable in vlan name, I have the following message error :

 

 

 

pipo.tcl: script failed to complete:

 

can't eval proc: "script::run"

 

"vsys$x-vlan" unexpected argument

 

while executing

 

"tmsh::create net route-domain $numrd vlans add { vsys$x-vlan }"

 

(procedure "script::run" line 42)

 

invoked from within

 

"script::run" line:1

 

script did not successfully complete, status:1

 

 

 

 

 

 

- Here is an extract of my script :

 

 

 

set usercount 10

 

set numrd 12

 

for {set x 1} {$x<=$usercount} {incr x} {

 

tmsh::modify cli admin-partitions query-partitions all update-partition fce-vsys$x

 

tmsh::create net route-domain $numrd vlans add { vsys$x-vlan }

 

incr numrd

 

}

 

}

 

tmsh::modify cli admin-partitions query-partitions all update-partition Common

 

 

 

 

- I tried without {}, no success. Somebody have an Idea?

 

 

 

Thanks!

 

 

 

 

 

3 Replies

  • Hi NQ,

     

     

    Can you try replacing escaping the hyphen in x-vlan like this:

     

     

    ${x-vlan}

     

     

    Aaron
  • Mark_Crosland_2's avatar
    Mark_Crosland_2
    Historic F5 Account
    Another issue is that {}'s are special characters in both tmsh and Tcl, so they must be escaped in Tcl so that Tcl doesn't swallow them.

     

     

    tmsh::stateless enabled

     

    set ip-value "10.1.1.2:80"

     

    tmsh::create ltm pool foo members add "{ ${ip-value} }"

     

    or

     

    tmsh::create ltm pool foo members add \{ ${ip-value} \}

     

     

     

  • Hi Mark & hoolio,

     

     

    Thanks for your help, here is the solution i use : vlans add "{ vsys${x}-vlan }"

     

     

    I put all the expression between double quote and i use bracket for the variable, example for several vlan to add :

     

     

    vlans add "{ vsys${x}-vlan vsys${y}-vlan }"

     

     

    Have fun.