Forum Discussion

Sean_Ellis_9378's avatar
Sean_Ellis_9378
Icon for Nimbostratus rankNimbostratus
Sep 26, 2012

Dumping contents of a class

I have a few classes which I need to retrieve from some BIG-IP systems. I would like to do this via curl, so I set up a virtual service on each and applied an iRule. Here is the TCL I was testing with, which crashed and restarted TMM on the first BIG-IP I tested with. Anyone see the error or know of a way to do this? Thanks in advance!

 

 


when HTTP_REQUEST {
  set testVersion "8"
  set testResponse "Virtual Service Testing - move along"

   other code snippets removed

  if { $testVersion == 8 } {
    set testResponse ".html..head..title.Dump Class./title../head..body..pre.(newline)"
    set tv1db "rdDB"
    if {[class exists $tv1db]} {
      set tv1dbElement [class startsearch $tv1db]
      while {[class anymore $tv1db $tv1dbElement]} {
        append testResponse [class nextelement $tv1db $tv1dbElement]
        append testResponse "(newline)"
      }
    }
    append testResponse "./pre../body../html."
    class donesearch $tv1db $tv1dbElement
  }

  HTTP::respond 200 content $testResponse "Content-Type" "text/plain" "pragma" "no-cache"
  TCP::close
}

 

  • Not sure about the error, but there's probably a simpler way to get class values using the 'class get' command:

    
    when HTTP_REQUEST {
    set tv1db "rdDB"
    if { [class exists $tv1db] } {
    set testResponse "\n"
    foreach x [class get $tv1db] {
    append testResponse $x "\n"
    }
    HTTP::respond 200 content $testResponse "Content-Type" "text/html" "pragma" "no-cache" "Connection" "Close"
    }
    }
    

    Your HTTP::respond command is also outside of your conditions, so it's possible that testResponse may may not exist in some scenarios.