create_static.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:restconf-examples 作者: CiscoDevNet 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号