[edit system scripts language python] needs to be enabled in the Junos OS configuration.
Python on-box scripting is being implemented to provide an alternative to SLAX for operation, event, and commit scripts. SLAX will continue to be in Junos OS going forward and will be supported. Other than the large community of Python support, Python on-box scripting will allow, eventually, loading external modules or libraries to extend the capabilities of the scripts beyond what SLAX is currently capable of.
Physical: T Series, MX Series, EX Series, PTX Series, and QFX Series devices
Virtual: vMX Series and vQFX Series devices
Third-party import modules can be copied to the /opt/lib/python2.7/site-packages path.
From user scripts or applications, third-party modules can be called from import.
from app-module import foo
if __name__ == '__main__':
Using the identifier or submodule foo, respective module contents (functions, classes, etc.) can be accessed.
Going forward, for installing third-party modules, the cli>request system software add app-module*.tgz approach can be used from the CLI client.