-
-
Save tundragon/afce1dd2387f9cfc3e4469ca18efacb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import json | |
| from pprint import pprint | |
| from dotenv import load_dotenv, find_dotenv | |
| import os | |
| load_dotenv(find_dotenv()) | |
| CISCOU = os.environ.get("CISCOU") | |
| CISCOP = os.environ.get("CISCOP") | |
| device = { | |
| "ip": "10.1.1.103", | |
| "username": CISCOU, | |
| "password": CISCOP, | |
| "port": "443", | |
| } | |
| headers = { | |
| "Accept" : "application/yang-data+json", | |
| "Content-Type" : "application/yang-data+json", | |
| } | |
| payload = { | |
| "ietf-interfaces:interface": [ | |
| { | |
| "name": "gi3", | |
| "description": "HELLO" | |
| } | |
| ] | |
| } | |
| # retreive all details | |
| url = f"https://{device['ip']}/restconf/data/ietf-interfaces:interfaces/interface" | |
| print(url) | |
| requests.packages.urllib3.disable_warnings() | |
| response = requests.patch(url, | |
| headers=headers, | |
| data=json.dumps(payload), | |
| auth=(device['username'], | |
| device['password']), | |
| verify=False) | |
| print(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment