Advertisement
Guest User

Untitled

a guest
Jan 19th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. ---
  2. - hostname: R1
  3. interfaces:
  4. - name: f0/0
  5. description: This is FastEth 0/0 connected to R2 FastEth 0/0
  6. - name: f0/1
  7. description: This is FastEth 0/1 connected to Local Host Loopback
  8. - hostname: R2
  9. interfaces:
  10. - name: f0/0
  11. description: This is FastEth 0/0 connected to R2 FastEth 0/0
  12. - name: f0/1
  13. description: This is FastEth 0/1 connected to Local Host Loopback
  14.  
  15. {% for iface in config.interfaces %}
  16. int {{ config.name }}
  17. description {{ config.description }}
  18. {% endfor %}
  19.  
  20. env = Environment(loader=FileSystemLoader('./templates'),trim_blocks=True)
  21. with open('./YAML/configuration.yml') as _:
  22. config_commands_var = yaml.load(_)
  23.  
  24. for device in range(len(devices)):
  25. print "nStart time: " + str(datetime.now())
  26. username = devices[device]['username']
  27. password = devices[device]['password']
  28. ip = devices[device]['ip']
  29. device_type = devices[device]['device_type']
  30. secret = devices[device]['secret']
  31. hostname = devices[device]['hostname']
  32.  
  33. config_commands = template.render(config=config_commands_var)
  34. push_config_commands(username, password, ip, device_type, secret, config_commands)
  35.  
  36. ---
  37. interfaces:
  38. R1:
  39. f0/0:
  40. description: This is FastEth 0/0 connected to R2 FastEth 0/0
  41. f0/1:
  42. description: This is FastEth 0/1 connected to Local Host Loopback
  43. R2:
  44. f0/0:
  45. description: This is FastEth 0/0 connected to R2 FastEth 0/0
  46. f0/1:
  47. description: This is FastEth 0/1 connected to Local Host Loopback
  48.  
  49. {% for iface in config %}
  50. interface {{ iface }}
  51. description {{ config[iface]['description'] }}
  52. {% endfor %}
  53.  
  54. config_commands = template.render(config=config_commands_var['interfaces'][hostname])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement