XMC python modules used in example scripts

  • 0
  • 1
  • Question
  • Updated 1 week ago
  • Answered
Hello,

often in the XMC example scripts functions from the module "xmclib" or "device" are used.
Is there a documentation what functions are included, what parameters can be send and what returnvalues can be used?

If there is no documentation, is there a way to access the source code to find out what the functions can do?

It would be helpfule to use the existing code and not do reinvent the access to functions like "logger"

Here an example from XMC:

# @MetaDataEnd
from xmclib import emc_vars
from xmclib import logger
from xmclib import cli
from device import api


Best regards
Stephan


Photo of SH

SH

  • 5,318 Points 5k badge 2x thumb

Posted 4 weeks ago

  • 0
  • 1
Photo of Bharathiraja, Suresh

Bharathiraja, Suresh, Employee

  • 3,536 Points 3k badge 2x thumb
Hi Sh,

I am not sure if this is your question.

1) select the script from task and if you go to content tab where we can see the complete code of script.

2) Some of the basic scripts are available in github under Netsight.

3) XMC help tab has steps for scripting and how to create and run.

Thanks,
Suresh.B
Photo of SH

SH

  • 5,318 Points 5k badge 2x thumb
Hello Bharathiraja,

thank you for your answer. I am familiar with the XMC scripting tool and tasks and I know the content of the example scripts.

My question concerns  the modules used in these examples. Especially the xmclib and the device module (the post above). In modules you can wrap function and classes to reuse these in other scripts.

The example scripts use these modules and I would like to use these, too. Therefore I have to know what functions are available and how can I use these functions (parameters and return values).

Best regards
Stephan
Photo of James A

James A, Embassador

  • 7,492 Points 5k badge 2x thumb
It's a bit weird - all the scripts import from xmclib, but /usr/local/Extreme_Networks/NetSight/appdata/scripting/system/xmclib/__init__.py imports logger, nbi and emc_vars from xmcbase, which I can't find anywhere.

/usr/local/Extreme_Networks/NetSight/appdata/scripting/system/device/base/baseapi.py has actual methods in it, although in the end they are just cli calls and some are unimplemented.
Photo of Erik Auerswald

Erik Auerswald, Embassador

  • 13,792 Points 10k badge 2x thumb
Hi Stephan,

I cannot give you a definitive answer, but you may be able to find the source on an XMC appliance. Python modules are most often implemented in Python, and sometimes delivered as source. Thus you may just need to find the relevant files (brute force: find / -iname xmclib\*) to be able to read them.

Useful documentation is preferable, of course. :-)

Thanks,
Erik
Photo of SH

SH

  • 5,318 Points 5k badge 2x thumb
Hello Erik, hello James,


I have come as far as James. Therefore, the question how do I get to the information. I resolved the way till xmcbase, but I can't find it. Therefore this post.

I can't find any sources.

Best regards
Stephan


Photo of John Moore

John Moore, Employee

  • 546 Points 500 badge 2x thumb
Hi, all.

We're actually in the process of creating a more comprehensive scripting and workflows guide that should answer most of these questions. I'll provide a link to the resource online once it is published.

Thanks,

John
Photo of SH

SH

  • 5,318 Points 5k badge 2x thumb
Hello John,

thank you for feedback and good to hear. If you have a draft to read, I'm here ;-).

Regards
Stephan