Pls I am totally a newbie in this python programming. I have been struggling to push rendered configured to the 64 Routers in GNS3 but has not succeeded. I will appreciate your help here.
I succeeded in rendering the config and can print it out on the screen.
I used Yaml template and jinja2 template here
Do not know how to push rendered result to the devices configured on GNS3.
Python code used:
import yaml
from jinja2 import Template
from netmiko import Netmiko
import netmiko
import json
from netmiko import ConnectHandler
from getpass import getpass
username = input('Enter your SSH username: ')
password = getpass()
#read your yaml file
with open("Just4testing8.yml") as file:
devices = yaml.safe_load(file)
#read your jinja template file
with open("Just4testing7.j2") as file:
template = Template(file.read())
for device in devices["devices"]:
final = template.render(
device=device["name"],
interfaces=device["interfaces"],
bgpasn=device["bgpasn"],
bgp_id=device["bgp_id"],
bgp_neighbors=device["bgp_neighbors"])
print(final)
It looks like your missing your netmiko code. I think this is what you're looking for.
Here is a basic example using a list for the commands, I would assume that you would parse your render configuration into that. I dont know anything about Render but looks like a dictionary so you could create a list the values.
** SAMPLE -- Not tested**