SHARE
TWEET

Untitled

a guest Jul 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from netmiko import ConnectHandler
  2. from getpass import getpass
  3.  
  4. class Device:
  5.     def __init__(self, credentials):
  6.         self.device = {
  7.             'device_type': 'cisco_asa',
  8.             'ip': credentials["ip"],
  9.             'username': credentials["username"],
  10.             'password': credentials["password"],
  11.             'secret': credentials["secret"],
  12.         }
  13.         self.config = credentials["config"]
  14.     def update(self):
  15.         net_connect = Netmiko(**self.device)
  16.         output = net_connect.send_config_from_file(self.config)
  17.         return(output)
  18.  
  19. routers = [{"ip":"10.1.1.1","credentials":"/credentialsfile.txt","config":"configfile.txt"},{"ip":"10.1.1.2","credentials":"/credentialsfile2.txt","config":"configfile2.txt"}]
  20.  
  21. for router in routers:
  22.     rt = Device(router)
  23.     update = rt.update()
  24.     print(update)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top