Dev: Automating network using restconf

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)

No alt text provided for this image

# create the loopback

No alt text provided for this image

# assign the ip address

No alt text provided for this image

# configure the eigrp

No alt text provided for this image
No alt text provided for this image

# at the end call all the functions.

No alt text provided for this image

# this will be the result

No alt text provided for this image

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

No alt text provided for this image


要查看或添加评论,请登录

社区洞察

其他会员也浏览了