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 | 46
Part no.9036931-00 Rev AA February 2021
if args.username is None:
# prompt for username
args.username = input('Enter remote system username: ')
# also get password
args.password = getpass.getpass('Remote system password: ')
# open a restconf session
rest = Restconf(args.ip, args.username, args.password)
# you list the existing vlans prior adding one
list_vlans(rest)
# you prepare the data to send
url = "data/openconfig-vlan:vlans/"
data = {}
vlan = {}
vlan["config"] = {"name": "H2G2", "status": "ACTIVE", "tpid": "oc-vlan-
types:TPID_0x8100", "vlan-id": 42}
data["openconfig-vlan:vlans"] = [vlan]
# you make a POST API call
r = rest.post(url, data)
# you list the existing vlans after adding one to check
print("-"*42)
list_vlans(rest)
# you delete it now
del_url = url + "vlan=42"
rest.delete(del_url)
# you list the existing vlans after to check again
print("-"*42)
list_vlans(rest)
main()










