datacenter / acitoolkit

A basic toolkit for accessing the Cisco APIC
Other
347 stars 266 forks source link

ACI.Interface.get works only with pod='1' #353

Closed mupett closed 4 years ago

mupett commented 4 years ago

WORKING WITH POD ='1'


 # Download all of the interfaces
# and store the data as tuples in a list
data = []
interfaces = ACI.Interface.get(session, pod_parent='1', node='1101')
for interface in interfaces:
    data.append((interface.attributes['if_name'],
                 interface.attributes['porttype'],
                 interface.attributes['adminstatus'],
                 interface.attributes['operSt'],
                 interface.attributes['operSpeed'],
                 interface.attributes['mtu'],
                 interface.attributes['usage']))

(autoACI) [mupett@netmon samples]$ python aci-show-interfaces_debug.py INTERFACE TYPE ADMIN OPER SPEED MTU USAGE
--------- ---- ------ ------ ----- ___ --------- eth 1/1101/101/1/3 extchhp up up 10G 9000 epg
eth 1/1101/101/1/4 extchhp up up 10G 9000 epg
eth 1/1101/101/1/5 extchhp up up 10G 9000 epg
eth 1/1101/101/1/6 extchhp up up 10G 9000 epg
eth 1/1101/101/1/7 extchhp up down unknown 9000 discovery eth 1/1101/101/1/8 extchhp up down unknown 9000 discovery eth 1/1101/1/1 leaf up up 10G 9222 discovery eth 1/1101/1/2 leaf up up 10G 9222 discovery eth 1/1101/1/3 leaf up up 10G 9222 discovery eth 1/1101/1/4 leaf up up 10G 9222 discovery eth 1/1101/1/5 leaf up up 10G 9222 discovery eth 1/1101/1/6 leaf up up 10G 9222 discovery eth 1/1101/1/7 leaf up down 10G 9000 discovery eth 1/1101/1/8 leaf up down 10G 9000 discovery

NOT WORKING WITH POD ='2'

# Download all of the interfaces
# and store the data as tuples in a list
data = []
interfaces = ACI.Interface.get(session, pod_parent='2', node='2101')
for interface in interfaces:
    data.append((interface.attributes['if_name'],
                 interface.attributes['porttype'],
                 interface.attributes['adminstatus'],
                 interface.attributes['operSt'],
                 interface.attributes['operSpeed'],
                 interface.attributes['mtu'],
                 interface.attributes['usage']))

(autoACI) [mupett@netmon samples]$ python aci-show-interfaces_debug.py INTERFACE TYPE ADMIN OPER SPEED MTU USAGE
--------- ---- ------ ------ ----- _ --------- (autoACI) [mupett@netmon samples]$ python aci-show-interfacesdebug.py INTERFACE TYPE ADMIN OPER SPEED MTU USAGE
--------- ---- ------ ------ -----
--------- (autoACI) [mupett@netmon samples]$

mupett commented 4 years ago

thankyou :) but it still doesn't work

michsmit99 commented 4 years ago

Strange. Did you reinstall (i.e. python setup.py install or python setup.py develop) after downloading the latest ?

I'm running the following test code

import acitoolkit as ACI
import sys

# Take login credentials from the command line if provided
# Otherwise, take them from your environment variables file ~/.profile
description = 'Testing issue #353.'
creds = ACI.Credentials('apic', description)
args = creds.get()

# Login to APIC
session = ACI.Session(args.url, args.login, args.password)
resp = session.login()
if not resp.ok:
    print('%% Could not login to APIC')
    sys.exit(0)

# Download all of the interfaces
# and store the data as tuples in a list
data = []
interfaces = ACI.Interface.get(session, pod_parent='2', node='512')
for interface in interfaces:
    data.append((interface.attributes['if_name'],
                 interface.attributes['porttype'],
                 interface.attributes['adminstatus'],
                 interface.attributes['operSt'],
                 interface.attributes['operSpeed'],
                 interface.attributes['mtu'],
                 interface.attributes['usage']))

for line in data:
    print(line)

and getting the following output:

(venv) $ python test_pod_number.py 
('eth 2/512/1/33', 'fab', 'up', 'up', '40G', '9366', 'fabric')
('eth 2/512/1/34', 'fab', 'up', 'down', '100G', '9366', 'fabric,fabric-ext')
('eth 2/512/1/35', 'fab', 'up', 'up', '40G', '9366', 'fabric')
('eth 2/512/1/36', 'fab', 'up', 'down', '100G', '9366', 'fabric,fabric-ext')
('eth 2/512/1/1/1', 'leaf', 'up', 'down', '10G', '9000', 'epg')
mupett commented 4 years ago

Hello, It worked!

Regards Luca