Skip to content

Commit b81825d

Browse files
committed
remove Ip address using Delete operation
1 parent 4ceab3c commit b81825d

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

RESTCONF/delete-Ip-address.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright (c) 2018 Krishna Kotha <[email protected]>
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions
8+
# are met:
9+
# 1. Redistributions of source code must retain the above copyright
10+
# notice, this list of conditions and the following disclaimer.
11+
# 2. Redistributions in binary form must reproduce the above copyright
12+
# notice, this list of conditions and the following disclaimer in the
13+
# documentation and/or other materials provided with the distribution.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25+
# SUCH DAMAGE.
26+
#
27+
# This script deletes the Ip address of a interface using DELETE operation via RESTCONF
28+
29+
# import the requests library
30+
import requests
31+
import sys
32+
33+
# disable warnings from SSL/TLS certificates
34+
requests.packages.urllib3.disable_warnings()
35+
36+
# use the IP address or hostname of your Cat9300
37+
HOST = '172.26.198.63'
38+
39+
# use your user credentials to access the Cat9300
40+
USER = 'cisco'
41+
PASS = 'cisco'
42+
43+
44+
# create a main() method
45+
def main():
46+
"""Main method that configures the Ip address for a interface via RESTCONF."""
47+
48+
# url string to issue GET request
49+
url = "https://172.26.198.63/restconf/data/Cisco-IOS-XE-native:native/interface/TenGigabitEthernet=1%2F0%2F10/ip/address/primary"
50+
51+
# RESTCONF media types for REST API headers
52+
headers = {'Content-Type': 'application/yang-data+json',
53+
'Accept': 'application/yang-data+json'}
54+
# this statement performs a GET on the specified url
55+
response = requests.request("DELETE",url, auth=(USER, PASS),
56+
headers=headers, verify=False)
57+
# print the json that is returned
58+
print(response.text)
59+
60+
if __name__ == '__main__':
61+
sys.exit(main())

0 commit comments

Comments
 (0)