PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...
PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..
Original Message:
Sent: May 10, 2023 05:01 AM
From: Andrew
Subject: Help with a working python script for Aruba CX APi calls
I made a video of what is happening,
I also added an extra step to show I have connection to the switch over HTTPS
https://youtu.be/7d-5ubOhgRw
Original Message:
Sent: May 09, 2023 01:28 PM
From: Tiffany.Chiapuzio-Wong
Subject: Help with a working python script for Aruba CX APi calls
Can you share the error you receive when you copy/paste the code I provided? No debug mode or anything
------------------------------
Ti Chiapuzio-Wong (they/them)
HPE Aruba Networking
Original Message:
Sent: May 09, 2023 05:55 AM
From: Andrew
Subject: Help with a working python script for Aruba CX APi calls
Thanks for helping, I do appreciate it.
I am using pycham, with Python 3.11,
I have installed pyoscx into the project.
I copied the code (and left the version as 10.09)
I don't have a proxy in my setup. I have a direct connection to switch.
When I try with a simple get command I get a certificate error, so i believe connectivity is fine.
I ran in debug mode and I keep getting the prompt when pressing enter. I enter the username and password but nothing after that.
Original Message:
Sent: May 08, 2023 12:31 PM
From: Tiffany.Chiapuzio-Wong
Subject: Help with a working python script for Aruba CX APi calls
at this point v10.11 isn't supported in pyaoscx but 10.09 is still supported with firmware version 10.11 - do you have a proxy set in your environment? when you say you're executing the script and you have to stop it- is it just executing with no output? did you copy/paste the code I sent?
what version of python are you using? are you using a python virtual env?
------------------------------
Ti Chiapuzio-Wong (they/them)
HPE Aruba Networking
Original Message:
Sent: May 08, 2023 10:41 AM
From: Andrew
Subject: Help with a working python script for Aruba CX APi calls
Thanks Ti
Unfortunately I get nothing with running the script... I have to stop the script from executing with no error message when I use the code above.
I have updated the switch version 10.11 as that is what I am using,
I checked https-server is enable,
I have logged into the GUi and checked the username and password in the swagger interface and got a success,
When i look at the switch logs, there is no evidence of the script trying to access the switch.
I'd be happy to be able to within python to just do a
post https://192.168.4.199/rest/v10.11/login?username=admin&password=Aruba123
and get a login status code back at this point.
Original Message:
Sent: May 05, 2023 01:07 PM
From: Tiffany.Chiapuzio-Wong
Subject: Help with a working python script for Aruba CX APi calls
Hi Andrew! I'm sorry to hear you're having difficulties - can you share what error you get with the above code? I'm sorry you're having difficulty with the PYAOSCX package, I recommend using our instance on the Python readthedocs for finding modules and their required parameters. Here is an example workflow that configures VLANs and shows how to use our object oriented package on creating a session object.
For your "show version" desired output here would be the following code:
from pyaoscx.session import Sessionfrom pyaoscx.device import Devicefrom getpass4 import getpassimport urllib3urllib3.disable_warnings()username = input("Enter Username: ")password = getpass('Password: ')version = "10.09"switch_ip = "10.6.7.16"s = Session(switch_ip, version)s.open(username, password)try: device = Device(s) version = device.get_firmware_version() print(version)except Exception as error: print("Ran into exception: {0}. Closing session.".format(error))finally: s.close()
------------------------------
Ti Chiapuzio-Wong (they/them)
HPE Aruba Networking
Original Message:
Sent: May 05, 2023 11:59 AM
From: Andrew
Subject: Help with a working python script for Aruba CX APi calls
Hi need some help,
please can somebody help me with a working example of logging into a CX switch using APi Calls,
I'd be happy just to do a show version at the moment.
I feel like I've watched every video on you tube, i've read the documentation, purchased all the books without making much progress.
I have Python 3 installed, with PyCham,
I cant use Paramiko or Netmiko on CX
I have tried using pyaoscx but have no idea how to use it and cant find a working example.
I'd really like to do it with APi calls, but cant get any response.
This is what I have got
import requests
from getpass4 import getpass
username = input("Enter Username: ")
password = getpass('Password: ')
baseurl = "https://192.168.4.199/rest/v10.11/"
creds = {"username": username, "password": password}
s = requests.Session()
login = s.post(baseurl + "login?", params=creds, verify=False, timeout=2)
print("Login Status: ", login.status_code, "Cookie: ", login.cookies)
logout = s.post(baseurl + "logout", verify=False, timeout=2)
print("Login Status: ", login.status_code, "Cookie: ", login.cookies)
This was from - Login with Python - Python and ArubaOS-CX 2
YouTube | remove preview |
| Login with Python - Python and ArubaOS-CX 2 | Use Python to login to the REST API of new ArubaOS-CX switches. Here's a step-by-step 'how to' demo. Twitter..........►https://twitter.com/joeneville_ | View this on YouTube > |
|
|
with a few updates to my script.