def configEthernetNgpf(self, obj=None, port=None, portName=None, ngpfEndpointName=None, **kwargs): """ Description Create or modify NGPF Ethernet. To create a new Ethernet stack in NGPF, pass in the device group object. To modify an existing Ethernet stack in NGPF, pass in the Ethernet object. Parameters obj: : Device Group obj: '/api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/2' Ethernet obj: '/api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ethernet/1' name|ethernetName: : Ethernet name. macAddressMultivalueType: Default=counter. Options: alternate, custom, customDistributed, random, repeatableRandom, repeatableRandomRange, valueList To get the multivalue settings, refer to the API browser. macAddress: : By default, IxNetwork will generate unique Mac Addresses. {'start': '00:01:02:00:00:01', 'direction': 'increment', 'step': '00:00:00:00:00:01'} Note: step: '00:00:00:00:00:00' means don't increment. macAddressPortStep:: disable|00:00:00:01:00:00 Incrementing the Mac address on each port based on your input. '00:00:00:00:00:01' means to increment the last byte on each port. vlanId: : Example: {'start': 103, 'direction': 'increment', 'step': 1} vlanPriority: : Example: {'start': 2, 'direction': 'increment', 'step': 1} mtu: : Example: {'start': 1300, 'direction': 'increment', 'step': 1}) Syntax POST: /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet PATCH: /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id} Example: createEthernetNgpf(deviceGroupObj1, ethernetName='Eth1', macAddress={'start': '00:01:01:00:00:01', 'direction': 'increment', 'step': '00:00:00:00:00:01'}, macAddressPortStep='00:00:00:00:01:00', vlanId={'start': 128, 'direction': 'increment', 'step':0}, vlanPriority={'start': 7, 'direction': 'increment', 'step': 0}, mtu={'start': 1400, 'direction': 'increment', 'step': 0}, ) """ createNewEthernetObj = True # To create a new Ethernet object if obj != None: if 'ethernet' not in obj: url = self.ixnObj.httpHeader+obj + '/ethernet' self.ixnObj.logInfo('Create new Ethernet on NGPF') response = self.ixnObj.post(url) ethernetObj = response.json()['links'][0]['href'] # To modify if 'ethernet' in obj: ethernetObj = obj createNewEthernetObj = False # To modify if ngpfEndpointName: ethernetObj = self.getNgpfObjectHandleByName(ngpfEndpointName=ngpfEndpointName, ngpfEndpointObject='ethernet') createNewEthernetObj = False # To modify if port: x = self.getProtocolListByPortNgpf(port=port) ethernetObj = self.getProtocolObjFromProtocolList(x['deviceGroup'], 'ethernet')[0] createNewEthernetObj = False # To modify if portName: x = self.getProtocolListByPortNgpf(portName=portName) ethernetObj = self.getProtocolObjFromProtocolList(x['deviceGroup'], 'ethernet')[0] createNewEthernetObj = False ethObjResponse = self.ixnObj.get(self.ixnObj.httpHeader+ethernetObj) if 'ethernetName' in kwargs or 'name' in kwargs: if 'ethernetName' in kwargs: # This is to handle backward compatibility. This attribute should not be created. # Should be using 'name'. name = kwargs['ethernetName'] if 'name' in kwargs: name = kwargs['name'] self.ixnObj.logInfo('Configure MAC address name') self.ixnObj.patch(self.ixnObj.httpHeader+ethernetObj, data={'name': name}) if 'multiplier' in kwargs: self.configDeviceGroupMultiplier(objectHandle=ethernetObj, multiplier=kwargs['multiplier'], applyOnTheFly=False) if 'macAddress' in kwargs: multivalue = ethObjResponse.json()['mac'] self.ixnObj.logInfo('Configure MAC address. Attribute for multivalueId = jsonResponse["mac"]') # Default to counter multivalueType = 'counter' if 'macAddressMultivalueType' in kwargs: multivalueType = kwargs['macAddressMultivalueType'] if multivalueType == 'random': self.ixnObj.patch(self.ixnObj.httpHeader+multivalue, data={'pattern': 'random'}) else: self.configMultivalue(multivalue, multivalueType, data=kwargs['macAddress']) # Config Mac Address Port Step if 'macAddressPortStep' in kwargs: self.ixnObj.logInfo('Configure MAC address port step') portStepMultivalue = self.ixnObj.httpHeader + multivalue+'/nest/1' if 'macAddressPortStep' in kwargs: if kwargs['macAddressPortStep'] != 'disabled': self.ixnObj.patch(portStepMultivalue, data={'step': kwargs['macAddressPortStep']}) if kwargs['macAddressPortStep'] == 'disabled': self.ixnObj.patch(portStepMultivalue, data={'enabled': False}) if 'vlanId' in kwargs and kwargs['vlanId'] != None: # Enable VLAN if createNewEthernetObj == True: multivalue = ethObjResponse.json()['enableVlans'] self.ixnObj.logInfo('Enabling VLAN ID. Attribute for multivalueId = jsonResponse["enablevlans"]') self.configMultivalue(multivalue, 'singleValue', data={'value': True}) # CREATE vlan object (Creating vlanID always /vlan/1 and then do a get for 'vlanId') vlanIdObj = self.ixnObj.httpHeader+ethernetObj+'/vlan/1' vlanIdResponse = self.ixnObj.get(vlanIdObj) multivalue = vlanIdResponse.json()['vlanId'] # CONFIG VLAN ID self.ixnObj.logInfo('Configure VLAN ID. Attribute for multivalueId = jsonResponse["vlanId"]') self.configMultivalue(multivalue, 'counter', data=kwargs['vlanId']) # CONFIG VLAN PRIORITY if 'vlanPriority' in kwargs and kwargs['vlanPriority'] != None: multivalue = vlanIdResponse.json()['priority'] self.ixnObj.logInfo('Configure VLAN ID priority. Attribute for multivalue = jsonResponse["priority"]') self.configMultivalue(multivalue, 'counter', data=kwargs['vlanPriority']) if 'mtu' in kwargs and kwargs['mtu'] != None: multivalue = ethObjResponse.json()['mtu'] self.ixnObj.logInfo('Configure MTU. Attribute for multivalueId = jsonResponse["mtu"]') self.configMultivalue(multivalue, 'counter', data=kwargs['mtu']) return ethernetObj # Was configIsIsL3Ngpf