def VerifyPortState( stopTime = 40 ): # Search for all the created vports and get its state. for vPort in ixNet.getList(ixNet.getRoot(), 'vport'): # [u'::ixNet::OBJ-', u'availableHardware', u'chassis:"10.219.117.101"', u'card:1', u'port:1'] connectedTo = ixNet.getAttribute(vPort, '-connectedTo') card = connectedTo.split('/')[3].split(':')[1] portNum = connectedTo.split('/')[4].split(':')[1] port = card+'/'+portNum for timer in range(0, stopTime): timer = timer + 1 portState = ixNet.getAttribute(vPort, '-state') if portState == 'up': print 'VerifyPortState: ', port + ' is up' break if portState != 'up': print 'VerifyPortState: %s is not up yet. Verifying %d/%d seconds' % (port, timer, stopTime) time.sleep(1) if timer == stopTime: print 'Port can\'t come up. Exiting test' return 1 return 0