Skip to content

Instantly share code, notes, and snippets.

View twr14152's full-sized avatar

Todd Riemenschneider twr14152

  • Columbus, Ohio
View GitHub Profile
@twr14152
twr14152 / config_file.py
Last active December 31, 2022 19:08
python ssh script to automate gathering info and pushing configs to Cisco routers and switches
host_conf = ['show ip arp vlan 11', 'show ip arp vlan 12', 'show ip arp vlan 13', 'show ip arp vlan 32', 'show ip arp vlan 50', 'show ip arp vlan 102', 'show ip arp vlan 112', 'show ip arp vlan 145', 'show ip arp vlan 150', 'show ip arp vlan 155', 'show ip arp vlan 160', 'show ip arp vlan 161', 'show ip arp vlan 171', 'show ip arp vlan 172', 'show ip arp vlan 327', 'show ip arp vlan 328', 'show ip arp vlan 331', 'show ip arp vlan 332', 'show ip arp vlan 374', 'show ip arp vlan 380', 'show ip arp vlan 401', 'show ip arp vlan 409', 'show ip arp vlan 433', 'show ip arp vlan 434', 'show ip arp vlan 435', 'show ip arp vlan 436', 'show ip arp vlan 334', 'show ip arp vlan 343', 'show ip arp vlan 403', 'show ip arp vlan 404', 'show ip arp vlan 406', 'show ip arp vlan 447','exit']
# To implement config changes your config would be implemented in list format
# host_conf = ['config t', 'interface lo10', 'description TEST-CONFIG-SCRIPT-3', 'end', 'show run int loop 10']
@twr14152
twr14152 / host_config_file.py
Last active August 22, 2021 12:47
Using Python to script the configuration of Cisco devices
#
#
# add your configurations in a list format
#
host_conf = ['config t', 'interface lo10', 'description TEST-CONFIG-SCRIPT-3', 'end', 'show run int loop 10']
@twr14152
twr14152 / sample_playbook
Last active May 1, 2021 12:41
sample_playbook_example
- name: configure cisco routers
hosts: routers
connection: ansible.netcommon.network_cli
gather_facts: no
@twr14152
twr14152 / gross_pay_calc.py
Last active January 15, 2021 18:40
gross_pay_calc.py
#wage
name1_wage = <>
name2_wage = <>
name3_wage = <>
name4_wage = <>
#overtime wage
name1_ot = (name1_wage/2) + name1_wage
name2_ot = (name2_wage/2) + name2_wage
name3_ot = (name3_wage/2) + name3_wage
@twr14152
twr14152 / ios_config_script_07292020.py
Created July 29, 2020 23:04
requested_ios_config_script_07292020
#!/usr/bin/python3
#(c) 2020 Todd Riemenschneider
#
#Enable Multiprocessing
from multiprocessing import Pool
#getpass will not display password
from getpass import getpass
#ConnectionHandler is the function used by netmiko to connect to devices
from netmiko import ConnectHandler
#Time tracker
@twr14152
twr14152 / print_2_file.py
Last active November 8, 2020 15:43
Write to file using print
#Trying to understand the benefit of this method of writing to a file...
def main():
fname = input("Enter filename: ")
dfname = input("Destination Filename: ")
infile = open(fname, "r")
outfile = open(dfname, "a")
data = infile.read()
print(data)
infile.close()
@twr14152
twr14152 / write_2_file.py
Created November 8, 2020 15:42
Writing to file
#Comparing write method to print method to writing to file.
def main():
fname = input("Enter filename: ")
dfname = input("Destination Filename: ")
infile = open(fname, "r")
with open(dfname, "a") as f:
data = infile.read()
infile.close()
@twr14152
twr14152 / kw_count.py
Last active November 5, 2020 19:20
Python Keyword count
import keyword
def kw_count():
a = 0
for kw in keyword.kwlist:
a+=1
print(f"{a} ", kw)
kw_count()
@twr14152
twr14152 / pushupCounter.go
Created April 5, 2020 14:46
Pushup Counter workout routine
/*
Specify a number of pushups you want to do in a set.
Every 30 secs do another set - 1 rep. Repeat until you reach 0.
This program will calculate how many pushups you do in total
*/
package main
import (
"fmt"
@twr14152
twr14152 / findingDupIPs.py
Created February 15, 2020 21:12
Finding duplicate IPs in a souce list
#sample Source List
ip_address = ["10.0.0.1", "10.0.0.1", "10.0.0.2", "12.0.3.1", "10.9.0.1", "12.0.1.1", "10.0.0.2"]
ip_counts = {ip: ip_address.count(ip) for ip in set(ip_address)}
for ip, count in ip_counts.items():
if count > 1:
print(f"Dup IP:{ip} number of dup hosts {count}")
else:
continue