def sendPimV4JoinLeaveNgpf(self, routerId=None, pimObj=None, multicastIpAddress=None, action='join'): """ Description Send PIMv4 joins or leaves. A PIM host object is acceptable. If you don't know the PIM host object, use Device Group RouterID. Since a Device Group could have many routerID, you could state one of them. If multicastIpAddress is 'all', this will send join on all multicast addresses. Else, provide a list of multicast IP addresses to send join|leave. NOTE: Current support: Each IP host multicast group address must be unique. IP hosts could send the same multicast group address, but this API only supports unique multicast group address. Parameters routerId: The Device Group Router ID address. pimObj: '/api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ethernet/1/ipv4/1/pimV4Interface/1/pimV4JoinPruneList' multicastIpAddress: 'all' or a list of multicast IP addresses to send join. Example: ['225.0.0.3', '225.0.0.4'] action: join|leave """ # In case somebody passes in http://{ip:port}. All this function needs is the Rest API. if pimObj: match = re.match('http://.*(/api.*)', pimObj) if match: pimObj = match.group(1) if routerId: deviceGroupObj = self.getDeviceGroupByRouterId(routerId=routerId) if deviceGroupObj == 0: raise IxNetRestApiException('No Device Group found for router ID: %s' % routerId) queryData = {'from': deviceGroupObj, 'nodes': [{'node': 'routerData', 'properties': [], 'where': []}, {'node': 'ethernet', 'properties': [], 'where': []}, {'node': 'ipv4', 'properties': [], 'where': []}, {'node': 'pimV4Interface', 'properties': [], 'where': []} ]} queryResponse = self.ixnObj.query(data=queryData) routerIdObj = queryResponse.json()['result'][0]['routerData'][0]['href'] response = self.ixnObj.get(self.ixnObj.httpHeader+routerIdObj) routerIdMultivalue = response.json()['routerId'] routerIdList = self.ixnObj.getMultivalueValues(routerIdMultivalue, silentMode=True) if routerId in routerIdList: pimObj = queryResponse.json()['result'][0]['ethernet'][0]['ipv4'][0]['pimV4Interface'][0]['href'] # Based on the list of multicastIpAddress, get all their indexes. response = self.ixnObj.get(self.ixnObj.httpHeader+pimObj+'/pimV4JoinPruneList') startMcastAddrMultivalue = response.json()['groupV4Address'] listOfConfiguredMcastIpAddresses = self.ixnObj.getMultivalueValues(startMcastAddrMultivalue) self.ixnObj.logInfo('sendPimV4JoinNgpf: List of configured Mcast IP addresses: %s' % listOfConfiguredMcastIpAddresses) if listOfConfiguredMcastIpAddresses == []: raise IxNetRestApiException('sendPimV4JoinNgpf: No Mcast IP address configured') if multicastIpAddress == 'all': listOfMcastAddresses = listOfConfiguredMcastIpAddresses else: listOfMcastAddresses = multicastIpAddress # Note: Index position is not zero based. indexListToSend = [] for eachMcastAddress in listOfMcastAddresses: index = listOfConfiguredMcastIpAddresses.index(eachMcastAddress) indexListToSend.append(index+1) url = pimObj+'/pimV4JoinPruneList/operations/%s' % action data = {'arg1': [pimObj+'/pimV4JoinPruneList'], 'arg2': indexListToSend} self.ixnObj.logInfo('sendPimv4JoinNgpf: %s' % url) self.ixnObj.logInfo('\t%s' % multicastIpAddress) response = self.ixnObj.post(self.ixnObj.httpHeader+url, data=data) self.ixnObj.waitForComplete(response, url+response.json()['id'])