cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3394
Views
7
Helpful
5
Replies

How-to list fabric nodes (Leafs) ?

sfeldmann
Level 1
Level 1

I've gotten stuck with a new script I'm creating.  As part of it, I would like to pull the list of nodes that are in the fabric and then use that list to do other tasks.  I have not been able to find the correct method to get the list of nodes.  Following the examples for listing tenants  - tenants = ACI.Tenant.get(session) - as an example, I would think it would be something like: nodes = ACI.xxxxx.get(session)  I've tried node, fabricNode, Fabric.node, etc.  I can see the model using APIC Object Browser, but I'm not sure how to refer to it, and I keep getting an error that it is undefined.  Any help is appreciated.

5 Replies 5

Richard Strnad
Level 4
Level 4

Hi Scott,

Important is to import the physical module.

I posted an example script on my blog: https://www.richardstrnad.ch/2016/10/27/acitoolkit-get-all-nodes/

If you have further questions, i'm happy to help.

Cheers

Richard

Hi richard and all,

 

i am also looking sample code like, i want to search the required leaf id then i want to get the ouput of interface status, interface vlan and more import interface description output

 

could you please help

I would suggest to open a new thread.

 

Cheers,

Sergiu

tigephillips
Level 4
Level 4

The following function will return a list of "leaf" objects in Python.  You could then iterate over the returned list and print or check values.  Notice how I am checking item.role to see if it's a leaf.

def get_leafs(session):

    from acitoolkit.aciphysobject import Node

    data = []

    items = Node.get(session)

    for item in items:

        if item.role == 'leaf':

            data.append(item.node)

   

    return data

Just to add more information for tigephillips,

We can use node.info() to get the complete information about the switches.

######sample code

from acitoolkit.acisession import Session
from acitoolkit.aciphysobject import Node

session = Session(url, usr_name, password)
resp = session.login()

nodes = Node.get(session)

for node in nodes:
    if node.role == 'leaf':     #This will filter for leaf nodes.
         print node.node        #you can use 'node.info()', either to see the complete information about the leaf nodes like

                                           inband_ip, outband_ip, firmware running etc..