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 | 39
Part no.9036931-00 Rev AA February 2021
Raises:
- CLICommandError(error_msg, cmd): A CLI command returned an error message. The error_msg
attribute is the message received from the CLI and cmd is the command that was being run at
the time
- CLITimeoutError: A CLI request timed out
Note: You are presenting the synchronous CALL in this example, but asynchronous CALLs exist as well.
Enhance your previous example by creating or deleting a VLAN is on the switch:
from exos import api
import exos.api.throwapi as throwapi
import sys
import logging
logger = logging.getLogger('test')
logger.setLevel(logging.DEBUG)
logHandler = api.TraceBufferHandler("testbuf", 20480)
logHandler.setLevel(logging.DEBUG)
logHandler.setFormatter(logging.Formatter("%(levelname)s:%(name)s:%(funcName)s.%(
lineno)s:: %(message)s"))
logger.addHandler(logHandler)
def event_cb(event, subs):
meta = event.get('meta')
data = event.get('data')
# Here are some CLI commands based on VLAN events
if meta.get('action') == 'create':
api.exec_cli(['config vlan {} description "This is a description for VLAN
{}"'.format(data.get('vlan_name'), data.get('vlan_name'))])
elif meta.get('action') == 'delete':
api.exec_cli(['create log message "Ohoh! VLAN {} has been deleted"'.forma
t(data.get('vlan_name'))])
def main():
# Verify you are running under EXPY. You can't live without it.
if not hasattr(sys, 'expy') or not sys.expy:
print "Must be run within EXPY"
return










