def assignPorts(self, communityPortListDict): ''' Usage: chassisId = Pass in the chassis ID. If you reassign chassis ID, you must pass in the new chassis ID number. communityPortListDict should be passed in as a dictionary with Community Names mapping to ports in a tuplie list. communityPortListDict = { 'Traffic0@CltNetwork_0': [(chassisId,1,1)], 'SvrTraffic0@SvrNetwork_0': [(chassisId,2,1)] } ''' communityListUrl = self.sessionIdUrl+'/ixLoad/test/activeTest/communityList/' communityList = self.get(communityListUrl) failedToAddList = [] communityNameNotFoundList = [] for eachCommunity in communityList.json(): # eachCommunity are client side or server side currentCommunityObjectId = str(eachCommunity['objectID']) currentCommunityName = eachCommunity['name'] if currentCommunityName not in communityPortListDict: self.logInfo('\nNo such community name found: %s' % currentCommunityName) self.logInfo('\tYour stated communityPortList are: %s' % communityPortListDict, timestamp=False) communityNameNotFoundList.append(currentCommunityName) return 1 for eachTuplePort in communityPortListDict[currentCommunityName]: chassisId,cardId,portId = eachTuplePort params = {'chassisId':chassisId, 'cardId':cardId, 'portId':portId} self.logInfo('\nAssignPorts: {0}: {1}'.format(eachTuplePort, params)) url = communityListUrl+str(currentCommunityObjectId)+'/network/portList' response = self.post(url, data=params, ignoreError=True) if response.status_code != 201: failedToAddList.append((chassisId,cardId,portId)) if failedToAddList == []: return 0 else: raise IxLoadRestApiException('Failed to add ports:', failedToAddList)