def activateRouterIdProtocol(self, routerId, protocol=None, activate=True): """ Description Activate the protocols based on the RouterId. This API will disabled all Device Groups within a Topology Group and enable only the Device Group that has the specified router ID in it. Parameter routerId: The router Id address to enable|disable activate: True|False. The protocol to activate|disactivate. protocol: The protocol to activate. Current choices: bgpIpv4Peer, bgpIpv6Peer, igmpHost, igmpQuerier, mldHost, mldQuerier, pimV6Interface, ospfv2, ospfv3, isisL3 """ if type(routerId) is list: routerId = routerId[0] queryData = {'from': '/', 'nodes': [{'node': 'topology', 'properties': [], 'where': []}, {'node': 'deviceGroup', 'properties': [], 'where': []}, {'node': 'routerData', 'properties': ['routerId'], 'where': []}, {'node': 'ethernet', 'properties': [], 'where': []}, {'node': 'ipv4', 'properties': [], 'where': []}, {'node': 'ipv6', 'properties': [], 'where': []}, {'node': protocol, 'properties': ['active'], 'where': []} ]} queryResponse = self.ixnObj.query(data=queryData, silentMode=False) # Get the Device Group object that contains the RouterId # and search for configured protocols. protocolList = [] foundRouterIdFlag = 0 for topology in queryResponse.json()['result'][0]['topology']: for deviceGroup in topology['deviceGroup']: deviceGroupHref = deviceGroup['href'] routerIdMultivalue = deviceGroup['routerData'][0]['routerId'] routerIdList = self.ixnObj.getMultivalueValues(routerIdMultivalue, silentMode=True) self.ixnObj.logInfo('activateRouterIdProtocols: Querying DeviceGroup for routerId %s: %s' % (routerId, protocol)) self.ixnObj.logInfo('routerIdList: {0}'.format(routerIdList)) # response: ["192.0.0.1", "192.0.0.2", "192.0.0.3", "192.0.0.4","192.1.0.1"] if routerId in routerIdList: foundRouterIdFlag = 1 self.ixnObj.logInfo('Found routerId %s' % routerId) routerIdIndex = routerIdList.index(routerId) self.ixnObj.logInfo('routerId index: %s' % routerIdIndex) if protocol == 'isisL3' and deviceGroup['ethernet'][0]['isisL3'] != []: protocolList.append(deviceGroup['ethernet'][0]['isisL3'][0]['active']) if deviceGroup['ethernet'][0]['ipv4'] != []: if protocol == 'igmpHost' and deviceGroup['ethernet'][0]['ipv4'][0]['igmpHost'] != []: protocolList.append(deviceGroup['ethernet'][0]['ipv4'][0]['igmpHost'][0]['active']) if protocol == 'igmpQuerier' and deviceGroup['ethernet'][0]['ipv4'][0]['igmpQuerier'] != []: protocolList.append(deviceGroup['ethernet'][0]['ipv4'][0]['igmpQuerier'][0]['active']) if protocol == 'bgpIpv4Peer' and deviceGroup['ethernet'][0]['ipv4'][0]['bgpIpv4Peer'] != []: protocolList.append(deviceGroup['ethernet'][0]['ipv4'][0]['bgpIpv4Peer'][0]['active']) if protocol == 'ospfv2' and deviceGroup['ethernet'][0]['ipv4'][0]['ospfv2'] != []: protocolList.append(deviceGroup['ethernet'][0]['ipv4'][0]['ospfv2'][0]['active']) if deviceGroup['ethernet'][0]['ipv6'] != []: if protocol == 'pimV6Interface' and deviceGroup['ethernet'][0]['ipv6'][0]['pimV6Interface'] != []: protocolList.append(deviceGroup['ethernet'][0]['ipv6'][0]['pimV6Interface'][0]['active']) if protocol == 'bgpIpv6Peer' and deviceGroup['ethernet'][0]['ipv6'][0]['bgpIpv6Peer'] != []: protocolList.append(deviceGroup['ethernet'][0]['ipv6'][0]['bgpIpv6Peer'][0]['active']) if protocol == 'ospfv3' and deviceGroup['ethernet'][0]['ipv6'][0]['ospfv3'] != []: protocolList.append(deviceGroup['ethernet'][0]['ipv6'][0]['ospfv3'][0]['active']) if protocol == 'mldHost' and deviceGroup['ethernet'][0]['ipv6'][0]['mldHost'] != []: protocolList.append(deviceGroup['ethernet'][0]['ipv6'][0]['mldHost'][0]['active']) if protocol == 'mldQuerier' and deviceGroup['ethernet'][0]['ipv6'][0]['mldQuerier'] != []: protocolList.append(deviceGroup['ethernet'][0]['ipv6'][0]['mldQuerier'][0]['active']) for protocolActiveMultivalue in protocolList: try: protocolActiveList = self.ixnObj.getMultivalueValues(protocolActiveMultivalue) self.ixnObj.logInfo('currentValueList: %s' % protocolActiveList) protocolActiveList[routerIdIndex] = str(activate).lower() self.ixnObj.logInfo('updatedValueList: %s' % protocolActiveList) self.ixnObj.configMultivalue(protocolActiveMultivalue, multivalueType='valueList', data={'values': protocolActiveList}) except: pass return if foundRouterIdFlag == 0: raise Exception ('\nNo RouterID found in any Device Group: %s' % routerId)