def getNgpfObjectHandleByRouterId(self, ngpfEndpointObject, routerId): """ Description Get the NGPF object handle filtering by the routerId. All host interface has a router ID by default and the router ID is located in the Device Group in the IxNetwork GUI. The API endpoint is: /topology/deviceGroup/routerData Note: Router ID exists only if there are protocols configured. Parameters ngpfEndpointObject: : The NGPF endpoint. Example: deviceGroup, ethernet, ipv4, ipv6, bgpIpv4Peer, ospfv2, etc. These endpoint object names are the IxNetwork API endpoints and you could view them in the IxNetwork API browser. routerId: : The router ID IP address. Example: protocolObj.getNgpfObject(ngpfEndpointObject='ipv4', routerId='192.0.0.1') return objectHandle: /api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/ethernet/1/ipv4/1 protocolObj.getNgpfObject(ngpfEndpointObject='bgpIpv4Peer', routerId='193.0.0.1') return objectHandle: /api/v1/sessions/1/ixnetwork/topology/2/deviceGroup/1/ethernet/1/ipv4/1/bgpIpv4Peer/2 protocolObj.getNgpfObject(ngpfEndpointObject='networkGroup', routerId='193.0.0.1') return objectHandle: /api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/networkGroup/1 protocolObj.getNgpfObject(ngpfEndpointObject='ipv4PrefixPools', routerId='193.0.0.1') return objectHandle: /api/v1/sessions/1/ixnetwork/topology/1/deviceGroup/1/networkGroup1/ipv4PrefixPools/1 """ ngpfMainObjectList = ['topology', 'deviceGroup', 'ethernet', 'ipv4', 'ipv6', 'networkGroup', 'ipv4PrefixPools', 'ipv6PrefixPools'] ngpfL2ObjectList = ['isisL3', 'lacp', 'mpls'] ngpfL3ObjectList = ['ancp', 'bfdv4Interface', 'bgpIpv4Peer', 'bgpIpv6Peer', 'dhcpv4relayAgent', 'dhcpv6relayAgent', 'geneve', 'greoipv4', 'greoipv6', 'igmpHost', 'igmpQuerier', 'lac', 'ldpBasicRouter', 'ldpBasicRouterV6', 'ldpConnectedInterface', 'ldpv6ConnectedInterface', 'ldpTargetedRouter', 'ldpTargetedRouterV6', 'lns', 'mldHost', 'mldQuerier', 'ptp', 'ipv6sr', 'openFlowController', 'openFlowSwitch', 'ospfv2', 'ospfv3', 'ovsdbcontroller', 'ovsdbserver', 'pcc', 'pce', 'pcepBackupPCEs', 'pimV4Interface', 'pimV6Interface', 'ptp', 'rsvpteIf', 'rsvpteLsps', 'tag', 'vxlan' ] if ngpfEndpointObject not in ngpfL2ObjectList + ngpfL3ObjectList + ngpfMainObjectList: raise IxNetRestApiException('\nError: No such ngpfEndpointObject: %s' % ngpfEndpointObject) if ngpfEndpointObject in ngpfL2ObjectList + ngpfL3ObjectList: if ngpfEndpointObject in ngpfL2ObjectList: nodesList = [{'node': 'topology', 'properties': [], 'where': []}, {'node': 'deviceGroup', 'properties': [], 'where': []}, {'node': 'routerData', 'properties': ['routerId'], 'where': []}, {'node': 'ethernet', 'properties': [], 'where': []} ] if ngpfEndpointObject in ngpfL3ObjectList: nodesList = [{'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': []} ] # Add the protocol level to the end of the list. nodesList.insert(len(nodesList), {'node': ngpfEndpointObject, 'properties': [], 'where': []}) # User is looking for non protocol object handle such as deviceGroup, ethernet, ipv4 or ipv6 if ngpfEndpointObject not in ngpfL2ObjectList + ngpfL3ObjectList: nodesList = [{'node': 'topology', 'properties': [], 'where': []}, {'node': 'deviceGroup', 'properties': [], 'where': []}, {'node': 'networkGroup', 'properties': [], 'where': []}, {'node': 'ethernet', 'properties': [], 'where': []}, {'node': 'ipv4PrefixPools', 'properties': [], 'where': []}, {'node': 'ipv6Prefixpools', 'properties': [], 'where': []}, {'node': 'routerData', 'properties': ['routerId'], 'where': []}, {'node': 'ethernet', 'properties': [], 'where': []}, {'node': 'ipv4', 'properties': [], 'where': []}, {'node': 'ipv6', 'properties': [], 'where': []} ] queryData = {'from': '/', 'nodes': nodesList} queryResponse = self.ixnObj.query(data=queryData) # This is for getObject out of scope variable tracking class getObjectVar: protocolObjHandle= None foundRouterId = False