Extreme API with Python
Table Of Contents
- 1 Preface
- 2 Introduction
- 3 EXOS APIs
- 4 VOSS API
- 5 XMC API
- 6 ExtremeCloud IQ API
- 7 Extreme Campus Controller API
Extreme API with Python
Page | 30
Part no.9036931-00 Rev AA February 2021
3.1.1.3 Execute a Python Script
There are two CLI commands you can use to execute an existing Python script from the CLI:
-
run script <script_name>.py
- load script <script_name>.py
The first command was introduced specifically for executing Python script. The second one is the legacy
command, used for CLI Scripting.
3.1.1.4 EXOS CLI Module
You can use an EXOS module called exsh to execute a Python script on EXOS. This module allows you to
execute any CLI command and returns the output either as a string, XML, both, or none.
exsh.clicmd(cmd, capture=False, xml=False, args=None)
Parameters:
- cmd: a string containing any valid EXOS CLI command.
- capture: a Boolean, defaulting to False if not specified, returning as a text (string) the CLI
output of the command.
- xml: a Boolean, defaulting to False if not specified, returning the XML that EXOS used to
create the CLI output
- args: a string to provide additional input to some EXOS commands that prompt for more
information
Returns:
- None: if both capture and xml are False
- Captured text: if capture is True
- XML: if xml is True
- Captured text and xml: if both capture and xml are True
Raises:
- RuntimeError: EXOS command is invalid or encountered an error
When you work with JSON data, you can be tempted to use the embedded cli2json.py script.
Calling a script from another script is not supported, as each script has its own session.
This is an example of a simple script:
import exsh
for vid in range(10, 15):
exsh.clicmd("create vlan {}".format(vid))
The result:










