aruba / pyaoscx

Python modules for AOS-CX
Apache License 2.0
35 stars 24 forks source link

PoeInterface does not work #20

Closed johanreinalda closed 2 years ago

johanreinalda commented 2 years ago

I have a CX6300 switch, which serves PoE to a bunch of Aruba AP's. When I run the code snippet below, I get an error stating "UNSUPPORTED CAPABILITY, This device is not PoE capable.", for either 10.04 or 10.08 api. I can get interfaces shutdown, enabled, vlan changes, and more, but not this. Any ideas ? (I am using the latest github pull, with the recent mac() fixes)

Output:

Getting sesion for 10.112.1.75
Firmware = FL.10.08.1040
Platform = 6300

Getting interface list...
Interface 1/1/1:
   poe.get() error - exception: 'UNSUPPORTED CAPABILITY, This device is not PoE capable.'
 ... (other interfaces removed for brevity)

My test code:

import sys

from pyaoscx.session import Session
from pyaoscx.device import Device
from pyaoscx.interface import Interface
from pyaoscx.poe_interface import PoEInterface

# disable unknown SSL cert warnings:
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

switch_ip = '10.112.1.75'
username = '***'
password = '***'

API_VERSION = '10.08'   # "10.04" or "10.08"

s =  Session(ip_address=switch_ip, api=API_VERSION)
try:
    print(f"Getting sesion for {switch_ip}")
    s.open(username=username, password=password)
except Exception as error:
    print('s.open() exception: {}. Cannot open session.'.format(error))
    sys.exit()

device = Device(s)
device.get()
print(f"Firmware = {device.firmware_version}")
print(f"Platform = {device.platform_name}")

print("\nGetting interface list...")
interface_dict = Interface.get_facts(session=s)
for ifname in interface_dict:
    print(f"Interface {ifname}:")
    try:
        # go get PoE info:
        interface = Interface(session=s, name=ifname)
        try:
            poe = PoEInterface(session=s, parent_interface=interface)
            try:
                poe.get(selector='status')
                print("   POE Exists!")
            except Exception as error:
                print(f"   poe.get() error - exception: {format(error)}")
        except Exception as error:
            print(f"   PoEInterface() error - exception: {format(error)}")
    except Exception as error:
        print(f"   Interface() error - exception: {format(error)}")

s.close()
michaelrosejr commented 2 years ago

It looks like the issue is that pyaoscx.poe_interface (line 65) should be poe and not quick_poe. I'll submit a PR if there isn't one already submitted to fix this bug.

michaelrosejr commented 2 years ago

A PR has been submitted for this fix.

johanreinalda commented 2 years ago

Any information on when this PR will be pulled, or another fix posted ?

michaelrosejr commented 2 years ago

@johanreinalda It appears v2.3.0 fixed this issue.

johanreinalda commented 2 years ago

Yes, this now works, since the change to poe_interface was posted several weeks back. Thanks! Now on to LLDP, etc. ;-)