proc Connect {args} { # osPlatform: The Ixia chassis OS. windows|linux. Defaults to windows # apiServerIp: The IxNetwork API server # sessionId: The Linux API server session ID to connect to. This is for connecting to an existing session. # ixNetworkVersion: The IxNetwork version # username: Linux API server. login. Defaults = admin # password: Linux API server login passwoed. Default = admin # apiKey: Linux API server user login account API-key. # The Proc will automatically get the API-key when login is authenticated. # Optionally, you could pass it in. # closeServerOnDisconnect: 0|1 # # Examples: # To connect to an existing Linux API server session: # Connect -apiServerIp 192.168.70.12 -port 443 -ixNetworkVersion 8.50 -sessionId 1 -apiKey $apiKey -closeServerOnDisconnect 0 # Set the Linux API server admin login default credentials set username None set password None set apiKey None set sessionId None set osPlatform windows set argIndex 0 while {$argIndex < [llength $args]} { set currentArg [lindex $args $argIndex] switch -exact -- $currentArg { -osPlatform { set osPlatform [lindex $args [expr $argIndex + 1]] incr argIndex 2 } -apiServerIp { set apiServerIp [lindex $args [expr $argIndex + 1]] incr argIndex 2 append paramList " $apiServerIp" } -port { set port [lindex $args [expr $argIndex + 1]] incr argIndex 2 append paramList " -port $port" } -ixNetworkVersion { set ixNetworkVersion [lindex $args [expr $argIndex + 1]] incr argIndex 2 append paramList " -version $ixNetworkVersion" } -apiKey { set apiKey [lindex $args [expr $argIndex + 1]] incr argIndex 2 append paramList " -apiKey $apiKey" } -sessionId { set sessionId [lindex $args [expr $argIndex + 1]] incr argIndex 2 append paramList " -sessionId $sessionId" } -username { set username [lindex $args [expr $argIndex + 1]] incr argIndex 2 append paramList " -username $username" } -password { set password [lindex $args [expr $argIndex + 1]] incr argIndex 2 append paramList " -username $password" } -closeServerOnDisconnect { set closeServerOnDisconnect [lindex $args [expr $argIndex + 1]] append paramList " -closeServerOnDisconnect $closeServerOnDisconnect" incr argIndex 2 } default { puts "Connect: No such parameter: $currentArg" return 1 } } } # For Linux API server login to get the API key if {$osPlatform == "linux"} { if {$apiKey == "None"} { set apiKey [GetApiKey $apiServerIp $username $password] if {$apiKey == 1} { return 1 } append paramList " -apiKey $apiKey" } } append paramList " -setAttribute strict" puts "\nConnecting to API server: $apiServerIp" if {[catch {set connectStatus [eval ixNet connect $paramList]} errMsg]} { puts "\nConnect failed: $errMsg" return 1 } puts "\nConnectStatus: $connectStatus" return 0 }