[2/2] ui/ncurses: Display warning when net override active
diff mbox

Message ID 20160906042953.30304-2-sam@mendozajonas.com
State Accepted
Headers show

Commit Message

Samuel Mendoza-Jonas Sept. 6, 2016, 4:29 a.m. UTC
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 | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

Patch
diff mbox

diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c
index 10d7eb6..fbba943 100644
--- a/ui/ncurses/nc-config.c
+++ b/ui/ncurses/nc-config.c
@@ -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, "/");