Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 63
Part no.9036931-00 Rev AA February 2021
Because the emc_cli object connects to the device using either Telnet or SSH, any device from any
vendor is accessible, however login banners and sub-prompts can vary from one vendor to another.
XMC has a list of CLI rules to access the device.
Starting with XMC 8.1.2, you can customize the CLI rules or the regular expressions for prompt
detection, by creating a file named myCLIRules.xml, located in the same directory as the
CLIRules.xml file (names are case-sensitive).
/usr/local/Extreme_Networks/NetSight/appdata/scripting/
This file should be divided into sections containing regular expressions per vendor, in a similar fashion to
that of the CLIRules.xml file. Typically, BOSS and VOSS access also uses this file.
Note: CLI scripting for BOSS and VOSS is very inconsistent. Devices have a variety of different login
banners and subprompts. Make sure that the CLI profile for a device is correct, as emc_cli relies on the
CLI profile that is set for that device. By default, emc_cli will try to use the regular expressions defined in
CLIRules.xml under the "Avaya" section, but because not all commands and prompts have been
added. As a result, this might be the reason the script fails even if your CLI profile is correct.
When you create the myCLIRules.xml file, the following logic applies when XMC tries to connect to
a device:
- Checks if myCLIRules.xml exists. If it does, use the cliRule name in it.
- Checks if cliRule name exists in CLIRules.xml, if yes use this one.
- Finally, use the default rule name of “*”
The cliRule name normally comes from the device vendor profile. Each device (family, subfamily or
device type) should have a property called cliRuleFileName (this name is misleading, it is really the
cliRuleName, not a file name).
Note: To set the cliRuleName dynamically from Python, invoke emc_cli.setCliRule.
For example:
# must be called before using emc_cli.send
emc_cli.setCliRule("ruleName")
The CLI output returned by emc_cli.send() is a string that contains the CLI command used (first
line).
Note: For XMC 8.0.4 up to XMC 8.1.1, the string returned also included the trailing CLI prompt. XMC 8.1.2
removed it, and XMC 8.1.3 brought it back. You may need to update existing Python scripts.
One way to remove extra lines, which is especially important if you are waiting for JSON-formatted
output, is shown here:
import re
RegexPrompt = re.compile('.*[\?\$%#>]\s?$')