From d0602ed25e3bff8298c19bece8cd8b3f80d86624 Mon Sep 17 00:00:00 2001 From: Samuel Mendoza-Jonas Date: Wed, 25 Jan 2017 14:45:37 +1100 Subject: discover: Track both configured and current autoboot settings If autoboot is enabled but later disabled or cancelled by, for example, an IPMI override then the nc-config screen will set the autoboot widget as disabled. If the user then makes and saves a change in nc-config, autoboot will also be saved as disabled. This accidental change is particularly awkward if the user is attempting to remove an IPMI override. Instead only ever change the autoboot setting if the user explicitly changes it. Use a new helper function 'config_autoboot_active()' to determine the current autoboot status where needed. Signed-off-by: Samuel Mendoza-Jonas --- lib/types/types.c | 12 ++++++++++++ lib/types/types.h | 2 ++ 2 files changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/types/types.c b/lib/types/types.c index 63045e1..d7f4ead 100644 --- a/lib/types/types.c +++ b/lib/types/types.c @@ -75,3 +75,15 @@ enum device_type find_device_type(const char *str) return DEVICE_TYPE_UNKNOWN; } + +bool config_autoboot_active(const struct config *config) +{ + enum ipmi_bootdev bootdev = config->ipmi_bootdev; + + if (!config->autoboot_enabled) + return false; + if (bootdev == IPMI_BOOTDEV_SETUP || bootdev == IPMI_BOOTDEV_SAFE) + return false; + + return true; +} diff --git a/lib/types/types.h b/lib/types/types.h index 13ff7fc..7f4ae1f 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -183,4 +183,6 @@ struct config { bool debug; }; +bool config_autoboot_active(const struct config *config); + #endif /* _TYPES_H */ -- cgit v1.2.1