0

I am new to netconf. I have created an xml data model as a jinja2 template. I am reading the file and attempting to render it with the variables from a dictionary. The template prints out, but the raw file without any variables populated. So I am getting the file with the dictionary keys printed in Jinja format, not the dictionary values. I just want to make sure the file is being populated with the correct information. I will worry about the connection later.

from ncclient import manager
from jinja2 import Template

# netconf Connection Manager
# netconf_connection = manager.connect(host='1.1.1.1',
#                     port=830,
#                     username='admin',
#                     password='admin',
#                     device_params={'name': 'iosxr'},
#                     hostkey_verify=False,
#                     look_for_keys=False)
#
netconf_data = {
    "carrier_vlan": 101,
    "customer_vlan": 1000,
    "HUB_WAN1_PUBLIC_IP": "10.10.10.10",
    "customer": "FirstNetConfTest",
    "PRIMARY_TRANSIT": "11.11.11.11",
    "neighbor_IP": "11.11.11.12",
    "Location": "LAX"
    }

netconf_file = open('templates/new_config.j2').read()
netconf_template = Template(netconf_file)
netconf_payload = netconf_template.render(netconf_data)


print(netconf_payload)

1 Answers1

1

Most likely this is due to a missing / misspelled field in your template. Try checking all the variable names match their corresponding fields.

alexBoldea
  • 11
  • 3