proc GetProtocolIntObjects { args } { # This API supports single chassis ports and diasy chained chassis ports. # # This API will return you all the Protocol Interface objects # based on the $port and/or $vlanId # # -port format = 1/1/3 or $ixiaChassisIp/1/3 # -You could pass in a list of ports also: # "1/1/1 1/1/2" or "$ixiaChassisIp/1/1 $ixiaChassisIp/1/2" # For a single chassis, port format can be 1/1/1 or $ixiaChassisIp/1/1 # For a daisy chained chassis, port format must be $ixiaChassisIp1/1 # For -vlanId parameter: # Currently, you can only pass in one vlan ID for a single port or for # the list of ports. set argIndex 0 while {$argIndex < [llength $args]} { set currentArg [lindex $args $argIndex] switch -exact -- $currentArg { -port { # For a single chassis, port format can be 1/1/1 or $ixiaChassisIp/1/1 # For a daisy chained chassis, port format must be $ixiaChassisIp/1/1 set port [lindex $args [expr $argIndex + 1]] set portList {} foreach p $port { set port [join [lrange [split $p /] 1 end] /] lappend portList $port } incr argIndex 2 } -vlanId { set vlanId [lindex $args [expr $argIndex + 1]] incr argIndex 2 } default { puts "\nError GetProtocolIntObjects: No such parameter: $currentArg" return 1 } } } set interfaceObjList {} foreach vport [ixNet getList [ixNet getRoot] vport] { set currentPort [ixNet getAttribute $vport -assignedTo] set chassis [lindex [split $currentPort :] 0] set card [lindex [split $currentPort :] 1] set portNumber [lindex [split $currentPort :] 2] if {[lsearch $portList "$card/$portNumber"] != -1 || [lsearch $portList "$chassis/$card/$portNumber"] != -1} { # Get all the interface objects for the current $card/$portNumber. # Because a port can have a large scale of interfaces. foreach interface [ixNet getList $vport interface] { if {[info exists vlanId] == 0} { lappend interfaceObjList $interface } # User can bind a vlanID to a port. if {[info exists vlanId] == 1} { set currentVlanId [ixNet getAttribute $interface/vlan -vlanId] if {$vlanId == $currentVlanId} { lappend interfaceObjList $interface } } } } } if {$interfaceObjList != ""} { return $interfaceObjList } else { return 0 } }