Fonction aiguillage suivant constructeur

This commit is contained in:
chirac 2018-07-09 00:43:21 +02:00
parent a4922017e8
commit b1319bfcc2

11
main.py
View file

@ -85,7 +85,17 @@ class Switch:
self.preprocess_hp() self.preprocess_hp()
self.conf = self.hp_tpl.render(switch=self.switch, additionals=self.additionals) self.conf = self.hp_tpl.render(switch=self.switch, additionals=self.additionals)
def gen_conf_and_write(self):
"""Génère la conf suivant le bon constructeur et l'écrit"""
if self.switch["model"]:
constructor = self.switch["model"]["constructor"].lower()
if "hp" in constructor or "aruba" in constructor:
self.gen_conf_hp()
self.write_conf()
def write_conf(self): def write_conf(self):
"""Ecriture de la conf du switch dans le fichier qui va bien"""
with open("generated/" + self.get_conf_file_name(), 'w+') as f: with open("generated/" + self.get_conf_file_name(), 'w+') as f:
f.write(self.conf) f.write(self.conf)
@ -95,6 +105,7 @@ print("gen tpl")
sw = Switch() sw = Switch()
for switch in all_switchs: for switch in all_switchs:
sw.switch = switch sw.switch = switch
# sw.gen_conf_and_write()
sw.gen_conf_hp() sw.gen_conf_hp()
sw.write_conf() sw.write_conf()