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 | 64
Part no.9036931-00 Rev AA February 2021
# Remove echoed command and final prompt from output
def cleanOutput(outputStr):
lastLine = outputStr.splitlines()[-1:][0]
if RegexPrompt.match(lastLine):
lines = outputStr.splitlines()[1:-1]
else:
lines = outputStr.splitlines()[1:]
return '\n'.join(lines)
5.1.6.3 Additional emc_cli Methods
This section has covered the most common method used for the emc_cli Python object. However, there
are several other methods that can be useful. Examples of these are shown below.
You can list all the functions and methods provided with this object using a very basic Python code. The
output with XMC 8.4.4 is shown below.
print dir(emc_cli)
The result:
['SSHEnabled', '__class__', '__copy__', '__deepcopy__', '__delattr__',
'__doc__', '__ensure_finalizer__', '__eq__', '__format__',
'__getattribute__', '__hash__', '__init__', '__ne__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
'__subclasshook__', '__unicode__', 'class', 'cliRule', 'cliRuleObject',
'close', 'commandPrompt', 'commandReply', 'commandTimeout',
'commandTimeoutInMillis', 'connect', 'connected', 'equals', 'errorMessage',
'getClass', 'getCliRule', 'getCliRuleObject', 'getCommandPrompt',
'getCommandReply', 'getCommandTimeout', 'getIpAddress', 'getMaxCliOut',
'getPasswd', 'getPort', 'getSSHEnabled', 'getSaveCommand',
'getSessionTimeout', 'getShellPrompt', 'getUser', 'getVendor', 'hashCode',
'ipAddress', 'isConnected', 'logDebugMessage', 'logErrorMessage',
'logMessage', 'maxCliOut', 'notify', 'notifyAll', 'passwd', 'port', 'read',
'saveCommand', 'send', 'sessionTimeout', 'setCliRule', 'setCommandPrompt',
'setCommandReply', 'setCommandTimeout', 'setCommandTimeoutInMillis',
'setErrorMessage', 'setIpAddress', 'setMaxCliOut', 'setPasswd', 'setPort',
'setSSHEnabled', 'setSaveCommand', 'setSessionTimeout', 'setShellPrompt',
'setUser', 'setVendor', 'shellPrompt', 'toString', 'user', 'vendor', 'wait']
You can also find many set methods to use with emc_cli, for example, the session timeout.
# set the session timeout to 80 seconds
emc_cli.setSessionTimeout(80)










