ajout name dans json, correction champ equipement matrice de routage, correction doublon headers matrice de routage
This commit is contained in:
@@ -390,6 +390,18 @@ class StormshieldParser(ParserMixin):
|
||||
|
||||
self.config["security_rules"].append(rule)
|
||||
|
||||
def _parse_name(self):
|
||||
"""Parse le nom du firewall depuis le fichier network"""
|
||||
path = os.path.join(self.base_dir, "network")
|
||||
fw_name = ""
|
||||
with open(path, "r", encoding="utf-8", errors="ignore") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line.startswith("Name="):
|
||||
fw_name = line.split("=", 1)[1].strip()
|
||||
break
|
||||
return fw_name
|
||||
|
||||
|
||||
def _extract_comment(self, line: str) -> str:
|
||||
"""Extrait un commentaire après #"""
|
||||
@@ -409,7 +421,7 @@ class StormshieldParser(ParserMixin):
|
||||
|
||||
def export_to_json(self, output_file: str):
|
||||
"""Exporte la configuration au format JSON OpenConfig"""
|
||||
openconfig_data = self.to_openconfig_yang("stormshield")
|
||||
openconfig_data = self.to_openconfig_yang("stormshield", [self._parse_name()])
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(openconfig_data, f, indent=2, ensure_ascii=False)
|
||||
|
||||
Reference in New Issue
Block a user