def configBgpAsPathSegmentListNumber(self, routerId, asNumber, indexAndAsNumber): """ Description Set BGP AS numbers in the route range. If there are 5 AS# created under "Number of AS# In Segment-1", the asNumberList is the AS# that you want to modify for all route ranges (Device Group multiplier). The indexAndAsNumber is the route range index and value: [3, 300]. 3 = the 2nd route range (zero based) and 300 is the value. NOTE! Currently, this API will get the first Network Group object even if there are multiple Network Groups. Network Groups could be filtered by the name or by the first route range address. Haven't decided yet. Don't want to filter by name because in a situation where customers are also using Spirent, Spirent doesn't go by name. Parameters routerId: The Device Group router ID where the BGP is configured. asListNumber: 1|2|3|...|6|..: The AS# to modify. (On GUI, click NetworkGroup, on bottom tab asPathSegment, and on top tab, use the "Number of AS# In Segment-1" to set number of AS#1 or AS#2 or AS#3.) indexAndAsNumber: all|a list of indexes with as# -> [[1, 100], [3, 300], ...] Example: protocolObj.configBgpAsPathSegmentListNumber(routerid='195.0.0.2', 3, [[0,28], [3,298], [4, 828]]) Requirements: getDeviceGroupByRouterId() getMultivalues() configMultivalues() """ deviceGroupObj = self.getDeviceGroupByRouterId(routerId=routerId) if deviceGroupObj == 0: raise IxNetRestApiException('No Device Group found for router ID: %s' % routerId) queryData = {'from': deviceGroupObj, 'nodes': [{'node': 'networkGroup', 'properties': [], 'where': []}, {'node': 'ipv4PrefixPools', 'properties': [], 'where': []}, {'node': 'bgpIPRouteProperty', 'properties': [], 'where': []}, {'node': 'bgpAsPathSegmentList', 'properties': [], 'where': []}, {'node': 'bgpAsNumberList', 'properties': [], 'where': []} ]} queryResponse = self.ixnObj.query(data=queryData) try: bgpStack = queryResponse.json()['result'][0]['networkGroup'][0]['ipv4PrefixPools'][0]['bgpIPRouteProperty'][0]['bgpAsPathSegmentList'][0]['bgpAsNumberList'][int(asNumber)-1] except: raise IxNetRestApiException('No object found in DeviceGroup object: deviceGroup/networkGroup/ipv4PrefixPools/bgpIPRouteProperty/bgpAsPathSegmentList/bgpAsNumberlist: %s' % deviceGroupObj) if bgpStack == []: return IxNetRestApiException('No ipv4PrefixPools bgpIPRouteProperty object found.') bgpRouteObj = bgpStack['href'] response = self.ixnObj.get(self.ixnObj.httpHeader+bgpRouteObj) asNumberMultivalue = response.json()['asNumber'] asNumberValueList = self.ixnObj.getMultivalueValues(asNumberMultivalue) try: for eachIndexAsNumber in indexAndAsNumber: index = eachIndexAsNumber[0] asNumber = eachIndexAsNumber[1] asNumberValueList[index] = str(asNumber) except: raise IxNetRestApiException('The index that you indicated is out of range for the current AS list') self.ixnObj.logInfo('Configuruing: %s' % bgpRouteObj) self.ixnObj.configMultivalue(asNumberMultivalue, 'valueList', {'values': asNumberValueList})