Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- - hostname: R1
- interfaces:
- - name: f0/0
- description: This is FastEth 0/0 connected to R2 FastEth 0/0
- - name: f0/1
- description: This is FastEth 0/1 connected to Local Host Loopback
- - hostname: R2
- interfaces:
- - name: f0/0
- description: This is FastEth 0/0 connected to R2 FastEth 0/0
- - name: f0/1
- description: This is FastEth 0/1 connected to Local Host Loopback
- {% for iface in config.interfaces %}
- int {{ config.name }}
- description {{ config.description }}
- {% endfor %}
- env = Environment(loader=FileSystemLoader('./templates'),trim_blocks=True)
- with open('./YAML/configuration.yml') as _:
- config_commands_var = yaml.load(_)
- for device in range(len(devices)):
- print "nStart time: " + str(datetime.now())
- username = devices[device]['username']
- password = devices[device]['password']
- ip = devices[device]['ip']
- device_type = devices[device]['device_type']
- secret = devices[device]['secret']
- hostname = devices[device]['hostname']
- config_commands = template.render(config=config_commands_var)
- push_config_commands(username, password, ip, device_type, secret, config_commands)
- ---
- interfaces:
- R1:
- f0/0:
- description: This is FastEth 0/0 connected to R2 FastEth 0/0
- f0/1:
- description: This is FastEth 0/1 connected to Local Host Loopback
- R2:
- f0/0:
- description: This is FastEth 0/0 connected to R2 FastEth 0/0
- f0/1:
- description: This is FastEth 0/1 connected to Local Host Loopback
- {% for iface in config %}
- interface {{ iface }}
- description {{ config[iface]['description'] }}
- {% endfor %}
- config_commands = template.render(config=config_commands_var['interfaces'][hostname])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement