def configConfigElements(self, configElementObj, configElements): """ Description Configure Traffic Item Config Elements. This function will collect all the ReST API's attributes and execute a PATCH in one single command instead of sending a a PATCH for each attribute. This avoids dependency breakage because some APIs require the type to be configured first. This function also handles high level stream configurations since the attributes are the same. Pass in the highLevelStream obj for the parameter configElementObj Parameters configElementObj: : The config element object: Ex: /api/v1/sessions/{1}/ixnetwork/traffic/trafficItem/{1}/configElement/{1} highLevelStream obj Ex: /api/v1/sessions/{1}/ixnetwork/traffic/trafficItem/{1}/highLevelStream/{1} configElements: : This could also be highLevelStream elements. configElements = {'transmissionType': 'fixedFrameCount', 'frameCount': 50000, 'frameRate': 88, 'frameRateType': 'percentLineRate', 'frameSize': 128, 'portDistribution': 'applyRateToAll', 'streamDistribution': 'splitRateEvenly' } transmissionType: fixedFrameCount|continuous|fixedDuration incrementFrom: For frameSizeType = random. Frame size from size. incrementTo: For frameSizeType = random. Frame size to size. frameRateType: bitsPerSecond|percentLineRate|framesPerSecond frameRateBitRateUnitsType: bitsPerSec|bytesPerSec|kbitsPerSec|kbytesPerSec|mbitsPerSec|mbytesPerSec portDistribution: applyRateToAll|splitRateEvenly. Default=applyRateToAll streamDistribution: splitRateEvenly|applyRateToAll. Default=splitRateEvently """ transmissionControlData = {} frameRateData = {} frameRateDistribution = {} for item in configElements.keys() : # These attributes are int type if item in ['burstPacketCount', 'duration', 'frameCount', 'interBurstGap', 'interStreamGap', 'iterationCount', 'minGapBytes', 'repeatBurst', 'startDelay']: transmissionControlData.update({item: int(configElements[item])}) if item in ['enableInterBurstGap', 'enableInterStreamGap','interBurstGapUnits', 'startDelayUnits', 'type']: transmissionControlData.update({item: str(configElements[item])}) if item == 'frameRateType': frameRateData.update({'type': str(configElements[item])}) if item == 'frameRate': frameRateData.update({'rate': float(configElements[item])}) if item == 'frameRateBitRateUnitsType': frameRateData.update({'bitRateUnitsType': str(configElements[item])}) if item == 'portDistribution': frameRateDistribution.update({'portDistribution': configElements[item]}) if item == 'streamDistribution': frameRateDistribution.update({'streamDistribution': configElements[item]}) # Note: transmissionType is not an attribute in configElement. It is created to be more descriptive than 'type'. if 'transmissionType' in configElements: self.ixnObj.patch(configElementObj+'/transmissionControl', data={'type': configElements['transmissionType']}) if transmissionControlData != {}: self.ixnObj.patch(configElementObj+'/transmissionControl', data=transmissionControlData) if frameRateData != {}: self.ixnObj.patch(configElementObj+'/frameRate', data=frameRateData) if 'frameSize' in configElements: self.ixnObj.patch(configElementObj+'/frameSize', data={'fixedSize': int(configElements['frameSize'])}) if 'frameSizeType' in configElements: self.ixnObj.patch(configElementObj+'/frameSize', data={'type': configElements['frameSizeType']}) if configElements['frameSizeType'] == 'random': self.ixnObj.patch(configElementObj+'/frameSize', data={'incrementFrom': configElements['incrementFrom'], 'incrementTo': configElements['incrementTo']}) if frameRateDistribution != {}: self.ixnObj.patch(configElementObj+'/frameRateDistribution', data=frameRateDistribution)