def configBgp(self, obj=None, routerId=None, port=None, portName=None, ngpfEndpointName=None, hostIp=None, **kwargs): """ Description Create or modify BGP. If creating a new BGP, provide an IPv4 object handle. If modifying a BGP, there are five options. 2-6 will query for the BGP object handle. 1> Provide the BGP object handle using the obj parameter. 2> Set routerId. 3> Set port: The physical port. 4> Set portName: The vport port name. 5> Set NGPF BGP name that you configured. 6> Set hostIp: The src IP. Parameters obj: : None or Either an IPv4 object or a BGP object. If creating new bgp object: IPv4 object example: /api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ethernet/1/ipv4/1 If modifying, you could provide the bgp object handle using the obj parameter: BGP object example: /api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ethernet/1/ipv4/1/bgpIpv4Peer/1 routerId: : The router ID IP address. port: : Format: [ixChassisIp, str(cardNumber), str(portNumber)] portName: : The virtual port name. ngpfEndpointName: : The name that you configured for the NGPF endpoint. hostIp: : The source IP address to query for the object. kwargs: BGP configuration attributes. The attributes could be obtained from the IxNetwork API browser. Syntax POST: /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id}/ipv4/{id}/bgpIpv4Peer PATCH: /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id}/ipv4/{id}/bgpIpv4Peer/{id} Example: Create a new bgp object... configBgp(ipv4Obj, name = 'bgp_1', enableBgp = True, holdTimer = 90, dutIp={'start': '1.1.1.2', 'direction': 'increment', 'step': '0.0.0.0'}, localAs2Bytes=101, enableGracefulRestart = False, restartTime = 45, type = 'internal', enableBgpIdSameasRouterId = True Return /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id}/ipv4/{id}/bgpIpv4Peer/{id} """ # To create a new BGP stack using IPv4 object. if obj != None: if 'bgp' not in obj: if 'ipv4' in obj: bgpUrl = self.ixnObj.httpHeader+obj+'/bgpIpv4Peer' if 'ipv6' in obj: bgpUrl = self.ixnObj.httpHeader+obj+'/bgpIpv6Peer' self.ixnObj.logInfo('Create new BGP in NGPF') response = self.ixnObj.post(bgpUrl) # /api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ethernet/1/ipv4/1/bgpIpv4Peer/1 bgpObj = response.json()['links'][0]['href'] # To modify BGP by providing a BGP object handle. if 'bgp' in obj: bgpObj = obj # To modify if ngpfEndpointName: bgpObj = self.getNgpfObjectHandleByName(ngpfEndpointName=ngpfEndpointName, ngpfEndpointObject='bgpIpv4Peer') # To modify if port: x = self.getProtocolListByPortNgpf(port=port) bgpObj = self.getProtocolObjFromProtocolList(x['deviceGroup'], 'bgpIpv4Peer')[0] # To modify if portName: x = self.getProtocolListByPortNgpf(portName=portName) bgpObj = self.getProtocolObjFromProtocolList(x['deviceGroup'], 'bgpIpv4Peer')[0] # To modify if routerId: bgpObj = self.getNgpfObjectHandleByRouterId(routerId=routerId, ngpfEndpointObject='bgpIpv4Peer') # To modify if hostIp: x = self.getProtocolListByHostIpNgpf(hostIp) bgpObj = self.getProtocolObjFromHostIp(x, protocol='bgpIpv4Peer') bgpObjResponse = self.ixnObj.get(self.ixnObj.httpHeader+bgpObj + '?links=true') if 'name' in kwargs: self.ixnObj.patch(self.ixnObj.httpHeader+bgpObj, data={'name': kwargs['name']}) # For BgpIpv4Peer if 'enableBgp' in kwargs and kwargs['enableBgp'] == True: multiValue = bgpObjResponse.json()['enableBgpId'] self.ixnObj.patch(self.ixnObj.httpHeader+multiValue+"/singleValue", data={'value': True}) # For BgpIpv6Peer if 'active' in kwargs and kwargs['active'] == True: multiValue = bgpObjResponse.json()['active'] self.ixnObj.patch(self.ixnObj.httpHeader+multiValue+"/singleValue", data={'value': True}) if 'dutIp' in kwargs: multiValue = bgpObjResponse.json()['dutIp'] self.configMultivalue(multiValue, 'counter', data=kwargs['dutIp']) for key,value in bgpObjResponse.json().items(): if key != 'links' and key not in ['dutIp']: if bool(re.search('multivalue', str(value))) == True: if key in kwargs: multiValue = bgpObjResponse.json()[key] self.ixnObj.logInfo('Configuring BGP multivalue attribute: %s' % key) self.ixnObj.patch(self.ixnObj.httpHeader+multiValue+"/singleValue", data={'value': kwargs[key]}) else: if key in kwargs: self.ixnObj.patch(self.ixnObj.httpHeader+bgpObj, data={key: kwargs[key]}) self.configuredProtocols.append(bgpObj) return bgpObj