Hanfle interfaces exception for json
oginstaller/pipeline/head There was a failure building this commit Details

working-installer
Nicolas Arenas 2024-11-22 10:05:21 +01:00
parent ee28a98157
commit 00a96b0a84
1 changed files with 25 additions and 2 deletions

View File

@ -150,9 +150,32 @@ class OgDhcpForm(ComponentForm):
def configure_fields(self):
self.fields["ogbootIP"] = {"widget": self.add(npyscreen.TitleText, name="IP servidor de Boot (127.0.0.1):", value="127.0.0.1")}
self.fields["ogDhcpIP"] = {"widget": self.add(npyscreen.TitleText, name="IP servidor de DHCP (127.0.0.1):", value="127.0.0.1")}
self.fields["ogDhcp_Dir"] = {"widget": self.add(npyscreen.TitleText, name="Directorio de ogdhcp (/opt/opengnsys/ogdhcp):", value="/opt/opengnsys/ogdhcp")}
self.fields["ogDhcp_Dir"] = {"widget": self.add(npyscreen.TitleText, name="Directorio de ogdhcp (/opt/opengnsys/ogdhcp):", value="/opt/opengnsys/ogdhcp")}
self.fields["interfaces"] = {"widget": self.add(npyscreen.TitleText, name="Interfaces Boot (eth0,eth1):", value="eth0,eth1")}
def on_ok(self):
if not self.validate_fields():
return # Si las validaciones fallan, no proceder
npyscreen.blank_terminal()
config_data = {"release": self.parentApp.selected_tag}
for key, field_data in self.fields.items():
if key == "interfaces":
config_data[key] = [iface.strip() for iface in field_data["widget"].value.split(",")]
else:
config_data[key] = field_data["widget"].value
config_file = os.path.join(CONFIGS_DIR, f"config_{self.component_name}.json")
with open(config_file, "w") as f:
json.dump(config_data, f)
npyscreen.notify_confirm(f"Configuración de {self.component_name} guardada en {config_file}", title="Confirmación")
self.parentApp.current_component_index += 1
if self.parentApp.current_component_index < len(self.parentApp.selected_components):
next_component = self.parentApp.selected_components[self.parentApp.current_component_index]
self.parentApp.switchForm(next_component)
else:
self.parentApp.setNextForm(None)
class OgBootForm(ComponentForm):
component_name = "ogBoot"