def EnableTrafficItemByName( trafficItemNameList, condition='True' ): # condition: True or False for trafficItemName in trafficItemNameList: flag = 0 for eachTrafficItem in ixNet.getList(ixNet.getRoot()+'traffic', 'trafficItem'): currentTrafficItemName = ixNet.getAttribute(eachTrafficItem, '-name') if trafficItemName == currentTrafficItemName: try: print '\nEnableTrafficItemByName:', trafficItemName ixNet.setAttribute(eachTrafficItem, '-enabled', condition) ixNet.commit() flag = 1 except Exception, errMsg: print '\nEnableTrafficItemByName Error:', errMsg return 1 if flag == 0: print '\nEnableTrafficItemByName Error: No Traffic Item name found on configuration:', trafficItemName sys.exit()