-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_interface_template_jinja2.py
More file actions
35 lines (28 loc) · 1.1 KB
/
Copy pathformat_interface_template_jinja2.py
File metadata and controls
35 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from jinja2 import Template
from jinja2 import FileSystemLoader, Environment
def ask_interface_properties():
int_name = input("interface: ")
int_description = input("description: ")
int_type = input("type: ")
int_enabled = input("enabled [true/false]:")
int_ip_address = input("ip addres: ")
int_netmask = input("netmask: ")
properties = {"name":int_name,
"description":int_description,
"type":int_type,
"enabled":int_enabled,
"ip_address":int_ip_address,
"netmask":int_netmask}
return properties
def get_interface_config(interface_data):
'''Laad de template van file en vul met interface_data'''
templates = Environment(loader=FileSystemLoader('./templates'))
xmltemplate = templates.get_template('netconf_interface_template.j2')
xmlconfig = xmltemplate.render(interface_data)
return xmlconfig
def main():
interface_data = ask_interface_properties()
interface_config = get_interface_config(interface_data)
print(interface_config)
if __name__ == "__main__":
main()