proc ReleasePorts {{portList None}} { # This Proc could either get all the configured ports dynamically or you # could pass in a list of ports. # # portList: The format is: [list "$ixChassisIp $cardNum $portNum" ...] # If user did not include $portList, then get ports from the loaded configuration. # WARNING: This will release ALL the ports that is connected to your chassis. if {$portList == "None"} { set configuredPorts [GetPortsAssignedToVports] set portList [lindex $configuredPorts 0] set vportList [lindex $configuredPorts 1] } if {$portList != "None"} { set vportList [GetVportMappingToPhyPort $portList] } if {$vportList == 0 || $vportList == ""} { return 0 } puts "releasePorts vportList: $vportList" foreach vport $vportList { # chassis="192.168.70.11" card="1" port="1" portip="192.168.70.12" set assignedTo [ixNet getAttribute $vport -assignedTo] set chassisIp [string map {\" ""} [lindex [split $assignedTo :] 0]] set cardId [string map {\" ""} [lindex [split $assignedTo :] 1]] set portId [string map {\" ""} [lindex [split $assignedTo :] 2]] if {[lsearch -regexp $portList "$chassisIp $cardId $portId"] != -1} { puts "ReleasePorts: $chassisIp/$cardId/$portId" if {[catch {ixNet exec releasePort $vport} errMsg]} { puts "\nError: ReleasePorts: $errMsg" return 1 } } } return 0 }