Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 41
Part no.9036931-00 Rev AA February 2021
3.2.1 RESTCONF API
The latest API introduced with EXOS is the RESTConf, which follows the Openconfig model and works in
conjunction with the Python module restconf.pyz. This module is available on Extreme Networks github:
HTTPS://github.com/extremenetworks/EXOS_Apps/tree/master/REST
Note: The RESTConf module is bundled in EXOS since release 22.4, but is backward compatible with EXOS
22.1, by adding the restconf.pyz module to the system.
3.2.1.1 RESTCONF Documentation
The documentation is accessible either from the Extreme Networks documentation site, or directly from
a switch running the minimal version required (the EXOS web server must be enabled).
The link to the documentation on Extreme Networks site is:
http://api.extremenetworks.com/EXOS/ProgramInterfaces/RESTCONF/RESTCONF.html
To access the documentation directly from a switch (or VM):
http(s)://<switch IP>/apps/restconfdoc
3.2.1.2 Working with EXOS RESTCONF
This section describes some examples using Python 3 to work with EXOS switches. To facilitate the use
of RESTCONF CALLs, Extreme Networks offers a Python class the teaches you how to create the CALLs.
The Python class is available on github:
HTTPS://github.com/extremenetworks/EXOS_Apps/blob/master/REST/examples/restconf.py
Note: The restconf python class is included by default with XMC Python Engine since XMC 8.2. The latest
version of the classv1.2.0.0 at the time of writing - should be part of XMC 8.5.
3.2.1.3 How to Access Restconf
EXOS Restconf supports GET, POST, PUT, PATCH and DELETE HTTP methods.
You must authenticate to access the API. By default, basic authentication using a login and password is
available. When the session is successfully authenticated, a token is generated. This token allows you to
make multiple API CALLs without the need to reauthenticate, as long as the token is included as a cookie
in the request header.
Note: The duration of the token is set to 86400 seconds, which is 1 day.
EXOS Restconf implementation supports both HTTP and HTTPS protocols. By default, out-of-the-box,
EXOS switches only have HTTP enabled. The Python class restconf.py tries both protocols, starting with
HTTPS. However, the best practice is to use HTTPS for data integrity and confidentiality.