Forum Discussion

rob_carr_76748's avatar
rob_carr_76748
Icon for Nimbostratus rankNimbostratus
Aug 21, 2013

Need help with generating dynamic list in iApp proc

I'm a trainer, and some of the F5 training offerings now come with iApps to standardize the student environment, for those classes that aren't specifically about how to configure the F5. As such, the iApp asks the student to choose their 'pod number', where a pod is just an environment containing virtual workstations, F5 equipment and origin servers. In the iApp iterations being published as of now, the list of possible pods is statically set, and as such, may not work for all ATC's. See the fragment below:

 

  PROC_MGMT_IP3
  What is the 3rd octet from the mgmt ip address?
 proc proc_mgmt_ip3 {}
 {
  set mgmt_string [tmsh::list "sys management-ip"]
  set mgmt1 [split $mgmt_string "."]
  set mgmt_ip [lindex $mgmt1 2]

  set station_list [ format "%s \n 1 \n 2 \n 3 \n 4 \n 5 \n 6 \n 7 \n 8 \n 9 \n 10 \n 11 \n 12 \n 13 \n 14 \n 15 \n 16 \n 17" $mgmt_ip ]

  return $station_list
 }

Instead of having to edit that static list for however many pods there are in a particular ATC's setup, I want to dynamically generate the list based on a max_pod value, which will still requiring editing if you have a very large setup, but at least isn't as cumbersome as the static list above. Here's the best I've been able to accomplish:

 

  PROC_MGMT_IP3
  What is the 3rd octet from the mgmt ip address?
 proc proc_mgmt_ip3 {} 
 {
  set mgmt_string [tmsh::list "sys management-ip"]
  set mgmt1 [split $mgmt_string "."]
  set mgmt_ip [lindex $mgmt1 2]
   set max_pod to the highest number pod in use in your environment (default is 17)
   no pod 17 in pod_list, since 17 is used as the instructor pod
  set max_pod 31
  set pod_list " "
  for { set i 0 } { $i < $max_pod } { incr i } {
        if { $i == 17 } {
                continue
        }
        append $pod_list "\n" $i " "
  }   

  set station_list [ format "%s %s" $mgmt_ip $pod_list ]
  return $station_list
 }

It doesn't error out, it doesn't keep the student from creating an Application Service, but it also doesn't work. If you were to try and create an application service with my code, instead of seeing a list which starts with the value derived from the managment IP address and then followed by an arbitrary number of pods from 1 to max_pod, you only see the value derived from the management IP address.

 

Clearly, I have missed something.

 

2 Replies

  • Your append statement should look like this:

     

    append pod_list "\n$i "

     

  • You can test in the tclsh shell on the BIG-IP:

    % for { set i 0 } { $i < $max_pod } { incr i } {
      if { $i == 17 } { continue }
      append pod_list "\n$i "
    }
    % puts $pod_list
    
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30