Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 34
Part no.9036931-00 Rev AA February 2021
Default 1 --------------------------------T------------- ANY 0 /0 VR-Default
Mgmt 4095 192.168.56.121 /24 -------------------------- ANY 1 /1 VR-Mgmt
VLAN_0042 42 ---------------------------------------------- ANY 1 /1 VR-Default
--------------------------------------------------------------------------------------
Flags : (B) BFD Enabled, (c) 802.1ad customer VLAN, (C) EAPS Control VLAN,
[…]
Total number of VLAN(s) :
3.1.1.5.2 Startup Files
Potential companions for Python Scripting and UPM are the EXOS startup files. Historically, two startup
files can be used with EXOS:
- default.xsf
- autoexec.xsf
The autoexec.xsf file starts at every boot of the switch, while the default.xsf is only executed when the
switch boots with no configuration (in factory default config or after an unconfigure switch all
command). The default.xsf has a higher precedence. An autoexec.xsf cannot be used if default.xsf has
been started.
Both startup files execute valid CLI commands, which must be executed within 500 seconds. The startup
file aborts after 500 seconds without executing the remaining commands.
Note: The results of the startup file execution can be seen using the command show script output {default
| autoexec}.
With the introduction of Python support in EXOS, these two files have been added to Python, and with
EXOS 21.1 the .py versions are also supported.
default.py
autoexec.py
EXOS 22.3 introduced a new startup file in EXOS named exshrc.xsf. This file is executed after a successful
login in EXOS, and lets you execute specific CLI commands, or scripts, at each login. You can see who is
connected and start a required script per user. This can be helpful when creating a menu for specific
operators, for example.
In the following example, using the CLI Scripting built-in variables, and, specifically, $CLI.USER, returns
the user of the current session. There are many built-in variables available. Refer the EXOS User Guide,
in the CLI Scripting chapter, for more information.
sw1.1 # vi exshrc.xsf
enable cli scripting
IF (!$MATCH($CLI.USER,admin)) THEN
create log message "User Admin just connected!"
ENDIF
disable cli scripting
sw1.2 #
If you disconnect from the switch then reconnect as admin, you see the following: