cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Python Scripts Executing from Netsight - Clarification Needed

Python Scripts Executing from Netsight - Clarification Needed

Ed_McGuigan1
New Contributor III
I got my python book and started learning python at the beginning of the week.

I want to write a script that can be executed from Netsight ( EMC 8.04 ). What I actually want to do is locate ports on switches to which PoE powered wireless access points are connected and cycle the PoE power in order to reboot hung access points.

There is no documentation that I can find specific to Python scripts as opposed to TCL scripts on Netsight and my assumption was that I would just write a script that was suitable to be loaded directly onto a switch and that the Netsight interface would take care of uploading the script and executing it.

I noticed that there didn't seem to be any information about adding the same kind of metadata for the definition of script arguments.

I have a script that I can manually upload onto a switch and execute but if I try to execute it from Netsight by selecting the Run option and picking a switch to run it on, it fails with a complaint that the exsh module couldn't be found.

I have realized that a python script in Netsight is not uploaded to the switch but rather executed on the server. I guess that would be workable but there is no documented method for providing arguments to the scripts.

Is this a feature that hasn't been completed yet?
I am trying to work out a method of being able to upload and execute a python script on a switch such that it can be leveraged from Netsight, or understand how others are leveraging python on XOS and getting scripts out onto devices on as needed basis.

Do I need to use a generic python server script to push out my XOS python scripts, run them at the switch and then delete them?
20 REPLIES 20

Dave_Hammers
Extreme Employee
https://github.com/extremenetworks/EXOS_Apps/tree/master/JSONRPC includes a number of remote access topics using the EXOS JSONRPC interface and provides a more comprehensive Python jsonrpc.py class for python automation developers.

There is a client app jsonrpc_client.py that can be used as a JSONRPC CLI shell and/or a remote script tool. It also serves as an example for Python developers implementing their own EXOS JSONRPC applications.

jsonrpc_client.py supports
  • Command line options for multiple IP addresses, or specify a file with multiple IP addresses
  • Command line option for a single CLI to send to multiple switches or specify a file with multiple EXOS commands
  • Command line option for a EXOS script file to send to multiple swithes
  • Interactive option for EXOS CLI to send to multiple IP addresses
  • interactive option to enter EXOS script names and their command line parameters

Dave_Hammers
Extreme Employee
If you've had a chance to look at the example, do you have any feedback?

A lot of things are coming for Python in ExtremeManagement. Stay tuned.

I had a quick look through the example Dave. Bear in mind that I am brand new to python, have never worked with JSON and haven't done very much programming at all over the last few years.

Given all of that it looked quite straightforward, a testament to python's clarity. I am not sure I will take this approach though. My original observation was based on a belief that I couldn't run a decent python script from the server with parameters that could be adjusted by a non-programmer and therefore that I would need to use TCL on the server to run python on the switch ( I definitely wanted to move away from doing much in TCL ). I was wrong about that.

If I can use python on the server, that is preferred for me. We don't have a collection of existing python switch scripts that we would want to leverage. I am going to use python on the switch but it will be for port related scripting.

In any event, it's nice to have several options.
GTM-P2G8KFN