Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 44
Part no.9036931-00 Rev AA February 2021
# you make a GET API call for all the vlans
info = rest.get('data/openconfig-vlan:vlans')
data = info.json()
vlans = data.get('openconfig-vlan:vlans').get('vlan')
for vlan in vlans:
print("Found VLAN {} with VID {}".format(vlan.get('state').get('name'), v
lan.get('vlan-id')))
main()
As a result, you can see all existing VLANs on the switch:
C:\Extreme API with Python> rest_example.py -i 192.168.56.121 -u admin
Found VLAN Default with VID 1
Found VLAN VLAN_0054 with VID 54
Found VLAN interco with VID 4094
Locating existing VLANs is easy, as it was just a CALL to the root of the VLANs datastore. For
demonstration purposes, you can enhance this example to create a new VLAN and delete an existing
one. To modify the configuration, you must understand the YANG model, used in Openconfig.
Refer to the Restconf documentation, or do a GET (using postman for example) you will see the
following information about VLANs:
{
"openconfig-vlan:vlans": {
"vlan": [
{
"vlan-id": "1",
"state": {
"status": "ACTIVE",
"vlan-id": 1,
"name": "Default",
"tpid": "oc-vlan-types:TPID_0x8100"
},
"config": {
"status": "ACTIVE",
"vlan-id": 1,
"name": "Default",
"tpid": "oc-vlan-types:TPID_0x8100"
}
},
[…]
}