Forum Discussion
JRahm
Jan 27, 2011Admin
Object not displaying all fields
I'm using a proc from the wiki that prints fields:
proc print_fields { objVar } {
upvar $objVar obj
set fdx 0
set fields [tmsh::get_field_names value $obj]
set field_count [llength $fields]
while { $fdx < $field_count } {
set field [lindex $fields $fdx]
puts "$field [tmsh::get_field_value $obj $field]"
incr fdx
}
}
proc script::run {} {
foreach vip [tmsh::get_config /ltm virtual] {
puts [tmsh::get_name $vip]
print_fields vip
puts "\n"
}
}
When I run the script, I notice that not all my fields are present. For example, this vip when listed in tmsh:
root@golgotha(Active)(tmos) list ltm virtual cacti-vip
ltm virtual cacti-vip {
connection-limit 1500
destination 10.10.20.50:http
ip-protocol tcp
mask 255.255.255.255
pool testpooln
profiles {
http { }
tcp { }
}
rules {
table_mgmt
hashtest_distribution
}
snat automap
translate-port disabled
}
Shows all the fields except the profiles:
root@golgotha(Active)(tmos) run cli script parttest.tcl
cacti-vip
connection-limit 1500
destination 10.10.20.50:http
ip-protocol tcp
mask 255.255.255.255
pool testpooln
rules table_mgmt hashtest_distribution
snat automap
translate-port disabled
Is there another process I need to follow for the profiles? Each of those objects looks to have its own {}, is that maybe throwing it off?
- Mark_Crosland_2Historic F5 AccountIn the man page, help cli script, it talks about value fields and nested fields. Value fields are simple values or lists. A nested field (the missing profile list) can be used to retrieve nested objects. Nested objects also have fields, in this case the virtual/profile objects have a context field (clientside or serverside). Depending on the type of configuration, a nested object may also contain nested objects.
- JRahmAdminyeah, uh, RTFM has never been my strong suit. Sigh. Thanks Mark!
- Mark_Crosland_2Historic F5 AccountAs a general rule, a man page can also be used to figure out which fields contain/represent nested objects in the scripting interface. Any field that is a list (i.e., has operations like add, delete, replace-all-with, none, ....) and has properties is a nested object. Using "help ltm virtual" as an example, the profiles field is a list of profiles that also has a context property, so profiles are presented as nested objects in the scripting interface. Whereas the the vlans setting is a list of vlan names, but there are no configurable properties, so it is a simple list, and not a nested object.
- hooleylistCirrostratusThat's really useful info Mark. I was struggling through this last week. Thanks for the tips.
- JRahmAdminVery good information, helped me a request this morning putting wideIP info into csv format:
proc script::run {} { foreach wip [tmsh::get_config \gtm wideip] { append csvline "[tmsh::get_name $wip]," foreach pl [tmsh::get_field_value $wip pools] { append csvline "[tmsh::get_name $pl]," foreach pm [tmsh::get_config \gtm pool] { if { [tmsh::get_name $pl] == [tmsh::get_name $pm] } { foreach fld [tmsh::get_field_value $pm members] { append csvline "[tmsh::get_name $fld]," } } } } puts "$csvline" unset csvline } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects