Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. json-1 = {
  2. "channel": "scanner",
  3. "action": "create_device",
  4. "table": "U2",
  5. "device":[]
  6. }
  7. data = "device_name","ip_address","lldp_neighbors"
  8.  
  9. my[data[0]] = connection.find_prompt().rstrip('>') #to get hostname
  10. my[data[1]] = device['ip'] #to get ip address
  11. my[data[2]] = connection.send_command('show lldp neighbors | display xml')
  12. #to get lldp data in xml format
  13.  
  14. json1["device"].append(my) #append my data to device
  15.  
  16. "lldp_neighbors": [
  17. {
  18. "local-port": "xe-3/0/4.0",
  19. "parent-interface": "ae31.0",
  20. "chassis-id": "b0:c6:9a:63:80:40",
  21. "port-info": "xe-0/0/0/0.0",
  22. "system-name": "host.jnpr.net"
  23.  
  24. {
  25. "channel": "scanner",
  26. "action": "create_device",
  27. "table": "U2",
  28. "device": [
  29. {
  30. "device_name": "rtr1.wer",
  31. "ip_address": "1.1.1.1",
  32. "lldp_neighbors": [
  33. {
  34. "local-port": "xe-3/0/4.0",
  35. "parent-interface": "ae31.0",
  36. "chassis-id": "b0:c6:9a:63:80:40",
  37. "port-info": "xe-0/0/0/0.0",
  38. "system-name": "host.jnpr.net"
  39. }
  40. ]
  41. ]
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement