def IxVmRemovePortIdPy(ixNet, vmCardId, vmPortId): # This API will remove the specified vmCardId/vmPortId # ixNet = object # Example: ixNet = IxNetwork.IxNet() & ixNet.connect(apiServer) import re availableHardware = ixNet.getList(ixNet.getRoot(), 'availableHardware')[0] vChassisObj = ixNet.getList(availableHardware, 'virtualChassis')[0] vmCardList = ixNet.getList(vChassisObj, 'ixVmCard') for eachVmCardId in vmCardList: # '::ixNet::OBJ-/availableHardware/virtualChassis/ixVmCard:"Card1"' currentCardIdMatch = re.match('::ixNet.*ixVmCard.*Card([0-9]+)', eachVmCardId) if currentCardIdMatch: if int(currentCardIdMatch.group(1)) == vmCardId: vmPortIdList = ixNet.getList(eachVmCardId, 'ixVmPort') for eachVmPortId in vmPortIdList: currentPortIdMatch = re.match('::ixNet.*ixVmPort.*Port([0-9]+)', eachVmPortId) if int(currentPortIdMatch.group(1)) == vmPortId: print '\nremoveCardIdPortId: Removing:', eachVmPortId ixNet.remove(eachVmPortId) ixNet.commit() return 0 return 1