Revision 7c83f065 confFileGenerator/Node.py

View differences:

confFileGenerator/Node.py
19 19
import ipaddress
20 20
from constants import *
21 21
import os.path
22

  
22
from jinja2 import Environment, FileSystemLoader
23 23

  
24 24
class Node:
25 25
    nodeIpAddr_network = ipaddress.ip_network(u'200.0.0.0/8')
......
61 61
        self.exportedNetworks = []
62 62
        self.exportedNetworks_str = ""
63 63
        self.log_file_name = "log_h_" + str(self.name) + ".log"
64
        self.network_file_name = "network-config-node-" + str(self.name) + ".sh"
64 65

  
65 66
        self.eth_dict = {}
66 67
        self.customer = {}
......
112 113
                                      filter_conf_path=FILTER_CONF_PATH,
113 114
                                      bgp_session_export_path="", bgp_session_path=""))
114 115

  
116
    def write_network_configuration(self):
117
        # Write the network configuration of the node
118
        env = Environment(loader=FileSystemLoader('templates/'))
119
        baseline = env.get_template(NETWORK_TEMPLATE_PATH)
120
        ip_addresses = []
121
        for _,ip in self.eth_dict.items():
122
            ip_addresses.append(str(ip))
123
        rendered_template = baseline.render(name=self.name,ipaddresses=ip_addresses)
124
        with open(self.outFolder + self.network_file_name, "w") as netfd:
125
            netfd.write(rendered_template)
126

  
115 127
    def delete_export_file(self):
116 128
        if os.path.isfile(self.outFolder + self.sessionExporterFile_name):
117 129
            os.remove(self.outFolder + self.sessionExporterFile_name)

Also available in: Unified diff