def enableConfiguredStats(self, configuredStats, statNameList): ''' Notes: Filter queries .../configuredStats will re-enable all stats .../configuredStats/15 will only enable the stat with object id = 15 .../configuredStats?filter="objectID le 10" will only enable stats with object id s lower or equal to 10 .../configuredStats?filter="caption eq FTP" will only enable stats that contain FTP in their caption name ''' for eachStatName in statNameList: configuredStats = configuredStats + '?filter="caption eq %s"' % eachStatName self.logInfo('\nEnableConfiguredStats: %s' % configuredStats) response = self.patch(configuredStats, data={"enabled": True}) ortList1 = { 'chassisIp': '192.168.70.128', 'Traffic1@Network1': [(1,1)] } communityPortList2 = { 'chassisIp': '192.168.70.129', 'Traffic2@Network2': [(1,1), } restObj.assignChassisAndPorts([communityPortList1, communityPortList2]) """ if type(communityPortListDict) == dict: # Make this updated API backward compatible by passing in one dict versus a list. communityPortListDict = [communityPortListDict] for communityPorts in communityPortListDict: # Assign Chassis chassisIp = communityPorts['chassisIp'] newChassisId, locationUrl = self. addNewChassis(chassisIp) self.logInfo('assignChassisAndPorts: To new chassis: %s' % locationUrl, timestamp=False) # Assign Ports communityListUrl = self.sessionIdUrl+'/ixLoad/test/activeTest/communityList/' communityList = self.get(communityListUrl) self.refreshConnection(locationUrl=locationUrl) self.waitForChassisIpToConnect(locationUrl=locationUrl) failedToAddList = [] communityNameNotFoundList = [] for eachCommunity in communityList.json(): currentCommunityObjectId = str(eachCommunity['objectID']) currentCommunityName = eachCommunity['name'] if currentCommunityName not in communityPorts: continue if communityNameNotFoundList == []: for eachTuplePort in communityPorts[currentCommunityName]: # Going to ignore user input chassisId. When calling addNewChassis(), # it will verify for chassisIp exists. If exists, it will return the # right chassisID. cardId,portId = eachTuplePort params = {"chassisId":int(newChassisId), "cardId":cardId, "portId":portId} url = communityListUrl+str(currentCommunityObjectId)+'/network/portList' self.logInfo('assignChassisAndPorts URL: %s' % url, timestamp=False) self.logInfo('assignChassisAndPorts Params: %s' % json.dumps(params), timestamp=False) response = self.post(url, data=params, ignoreError=True) if response.status_code != 201: portAlreadyConnectedMatch = re.search('.*has already been assigned.*', response.json()['error']) if portAlreadyConnectedMatch: self.logInfo('%s/%s is already assigned' % (cardId,portId), timestamp=False) else: failedToAddList.append((newChassisId,cardId,portId)) self.logInfo('\nassignChassisAndPorts failed: %s' % response.text) if communityNameNotFoundList != []: raise IxLoadRestApiException if failedToAddList != []: if self.deleteSession: self.abortActiveTest() raise IxLoadRestApiException('Failed to add ports to chassisIp %s: %s:' % (chassisIp, failedToAddList))