cancel
Showing results for 
Search instead for 
Did you mean: 

XMC Python System Variables and api commands

XMC Python System Variables and api commands

Chad5
Contributor

Hi,

 

I am starting to create our own scripts/macros for certain tasks in Python and been looking at some of the built in one, so a simple one is disable a port:

 

from device import api

print "selected ports = " + emc_vars["port"]
api.perform_port_operation("disable", emc_vars["port"])

I can see from above there is a system variable of emc_vars[“ports”] and an api command to perform a port operation….

Where do I get a list of all variables and all the api commands so I can create my own stuff?

The alternative is to send SNMP commands, but this is simpler. I am looking to do one for example to enable/disable 802.1X mac or dot1x or mode.

Thanks for any references,

1 ACCEPTED SOLUTION

yas1
New Contributor II

Hello together,

This document https://api.extremenetworks.com/XMC/Scripting/Python_with_XMC_8.1_v0.94.pdf has helped me to get in touch with python and XMC. On page 5 there are some emc_vars listed too. Perhaps there are some further information for you.

Best regards
Yannick

View solution in original post

17 REPLIES 17

Chad5
Contributor

Hi Stephan,

 

I am going to run a script, which uses emc_cli to perform some tasks, which may change the current status of ports, vlans… whatever.

At the end at the script, I would like to tell XMC to initiate a rediscover of that switch/port to get the new status. 

Thanks,

StephanH
Valued Contributor III

Hello Chad,

do I understand you correctly that you want to display the current values from the switches and other devices in the XMC without clicking "Rediscover"?

Or is it about having current values in your script?

Regards Stephan

Chad5
Contributor

ohhh. ok. Didn’t know that. So I will refrain from trying to use those and stick to the document shared above.

so, I guess the only way to then send a refresh (rediscover to update ports) command in a pythen script is figure out how to send a nbi command using emc_nbi.

StephanH
Valued Contributor III

Hello Chad,

the official statement is (on my request). Do not use any of these modules (like device, xmclib, api, … ). These modules are not documented nor can you relay the modules are available in future. Typically these modules are linked to Java classes. It makes little sense here to try to use the included functions by reverse engineering.

 

 

 

Regards Stephan

Chad5
Contributor

This is great info and I was able to progress so much further than before after reading the pdf document and your suggestions.

One last thing I wonder if there is a document that discribed the various calls that I see in the included XMC example scripts. I see them import:

 

from device import api

from device.deviceutils import DeviceUtils

 

then there are calls that are not using the global objects like “emc_cli or emc_nbi”…

so I see calls like:
 

DeviceUtils.get_device_family ...... (I am guessing there are a lot 

api.vlan.config_switchport_trunk ......

api.perform_port_operations .....

 

Seems there is a lot more we can also do with the api.xxxxxxxx

the emc_cli is very good but it’s nice to know about the other methods using api to do device functions.

something I was looking how to do is after I send a emc_cli command, to send a refresh command on the device I was working with to update it’s new status. I know I can probably use nbi for that, but there might be an easier way.

 

Thank you all...

 

 

GTM-P2G8KFN