proc CreateTrafficItem {args} { # raw, ipv4, ipv6, ethernetVlan set paramList {} set argIndex 0 while {$argIndex < [llength $args]} { set currentArg [lindex $args $argIndex] puts "currentArg: $currentArg" switch -exact -- $currentArg { -name { set name [lindex $args [expr $argIndex + 1]] append paramList " -name $name" incr argIndex 2 } -trafficType { set trafficType [lindex $args [expr $argIndex + 1]] append paramList " -trafficType $trafficType" incr argIndex 2 } -trafficItemType { set trafficItemType [lindex $args [expr $argIndex + 1]] append paramList " -trafficItemType $trafficItemType" incr argIndex 2 } # true|false -biDirection { set biDirection [lindex $args [expr $argIndex + 1]] append paramList " -biDirectional $biDirection" incr argIndex 2 } -trackBy { set trackBy [lindex $args [expr $argIndex + 1]] incr argIndex 2 } -srcEndpoint { set srcEndpoint [lindex $args [expr $argIndex + 1]] append paramList " -srcEndpoint $srcEndpoint" incr argIndex 2 } -dstEndpoint { set dstEndpoint [lindex $args [expr $argIndex + 1]] append paramList " -dstEndpoint $dstEndpoint" incr argIndex 2 } default { puts "Connect: No such parameter: $currentArg" return 1 } } } puts "\nCreateTrafficItem: $paramList" set trafficItemObj [ixNet add [ixNet getRoot]/traffic trafficItem] ixNet commit if {[catch {eval ixNet setMultiAttribute $trafficItemObj $paramList} errMsg]} { puts "Error: CreateTrafficItem: $errMsg" return 1 } ixNet commit # Must set trafficType after creating a new Traffic Item or else it will default to raw. ixNet setAttribute $trafficItemObj -trafficType $trafficType ixNet commit set trafficItemObj [lindex [ixNet remapIds $trafficItemObj] 0] if {[info exists trackBy]} { puts "Configuring tracking: $trackBy" if {[catch {ixNet setMultiAttribute $trafficItemObj/tracking -trackBy $trackBy} errMsg]} { puts "\nError CreateTrafficItem: $errMsg" } ixNet commit } return $trafficItemObj }