Dev: Automating network using restconf
Hi there, in previous post we saw how to automate your network by making rest api calls using postman. In this post, we're going to see to how make rest api calls using python.
To make rest api calls, we must have the same components we used in postman:
- url
- authentication
- payload
I structured the code into functions for easy perception. We'll follow the same flow:
- create the loopback interface
- assign IP address to LAN interface
- enable eigrp
# import the following classes
import requests
from requests.auth import HTTPBasicAuth
# Disable SSL verification warning because of private SSL certificate
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# create the loopback
# assign the ip address
# configure the eigrp
# at the end call all the functions.
# this will be the result
I hope you enjoyed this post, leave your comments below and I'll see you on the next one.
Bonus: When interacting with postman, you can get the equivalent code for python by looking at Code > Python - Requests