def inventory_dispatcher():
 DEBUG = True
 class_mapper = {'cisco_ios_ssh': CiscoGatherInventory, 'arista_eos_ssh': AristaGatherInventory}
 net_devices = NetworkDevice.objects.all()
 for a_device in net_devices:
  if ('ssh' in a_device.device_class):
   if DEBUG:
    print 'SSH inventory call: {} {}\n'.format(a_device.device_name, a_device.device_class)
   ssh_connect = SSHConnection(a_device)
   output = ssh_connect.send_command('show version\n')
   inventory_obj = class_mapper[a_device.device_class](a_device, output)
   inventory_obj.find_vendor()
   inventory_obj.find_model()
   inventory_obj.find_device_type()
   inventory_obj.find_os_version()
   inventory_obj.find_serial_number()
   inventory_obj.find_uptime()
   print 'Inventory gathering for device complete'
   print_inventory(a_device)
  elif ('onepk' in a_device.device_class):
   if DEBUG:
    print 'onePK inventory call: {} {}\n'.format(a_device.device_name, a_device.device_class)
   pass
  elif ('eapi' in a_device.device_class):
   if DEBUG:
    print 'eAPI inventory call: {} {}\n'.format(a_device.device_name, a_device.device_class)
   pass
  else:
   pass

def inventory_dispatcher ( ) : DEBUG = True class_mapper = { 'cisco_ios_ssh' : CiscoGatherInventory , 'arista_eos_ssh' : AristaGatherInventory } net_devices = NetworkDevice . objects . all ( ) for a_device in net_devices : if ( 'ssh' in a_device . device_class ) : if DEBUG : print 'SSH inventory call: {} {}\n' . format ( a_device . device_name , a_device . device_class ) ssh_connect = SSHConnection ( a_device ) output = ssh_connect . send_command ( 'show version\n' ) inventory_obj = class_mapper [ a_device . device_class ] ( a_device , output ) inventory_obj . find_vendor ( ) inventory_obj . find_model ( ) inventory_obj . find_device_type ( ) inventory_obj . find_os_version ( ) inventory_obj . find_serial_number ( ) inventory_obj . find_uptime ( ) print 'Inventory gathering for device complete' print_inventory ( a_device ) elif ( 'onepk' in a_device . device_class ) : if DEBUG : print 'onePK inventory call: {} {}\n' . format ( a_device . device_name , a_device . device_class ) pass elif ( 'eapi' in a_device . device_class ) : if DEBUG : print 'eAPI inventory call: {} {}\n' . format ( a_device . device_name , a_device . device_class ) pass else : pass
dispatcher for calling ssh .