Skip to content

Commit 4b064d6

Browse files
committed
New shut un unsed interface
1 parent 4923850 commit 4b064d6

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

shut_nonused_interfaces/shut_port.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Shut all un-used interface, where the out_pkts is 0.
2+
# Example testbed file provided
3+
4+
from genie.testbed import load
5+
tb = load('testbed.yaml')
6+
dev = tb.devices['csr1000v-1']
7+
dev.connect()
8+
x = dev.parse('show interfaces')
9+
10+
for interface, interface_data in x.items():
11+
if 'counters' in interface_data:
12+
if 'out_pkts' in interface_data['counters']:
13+
if x[interface]['counters']['out_pkts'] == 0 :
14+
dev.configure('int {}\n shutdown'.format(interface))

shut_nonused_interfaces/testbed.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
devices:
2+
csr1000v-1:
3+
alias: csr1000v-1
4+
connections:
5+
ssh:
6+
ip: 172.16.21.88
7+
protocol: ssh
8+
proxy: jump_host
9+
credentials:
10+
default:
11+
password: cisco
12+
username: cisco
13+
enable:
14+
password: cisco
15+
custom:
16+
abstraction:
17+
order:
18+
- os
19+
- platform
20+
os: iosxe
21+
platform: iosxe
22+
type: CSR1000v
23+
24+
jump_host:
25+
connections:
26+
cli:
27+
ip: 172.25.192.134
28+
port: 22
29+
protocol: ssh
30+
credentials:
31+
default:
32+
password: VIRL
33+
username: virl
34+
os: linux
35+
type: linux

0 commit comments

Comments
 (0)