Printer FriendlyEmail Article Link

Spirent TestCenter-API:How to retrieve the Bound Streamblock handles based on the protocols configured.

Environment/Versions
  • Spirent TestCenter
  • Automation-API
  • PGA
Answer

Below is the sample code to retrieve the Bound Streamblock handles based on the protocols (below code will check for BGP,OSPFv3,OSPF )configured.

proc protocol {deviceh } {
 
puts "*******procedure started***********"
 
set handles ""
 
foreach device $deviceh {
 
puts "********checking for BGP*****************"
 
set status [stc::get $device -children-BgpRouterConfig]
 
puts "$status"
 
if {[regexp -nocase $status matchresult]} {
 
    puts "Routerconfig Handle are :$status"
 
lappend handles "," $status
 
} else {
 
    puts "Bgp Not configured"
 
    puts "$device"
 
}
 
puts "********checking for ospfv2*****************"
 
set status2 [stc::get $device -children-ospfv2routerconfig]
 
puts "$status2"
 
 
 
if {[regexp -nocase $status2 matchresult]} {
 
puts "OSPfv2 RouterConfig Handle are :$status2"
 
lappend handles "," $status2
 
} else {
 
puts "ospfv2 not configured"
 
puts "$device"
 
}
 
puts "********checking for OSPFv3*****************"
 
set status3 [stc::get $device -children-ospfv3routerconfig]
 
puts "$status3"
 
if {[regexp -nocase $status3 matchresult]} {
 
puts "OSPfv3 RouterConfig Handle are :$status3"
 
lappend handles "," $status3
 
} else {
 
puts "ospfv3 not configured"
 
puts "$device"
 
}
 
}
 
return $handles
 
}
 
Code:
 
package require SpirentTestCenter
 
stc::perform loadfromxml -filename "SAMPLE.xml"
 
set device ""
 
set ports [stc::get project1 -children-port]
 
puts "Ports handle are $ports"
 
set i 0
 
set ports_h [split $ports " "]
 
set handles1 [protocol $deviceh1]
 
puts "handles are $handles1"


Product : Spirent TestCenter,Automation,API,Spirent TestCenter,PGA