Interaction with vManage API
5.3.a i Python requests library and Postman
General information on “vManage Python requests library or Postman”:
- Possible HTTP operations:
- GET: Retrieve/Read information.
- PUT: Update an object.
- POST: Create an object.
- DELETE: Remove an object.
- The API documentation can be found on the vManage server at https://vmanage-ipaddr:port/apidocs
- vManage requires authentication before further requests can be made
- Therefore it’s required to instantiate a TCP session via requests.session() which will first be used for the authentication and afterwards for every REST API call
Basic vManage authentication + GET via Python w/ requests library (example):
## MODULE IMPORT
import requests
import json
## AUTHENTICATION @ VMANAGE
def vmanage_authentication(session):
sdwan_authentication_url = 'https://sandboxsdwan.cisco.com:8443/j_security_check'
sdwan_authentication_cred = {'j_username':'devnetuser', 'j_password':'Cisco123!'}
sdwan_authentication = session.post(url = sdwan_authentication_url,
data = sdwan_authentication_cred,
verify=False)
return sdwan_authentication
## GET DEVICES @ VMANAGE
def vmanage_get_devices(session):
sdwan_get_devices_url = 'https://sandboxsdwan.cisco.com:8443/dataservice/device'
sdwan_get_devices_raw = session.get(url = sdwan_get_devices_url,
verify=False)
sdwan_get_devices = json.dumps(json.loads(sdwan_get_devices_raw.content), indent=4)
return sdwan_get_devices
## MAIN PROGRAM
## INSTANTIATE VMANAGE SESSION
vmanage_session_instance = requests.session()
## AUTHENTICATION @ VMANAGE via FUNCTION
vmanage_authentication = vmanage_authentication(vmanage_session_instance)
## GET DEVICES @ VMANAGE via FUNCTION
vmanage_get_devices = vmanage_get_devices(vmanage_session_instance)
## PRINTING RESULT of GET DEVICES
for device in vmanage_get_devices['data']:
print(device['host-name'], device['local-system-ip'], device['uuid'])
5.3.a ii Monitoring endpoints
General information on “vManage Monitoring endpoints”:
- MONITORING is a resource collection of the VIPTELA REST API
- Provides resources for viewing status, statistics and other information about operational devices in the overlay network
- VIPTELA devices collect information about themselves every 10 minutes, places them in a ZIP file and pushes it to the vManage server
5.3.a iii Configuration endpoints
General information on “vManage Configuration endpoints”:
- CONFIGURATION is a resource collection of the VIPTELA REST API
- Provides resources for creating feature and device configuration templates, retrieving configuration of existing templates and creating and configuring vManage clusters