The EEM Python package exposes the interfaces for executing EEM actions. You can use the Python script to call these actions, and they are forwarded from the Python package via Cisco Plug N Play (PnP) to the action handler. EEM Variables An EEM policy can have the following types of variables: • Event-specific built-in variables—A set of predefinied variables that are populated with details about the event that triggered the policy. The eem_event_reqinfo () API returns the builtin variables list. These variables can be stored in the local machine and used as local variables. Changes to local variables do not reflect in builtin variables.
• User-defined variables—Variables that can be defined and used in policies. The value of these variables can be referred in the Python script. While executing the script, ensure that the latest value of the variable is available. The eem_user_variables() API returns the current value of the argument that is provided in the API. EEM CLI Library Command Extensions The following CLI library commands are available within EEM for the Python script to work: • eem_cli_close()—Closes the EXEC process and releases the VTY and the specified channel handler connected to the command. • eem_cli_exec—Writes the command to the specified channel handler to execute the command.
Then reads the output of the command from the channel and returns the output. • eem_cli_open—Allocates a VTY, creates an EXEC CLI session, and connects the VTY to a channel handler. Returns an array including the channel handler. • eem_cli_read()—Reads the command output from the specified CLI channel handler until the pattern of the device prompt occurs in the contents read. Returns all the contents read up to the match. • eem_cli_read_line()—Reads one line of the command output from the specified CLI channel handler. Returns the line read.
• eem_cli_read_pattern()—Reads the command output from the specified CLI channel handler until the pattern that is to be matched occurs in the contents read. Returns all the contents read up to the match. • eem_cli_run()—Iterates over the items in the clist and assumes that each one is a command to be executed in the enable mode. On success, returns the output of all executed commands and on failure, returns error. • eem_cli_run_interactive()—Provides a sublist to the clist which has three items. On success, returns the output of all executed commands and on failure, returns the error.
Also uses arrays when possible as a way of making things easier to read later by keeping expect and reply separated. • eem_cli_write()—Writes the command that is to be executed to the specified CLI channel handler. The CLI channel handler executes the command. Shells and Scripting EEM Variables Programmability Configuration Guide, Cisco IOS XE 17.16.x 145