def configIpv4Ngpf(self, obj=None, port=None, portName=None, ngpfEndpointName=None, **kwargs): """ Description Create or modify NGPF IPv4. To create a new IPv4 stack in NGPF, pass in the Ethernet object. If modifying, there are four options. 2-4 will query for the IP object handle. 1> Provide the IPv4 object handle using the obj parameter. 2> Set port: The physical port. 3> Set portName: The vport port name. 4> Set NGPF IP name that you configured. Parameters obj: : None or Ethernet obj: '/api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ethernet/1' IPv4 obj: '/api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ethernet/1/ipv4/1' port: : Format: [ixChassisIp, str(cardNumber), str(portNumber)] portName: : The virtual port name. ngpfEndpointName: : The name that you configured for the NGPF IPv4 endpoint. kwargs: ipv4AddressMultivalueType & gatewayMultivalueType: Default='counter'. Options: alternate, custom, customDistributed, random, repeatableRandom, repeatableRandomRange, valueList To get the multivalue settings, refer to the API browser. ipv4Address: : {'start': '100.1.1.100', 'direction': 'increment', 'step': '0.0.0.1'}, ipv4AddressPortStep: |: disable|0.0.0.1 Incrementing the IP address on each port based on your input. 0.0.0.1 means to increment the last octet on each port. gateway: : {'start': '100.1.1.1', 'direction': 'increment', 'step': '0.0.0.1'}, gatewayPortStep: |: disable|0.0.0.1 Incrementing the IP address on each port based on your input. 0.0.0.1 means to increment the last octet on each port. prefix: : Example: 24 rsolveGateway: Syntax POST: /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id}/ipv4 PATCH: /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id}/ipv4/{id} Example to create a new IPv4 object: ipv4Obj1 = createIpv4Ngpf(ethernetObj1, ipv4Address={'start': '100.1.1.1', 'direction': 'increment', 'step': '0.0.0.1'}, ipv4AddressPortStep='disabled', gateway={'start': '100.1.1.100', 'direction': 'increment', 'step': '0.0.0.0'}, gatewayPortStep='disabled', prefix=24, resolveGateway=True) Return /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id}/ipv4/{id} """ createNewIpv4Obj = True if obj != None: if 'ipv4' in obj: # To modify IPv4 ipv4Obj = obj createNewIpv4Obj = False else: # To create a new IPv4 object ipv4Url = self.ixnObj.httpHeader+obj+'/ipv4' self.ixnObj.logInfo('Creating new IPv4 in NGPF') response = self.ixnObj.post(ipv4Url) ipv4Obj = response.json()['links'][0]['href'] # To modify if ngpfEndpointName: ipv4Obj = self.getNgpfObjectHandleByName(ngpfEndpointName=ngpfEndpointName, ngpfEndpointObject='ipv4') createNewIpv4Obj = False # To modify if port: x = self.getProtocolListByPortNgpf(port=port) ipv4Obj = self.getProtocolObjFromProtocolList(x['deviceGroup'], 'ipv4')[0] createNewIpv4Obj = False # To modify if portName: x = self.getProtocolListByPortNgpf(portName=portName) ipv4Obj = self.getProtocolObjFromProtocolList(x['deviceGroup'], 'ipv4')[0] createNewIpv4Obj = False ipv4Response = self.ixnObj.get(self.ixnObj.httpHeader+ipv4Obj) if 'name' in kwargs: self.ixnObj.patch(self.ixnObj.httpHeader+ipv4Obj, data={'name': kwargs['name']}) if 'multiplier' in kwargs: self.configDeviceGroupMultiplier(objectHandle=ipv4Obj, multiplier=kwargs['multiplier'], applyOnTheFly=False) # Config IPv4 address if 'ipv4Address' in kwargs: multivalue = ipv4Response.json()['address'] self.ixnObj.logInfo('Configuring IPv4 address. Attribute for multivalueId = jsonResponse["address"]') # Default to counter multivalueType = 'counter' if 'ipv4AddressMultivalueType' in kwargs: multivalueType = kwargs['ipv4AddressMultivalueType'] if multivalueType == 'random': self.ixnObj.patch(self.ixnObj.httpHeader+multivalue, data={'pattern': 'random'}) else: self.configMultivalue(multivalue, multivalueType, data=kwargs['ipv4Address']) # Config IPv4 port step # disabled|0.0.0.1 if 'ipv4AddressPortStep' in kwargs: portStepMultivalue = self.ixnObj.httpHeader+multivalue+'/nest/1' self.ixnObj.logInfo('Configure IPv4 address port step') if kwargs['ipv4AddressPortStep'] != 'disabled': self.ixnObj.patch(portStepMultivalue, data={'step': kwargs['ipv4AddressPortStep']}) if kwargs['ipv4AddressPortStep'] == 'disabled': self.ixnObj.patch(portStepMultivalue, data={'enabled': False}) # Config Gateway if 'gateway' in kwargs: multivalue = ipv4Response.json()['gatewayIp'] self.ixnObj.logInfo('Configure IPv4 gateway. Attribute for multivalueId = jsonResponse["gatewayIp"]') # Default to counter multivalueType = 'counter' if 'gatewayMultivalueType' in kwargs: multivalueType = kwargs['gatewayMultivalueType'] if multivalueType == 'random': self.ixnObj.patch(self.ixnObj.httpHeader+multivalue, data={'pattern': 'random'}) else: self.configMultivalue(multivalue, multivalueType, data=kwargs['gateway']) # Config Gateway port step if 'gatewayPortStep' in kwargs: portStepMultivalue = self.ixnObj.httpHeader+multivalue+'/nest/1' self.ixnObj.logInfo('Configure IPv4 gateway port step') if kwargs['gatewayPortStep'] != 'disabled': self.ixnObj.patch(portStepMultivalue, data={'step': kwargs['gatewayPortStep']}) if kwargs['gatewayPortStep'] == 'disabled': self.ixnObj.patch(portStepMultivalue, data={'enabled': False}) # Config resolve gateway if 'resolveGateway' in kwargs: multivalue = ipv4Response.json()['resolveGateway'] self.ixnObj.logInfo('Configure IPv4 gateway to resolve gateway. Attribute for multivalueId = jsonResponse["resolveGateway"]') self.configMultivalue(multivalue, 'singleValue', data={'value': kwargs['resolveGateway']}) if 'prefix' in kwargs: multivalue = ipv4Response.json()['prefix'] self.ixnObj.logInfo('Configure IPv4 prefix. Attribute for multivalueId = jsonResponse["prefix"]') self.configMultivalue(multivalue, 'singleValue', data={'value': kwargs['prefix']}) if createNewIpv4Obj == True: self.configuredProtocols.append(ipv4Obj) return ipv4Obj