Guest User

Untitled

a guest
Jan 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. [Host1]
  2. dfwm2
  3. dwm1-su2
  4. [Host2]
  5. cisb1
  6. cisb2
  7. [Othe]
  8. b4
  9. b8
  10.  
  11. [1]
  12. edit
  13. run show
  14. exit
  15. show et-0/0/0 brief
  16. show adjacency
  17. show oamtest
  18. edit
  19. run
  20.  
  21. def read_hosts(filename):
  22. # Read the filename and store file content in a variable as list of lines. Variable - file_cont
  23. hosts={}
  24. key=''
  25. value=[]
  26. with open(filename) as f:
  27. lines = f.read().splitlines()
  28. for line in lines:
  29. #if '[' in line and ']' in line:
  30. if line.startswith('[') and line.endswith(']'):
  31. key = line[1:-1]
  32. value = []
  33. hosts[key]=value
  34. return hosts
Add Comment
Please, Sign In to add comment