Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import getpass
- from netmiko import ConnectHandler
- from datetime import datetime
- # Get credentials
- username = raw_input("Username: ")
- password = getpass.getpass("User Password: ")
- asa_secret = getpass.getpass("ASA Secret Password: ")
- # Credential hash table for copying to device tables
- credentials = {
- 'username': username,
- 'password': password,
- }
- # Device hash tables
- its_asa = {
- 'device_type': 'cisco_asa',
- 'ip': '172.16.10.1',
- 'secret': asa_secret,
- }
- # List to include all devices controlled by this script
- all_devices = [its_asa]
- # This loop will add the entered credentials to everything in the
- # 'all_devices' list
- for a_device in all_devices:
- a_device.update(credentials)
- # Loop that executes command(s) on several devices
- start_time = datetime.now()
- for a_device in all_devices:
- ios_connect = ConnectHandler(**a_device)
- output = ios_connect.send_command("show version")
- print "\n\n-----> Device {0} <-----".format(a_device['device_type'])
- print output
- print "\n\n-----> END <-----"
- end_time = datetime.now()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement