def flapBgpRoutesNgpf(self, prefixPoolObj, enable=True, ipRouteListToFlap='all', uptime=0, downtime=0, ip='ipv4'): """ Description This API will enable or disable flapping on either all or a list of BGP IP routes. If you are configuring routes to enable, you could also set the uptime and downtime in seconds. Parameters prefixPoolObj = The Network Group PrefixPool object that was returned by configNetworkGroup() /api/v1/sessions//ixnetwork/topology//deviceGroup//networkGroup//ipv4PrefixPools/ enable: True or False - Default = True ipRouteListToFlap: 'all' or a list of IP route addresses to enable/disable. [['160.1.0.1', '160.1.0.2',...] - Default = 'all' upTime: In seconds. - Defaults = 0 downTime: In seconds. - Defaults = 0 ip: ipv4 or ipv6 - Defaults = ipv4 Syntax POST = For IPv4: http://{apiServerIp:port}/api/v1/sessions//ixnetwork/topology//deviceGroup//networkGroup//ipv4PrefixPools//bgpIPRouteProperty For IPv6: http://{apiServerIp:port}/api/v1/sessions//ixnetwork/topology//deviceGroup//networkGroup//ipv4PrefixPools//bgpV6IPRouteProperty """ if ipRouteListToFlap != 'all' and type(ipRouteListToFlap) != list: ipRouteListToFlap = ipRouteListToFlap.split(' ') # Get a list of configured IP route addresses response = self.ixnObj.get(self.ixnObj.httpHeader+prefixPoolObj) networkAddressList = response.json()['lastNetworkAddress'] count = len(networkAddressList) # Recreate an index list based on user defined ip route to enable/disable indexToFlapList = [] if ipRouteListToFlap != 'all': for ipRouteAddress in ipRouteListToFlap: # A custom list of indexes to enable/disable flapping based on the IP address index number. indexToFlapList.append(networkAddressList.index(ipRouteAddress)) # Copy the same index list for uptime and downtime indexUptimeList = indexToFlapList indexDowntimeList = indexToFlapList if ip == 'ipv4': response = self.ixnObj.get(self.ixnObj.httpHeader+prefixPoolObj+'/bgpIPRouteProperty') if ip == 'ipv6': response = self.ixnObj.get(self.ixnObj.httpHeader+prefixPoolObj+'/bgpV6IPRouteProperty') enableFlappingMultivalue = response.json()[0]['enableFlapping'] upTimeMultivalue = response.json()[0]['uptime'] downTimeMultivalue = response.json()[0]['downtime'] flappingResponse = self.ixnObj.getMultivalueValues(enableFlappingMultivalue) uptimeResponse = self.ixnObj.getMultivalueValues(upTimeMultivalue) downtimeResponse = self.ixnObj.getMultivalueValues(downTimeMultivalue) # Flapping IP addresses flapOverlayList = [] uptimeOverlayList = [] downtimeOverlayList = [] # Build a valueList of either "true" or "false" if ipRouteListToFlap == 'all': for counter in range(0,count): if enable == True: flapOverlayList.append("true") if enable == False: flapOverlayList.append("false") uptimeOverlayList.append(str(uptime)) downtimeOverlayList.append(str(downtime)) if ipRouteListToFlap != 'all': currentFlappingValueList = flappingResponse[0] currentUptimeValueList = uptimeResponse[0] currentDowntimeValueList = downtimeResponse[0] indexCounter = 0 for (eachFlapValue, eachUptimeValue, eachDowntimeValue) in zip(currentFlappingValueList, currentUptimeValueList, currentDowntimeValueList): # Leave the setting alone on this index position. User did not care to change this value. if indexCounter not in indexToFlapList: flapOverlayList.append(eachFlapValue) uptimeOverlayList.append(eachUptimeValue) downtimeOverlayList.append(eachDowntimeValue) else: # Change the value on this index position. if enable == True: flapOverlayList.append("true") else: flapOverlayList.append("false") uptimeOverlayList.append(str(uptime)) downtimeOverlayList.append(str(downtime)) indexCounter += 1 # /topology/[1]/deviceGroup self.ixnObj.patch(self.ixnObj.httpHeader + enableFlappingMultivalue+'/valueList', data={'values': flapOverlayList}) self.ixnObj.patch(self.ixnObj.httpHeader + upTimeMultivalue+'/valueList', data={'values': uptimeOverlayList}) self.ixnObj.patch(self.ixnObj.httpHeader + downTimeMultivalue+'/valueList', data={'values': downtimeOverlayList})