Guidelines for writing Python scripts

  • Although previous experience programming in Python is helpful, experience in other high-level languages is enough to get you started with simple Python scripts.
  • The Python developer either needs experience with SLX-OS CLI or access to a resource with such experience.
  • To help decide which editor or integrated development environment (IDE) to use, refer to http://www.python.org.
  • Make sure that the appropriate version of the Python interpreter is installed on your development computer. For the current version of SLX-OS, install Python 3.5.2.
  • Make sure that in the Extreme SLX-OS Command Reference you are familiar with the python and the CLI( ) topics.
  • The script must include from CLI import CLI. This enables the CLI( ) command, by which Python can interact with SLX-OS.
  • Write the Python script and save it, with a .py suffix. Valid filenames range from 4 through 32 characters (including the suffix). The first character must be alphabetic.

Guidelines for RASLOG event-handler scripts

The additional guidelines for writing RASLOG event-handler scripts are as follows:
  • The script must include import json.
  • If an event-handler detects the log messages specified in the triggers and the trigger-function conditions are met, the script is executed. As part of this execution, the script is passed a --raslog-triggers argument with JSON-formatted dictionary containing the relevant message identifiers (MSGID) as keys and the message text as values.
  • If the trigger-function is OR, only a single MSGID and message text are present.
  • If the trigger function is AND, all relevant MSGIDs and messages are passed inside the json data structure.
Note

Note

For sample scripts, refer to Python scripts and run-logs.