Skip to content

Commit f414e9c

Browse files
committed
delete loopback script
1 parent 3c507aa commit f414e9c

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#! /usr/bin/env python
2+
"""Sample use of the netmiko library for CLI interfacing
3+
4+
This script will delete configuration on a device.
5+
6+
Copyright (c) 2018 Cisco and/or its affiliates.
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in all
16+
copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
SOFTWARE.
25+
"""
26+
27+
# Import libraries
28+
from netmiko import ConnectHandler
29+
30+
from device_info import ios_xe1 as device # noqa
31+
32+
# New Loopback Details
33+
loopback = {"int_name": "Loopback103"}
34+
35+
# Create a CLI configuration
36+
interface_config = [
37+
"no interface {}".format(loopback["int_name"])
38+
]
39+
40+
# Open CLI connection to device
41+
with ConnectHandler(ip = device["address"],
42+
port = device["ssh_port"],
43+
username = device["username"],
44+
password = device["password"],
45+
device_type = device["device_type"]) as ch:
46+
47+
# Send configuration to device
48+
output = ch.send_config_set(interface_config)
49+
50+
# Print the raw command output to the screen
51+
print("The following configuration was sent: ")
52+
print(output)

0 commit comments

Comments
 (0)