cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Bookmark
|
Subscribe
|
383
Views
0
Helpful
1
Replies

See Netflow exporter IP address on interfaces from APIC GUI / API

zo3
Level 1
Level 1

I'm setting up a simulator with the netflow policies, following the directions from the videos, but is it possible to see the exporter IP address assigned to specific interfaces? I want to know if there is a way or API to get the IP addresses that are assigned to each device/node in the fabric!

1 Reply 1

AshSe
VIP
VIP

Hi @zo3 

Yes, it is possible to see the exporter IP address assigned to specific interfaces in a Cisco ACI fabric. You can use the Cisco ACI API to retrieve the IP addresses assigned to each device/node in the fabric. Here are the steps to achieve this:

 

Using the Cisco ACI API

 

  1. Log in to the APIC:

 

  • You need to authenticate with the APIC to get an authentication token. This token will be used in subsequent API calls.

 

2. Retrieve Node Information:

 

  • Use the API to retrieve information about the nodes in the fabric, including their IP addresses.

 

Step-by-Step Guide

Step 1: Authenticate with the APIC

 

You need to send a POST request to the APIC to get an authentication token.

 

API Endpoint:

 

POST https://<APIC_IP>/api/aaaLogin.json

 

Request Body:

 

{

  "aaaUser": {

    "attributes": {

      "name": "<username>",

      "pwd": "<password>"

    }

  }

}

 

Example using curl:

 

curl -k -X POST https://<APIC_IP>/api/aaaLogin.json -d '{

  "aaaUser": {

    "attributes": {

      "name": "<username>",

      "pwd": "<password>"

    }

  }

}'

 

Step 2: Retrieve Node Information

 

Once authenticated, use the token to retrieve node information, including IP addresses.

 

API Endpoint:

 

GET https://<APIC_IP>/api/node/class/fabricNode.json

 

Example using curl:

 

curl -k -X GET https://<APIC_IP>/api/node/class/fabricNode.json -b apic-cookie.txt

 

Step 3: Retrieve Interface Information

 

To get the IP addresses assigned to specific interfaces, you can query the l3extRsPathL3OutAtt class.

 

API Endpoint:

 

GET https://<APIC_IP>/api/node/class/l3extRsPathL3OutAtt.json

 

Example using curl:

 

curl -k -X GET https://<APIC_IP>/api/node/class/l3extRsPathL3OutAtt.json -b apic-cookie.txt

 

Example Python Script

 

Here is an example Python script that uses the requests library to authenticate with the APIC and retrieve node and interface information:

 

import requests

import json

 

# APIC credentials

apic_ip = "<APIC_IP>"

username = "<username>"

password = "<password>"

 

# Disable warnings for self-signed certificates

requests.packages.urllib3.disable_warnings()

 

# Authenticate with the APIC

login_url = f"https://{apic_ip}/api/aaaLogin.json"

login_payload = {

    "aaaUser": {

        "attributes": {

            "name": username,

            "pwd": password

        }

    }

}

 

session = requests.Session()

response = session.post(login_url, json=login_payload, verify=False)

if response.status_code != 200:

    print("Failed to authenticate with APIC")

    exit(1)

 

# Retrieve node information

nodes_url = f"https://{apic_ip}/api/node/class/fabricNode.json"

response = session.get(nodes_url, verify=False)

nodes = response.json()["imdata"]

 

# Print node information

for node in nodes:

    node_attrs = node["fabricNode"]["attributes"]

    print(f"Node ID: {node_attrs['id']}, Name: {node_attrs['name']}, IP: {node_attrs['address']}")

 

# Retrieve interface information

interfaces_url = f"https://{apic_ip}/api/node/class/l3extRsPathL3OutAtt.json"

response = session.get(interfaces_url, verify=False)

interfaces = response.json()["imdata"]

 

# Print interface information

for interface in interfaces:

    interface_attrs = interface["l3extRsPathL3OutAtt"]["attributes"]

    print(f"Interface: {interface_attrs['tDn']}, IP: {interface_attrs['addr']}")

 

# Close the session

session.close()

 

AshSe

Please rate this post if it was helpful; your feedback is appreciated!

Review Cisco Networking for a $25 gift card

Save 25% on Day-2 Operations Add-On License