def create_static(host, port, user, password, route, nexthop, insecure):
"""Function to create a static route on CSR1000V."""
url = "https://{h}:{p}/api/running/native/ip/route".format(h=HOST, p=PORT)
headers = {'content-type': 'application/vnd.yang.data+json',
'accept': 'application/vnd.yang.data+json'}
try:
result = requests.patch(url, auth=(USER, PASS), data=data,
headers=headers, verify=not insecure)
except Exception:
print(str(sys.exc_info()[0]))
return -1
return result.text
if result.status_code == 201:
return 0
# somethine went wrong
print(result.status_code, result.text)
return -1
评论列表
文章目录