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 | 68
Part no.9036931-00 Rev AA February 2021
if int(emc_vars["bvlan1"]) > 4094 or int(emc_vars["bvlan1"]) < 2:
raise RuntimeError('BVLAN 1 Id is out of range')
if int(emc_vars["bvlan2"]) > 4094 or int(emc_vars["bvlan2"]) < 2:
raise RuntimeError('BVLAN 2 Id is out of range')
if int(emc_vars["bvlan1"]) == int(emc_vars["bvlan2"]):
raise RuntimeError('Error: BVLAN 1 Id is identical than BVLAN 2 Id')
Writing a script from XMC is simple. The following example validates BGP information on an EXOS
switch, using Restconf:
from restconf import Restconf
if emc_vars['family'] != 'Summit Series':
print 'Must be run on EXOS'
exit(0)
r = Restconf(emc_vars['deviceIP'], emc_vars['deviceLogin'], emc_vars['devicePwd'])
data = r.get('data/openconfig-bgp:bgp/neighbors')
bgp_data = data.json()
if bgp_data:
bgp = bgp_data.get('openconfig-bgp:neighbors').get('neighbor')
print 'Found {} BGP neigbhors'.format(len(bgp))
for neighbor in bgp:
print 'Received {} prefixes from {} in ASN {}'.format(
neighbor['afi-safis']['afi-safi'][0]['state']['prefixes'].get('received'),
neighbor['neighbor-address'],
neighbor['state'].get('peer-as'))
When you run the script against a BGP router, you will see a result similar to:
Script Name: BGP Test
Date and Time: 2020-06-21T02:20:34.617
XMC User: root
XMC User Domain:
IP: 192.168.56.121
Found 1 BGP neighbors
Received 3 prefixes from 10.0.0.1 in ASN 65002










