cancel
Showing results for 
Search instead for 
Did you mean: 

Can't import api from exos

Can't import api from exos

Mirco
New Contributor
Hey everybody!

I'm working on a project with an Extreme Networks Summit X440-8p running firmware-version 16.1.1.4. I want to write a python script, but I'm stuck at the beginning.

The Python Scripting Guide (http://www.extremenetworks.com/wp-content/uploads/2015/02/Python_Getting_Started_Guide.pdf) tells me I have to import api from exos with the following line:

"from exos import api"

Unfortunately, every time I want to execute my script (which just has a print command at the moment), there's an error:

"* X440-8p.81 # run script print_test
Traceback (most recent call last):
File "/config/print_test.py", line 1, in
from exos import api
File "/exos/tools/lib/python2.7/site-packages/exos/api/__init__.py", line 21, in
File "/exos/tools/lib/python2.7/site-packages/exos/api/ems.py", line 10, in
ImportError: No module named _exos_ext_ems".

What am I doing wrong? It's exactly how the scripting guide tells me to import the api. This site tells me the same: http://documentation.extremenetworks.com/python/

Has anything changed since it looks like this site is for software-version 15.7.1 whereas I'm running 16.1.1.4?

Thanks in advance!
Mirco
22 REPLIES 22

Tim_Black
New Contributor II
I ended up just copying the jsonrpc.py file from EXOS_Apps for now to our internal repo, since that was all that was required. It works great! We'll look into using the entire repos when our needs get more complicated. Thanks.

Tim_Black
New Contributor II
Thanks Dave. Do you or anyone have any general insights into the purpose and distinction between all these repos that appear to overlap a lot in that they all have examples of extreme scripts: ExtremeScripting, EXOS_Apps, exoslib?

I'm cloning what I need to our git server, and would rather not just clone everything willy nilly. Was hoping someone could point out the rhyme and reason for the code organization there. Thanks.

Dave_Hammers
Extreme Employee
I'd recommend using https://github.com/extremenetworks/EXOS_Apps/tree/master/JSONRPC
It has support for authentication cookies so each JSONRPC transaction doesn't re-authenticate on the switch.
It also has HTTP/HTTPS support which tries HTTPS first before trying HTTP.

I had forgotten about the version posted in ExtremeScripting but I see someone has contributed to that version.which is why the date is recent.

Tim_Black
New Contributor II
Thanks Dave. I see your name as the last person to update the version of jsonrpc.py in the EXOS_Apps project (back in March), so I will ask you my next question directly:

I also see an implementation for the JsonRPC class required to use this API defined in the rmtscript.py module in the ExtremeScripting project, which was modified much more recently (3 months ago). I'm confused by these multiple implementations - seems like one should be using the other, since they're both in ExtremeNetworks' repos. Which should I use, to maximize my chances of being able to pull improvements moving forward, and/or be able to contribute to?

I was going to just use the one in the EXOS_Apps project, since this is the one that Stephane Grosjean pointed me at in [filter_by]=all&topic-reply-list[settings][reply_id]=19790751#reply_19790751]my other thread. But that one apparently isn't the most up-to-date.

Any advice would be appreciated, thanks.
GTM-P2G8KFN