]> git.ozlabs.org Git - petitboot/commitdiff
ui/ncurses: Display warning when net override active
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 6 Sep 2016 03:30:39 +0000 (13:30 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 8 Sep 2016 04:26:27 +0000 (14:26 +1000)
If the current interface config has been set by an IPMI network
override, display a warning in nc-config that saving the current config
will overwrite any saved interface config.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
ui/ncurses/nc-config.c

index 10d7eb6b49f84e2450f5d8e520468132cf816d90..fbba943e3f178f0e194215f647a984f88d668cb4 100644 (file)
@@ -33,7 +33,7 @@
 #include "nc-config.h"
 #include "nc-widgets.h"
 
-#define N_FIELDS       42
+#define N_FIELDS       43
 
 extern struct help_text config_help_text;
 
@@ -67,6 +67,7 @@ struct config_screen {
 
        bool                    autoboot_enabled;
        bool                    ipmi_override;
+       bool                    net_override;
 
        struct {
                struct nc_widget_label          *autoboot_l;
@@ -112,6 +113,7 @@ struct config_screen {
                struct nc_widget_select         *boot_tty_f;
                struct nc_widget_label          *current_tty_l;
 
+               struct nc_widget_label          *net_override_l;
                struct nc_widget_label          *safe_mode;
                struct nc_widget_button         *ok_b;
                struct nc_widget_button         *help_b;
@@ -473,7 +475,8 @@ static void config_screen_layout_widgets(struct config_screen *screen)
                widget_move(wf, y, screen->field_x);
                widget_move(wh, y, screen->field_x + widget_width(wf) + 1);
                y += 2;
-       }
+       } else
+               y += 1;
 
        if (screen->ipmi_override) {
                wl = widget_label_base(screen->widgets.ipmi_type_l);
@@ -583,13 +586,6 @@ static void config_screen_layout_widgets(struct config_screen *screen)
 
        y += 1;
 
-       show = screen->cui->config->safe_mode;
-       if (show) {
-               widget_move(widget_label_base(screen->widgets.safe_mode),
-                       y, screen->field_x);
-               y += 1;
-       }
-
        layout_pair(screen, y, screen->widgets.allow_write_l,
                    widget_select_base(screen->widgets.allow_write_f));
        y += widget_height(widget_select_base(screen->widgets.allow_write_f));
@@ -612,6 +608,22 @@ static void config_screen_layout_widgets(struct config_screen *screen)
                                        screen->widgets.current_tty_l), false);
        }
 
+       if (screen->net_override) {
+               widget_move(widget_label_base(screen->widgets.net_override_l),
+                               y, screen->label_x);
+               widget_set_visible(widget_label_base(screen->widgets.net_override_l),
+                                       true);
+               y += 1;
+       }
+
+       if (screen->cui->config->safe_mode) {
+               widget_move(widget_label_base(screen->widgets.safe_mode),
+                       y, screen->label_x);
+               widget_set_visible(widget_label_base(screen->widgets.safe_mode),
+                                       true);
+               y += 1;
+       }
+
        widget_move(widget_button_base(screen->widgets.ok_b),
                        y, screen->field_x);
        widget_move(widget_button_base(screen->widgets.help_b),
@@ -960,6 +972,12 @@ static void config_screen_setup_widgets(struct config_screen *screen,
                url = ifcfg->static_config.url;
        }
 
+       screen->net_override = ifcfg && ifcfg->override;
+       if (screen->net_override) {
+               screen->widgets.net_override_l = widget_new_label(set, 0, 0,
+                       _("Network Override Active! 'OK' will overwrite interface config"));
+       }
+
        screen->widgets.ip_addr_l = widget_new_label(set, 0, 0, _("IP/mask:"));
        screen->widgets.ip_addr_f = widget_new_textbox(set, 0, 0, 16, ip);
        screen->widgets.ip_mask_l = widget_new_label(set, 0, 0, "/");