User guide
Web Services, CLI Scripting and OpenFlow Embedded Python Scripting
OmniSwitch AOS Release 7 Switch Management Guide March 2015 page 11-25
Embedded Python Scripting
The OmniSwitch includes many standard Python packages to access AOS and system functions. This
feature allows administrators to create Python scripts and associate these scripts with specific traps. When
the traps are generated by the switch, the pre-configured scripts will be run on the switch. This provides
the capability to adapt to a dynamically changing network and customize how the switch should react to
those changes. There are multiple ways to execute Python on the switch:
• Automatically, as an event-action when a trap occurs
• Interactively, from the console
• In a script file executed by command from the console
AOS Python includes many standard Python packages for:
• OS access and issuing AOS commands
• Sending email and database access.
Guidelines
• Scripts can only be created by administrators with write privileges to the partition management family
AAA.
• Event-based scripts must be stored in the /flash/python directory.
• The show snmp-trap config command can be used to see list of traps on the switch.
• An event can have only one script assigned to it, but a script can be assigned to multiple events.
Assigning Events
To assign a switch event to a script use the event-action command, for example:
-> event-action trap linkDown script /flash/python/link_event.py
-> event-action trap stpNewRoot script stp_event.py
View the Events
To view statistics such as how many times a script has been run use the show event-action command, for
example:
-> show event-action
type name script (/flash/python/…)
------+ ---------------------------------+------------------------------
trap linkDown link_event.py
trap stpNewRoot stp_event.py
trap sessionAuthenticationTrap catchAll.py
Note: Use the
interfaces link-trap command to enable traps for link up/down events