3 files changed, 22 insertions(+), 4 deletions(-)
lib/ais/plugin.c |    8 ++++----
lib/ais/utils.c  |   16 ++++++++++++++++
lib/ais/utils.h  |    2 ++


# HG changeset patch
# User Andrew Beekhof <[EMAIL PROTECTED]>
# Date 1226393852 -3600
# Branch stable-1.0
# Node ID 38203f5ff9728096eb3bd86b6946d75c728e7a98
# Parent  c57beb84ee34df29fb099af9dcf3fa01a647fcff
Dev: ais: Correctly interpret the admin's configuration intentions

diff --git a/lib/ais/plugin.c b/lib/ais/plugin.c
--- a/lib/ais/plugin.c
+++ b/lib/ais/plugin.c
@@ -338,7 +338,7 @@ static void process_ais_conf(void)
     objdb_handle = get_config_section("logging");
 
     get_config_opt(objdb_handle, "debug", &value, "on");
-    if(ais_str_eq(value, "on")) {
+    if(ais_get_boolean(value)) {
 	plugin_log_level = LOG_DEBUG;
 	setenv("HA_debug",  "1", 1);
 	
@@ -348,7 +348,7 @@ static void process_ais_conf(void)
     }    
     
     get_config_opt(objdb_handle, "to_syslog", &value, "on");
-    if(ais_str_eq(value, "on")) {
+    if(ais_get_boolean(value)) {
 	get_config_opt(objdb_handle, "syslog_facility", &value, "daemon");
 	setenv("HA_logfacility",  value, 1);
 	
@@ -357,7 +357,7 @@ static void process_ais_conf(void)
     }
 
     get_config_opt(objdb_handle, "to_file", &value, "off");
-    if(ais_str_eq(value, "on")) {
+    if(ais_get_boolean(value)) {
 	get_config_opt(objdb_handle, "logfile", &value, NULL);
 
 	if(value == NULL) {
@@ -425,9 +425,9 @@ static void crm_plugin_init(void)
     local_nodeid = crm_api->totem_nodeid_get();
 #endif
 
+    ais_info("Service: %d", CRM_SERVICE);
     ais_info("Local node id: %u", local_nodeid);
     ais_info("Local hostname: %s", local_uname);
-    ais_info("Service: %d", CRM_SERVICE);
     
     update_member(local_nodeid, 0, 0, 1, 0, local_uname, CRM_NODE_MEMBER, NULL);
     
diff --git a/lib/ais/utils.c b/lib/ais/utils.c
--- a/lib/ais/utils.c
+++ b/lib/ais/utils.c
@@ -582,3 +582,19 @@ int objdb_get_int(
     }
     return -1;
 }
+
+int
+ais_get_boolean(const char * value)
+{
+	if(value == NULL) {
+		return 0;
+
+	} else if (strcasecmp(value, "true") == 0
+		   ||	strcasecmp(value, "on") == 0
+		   ||	strcasecmp(value, "yes") == 0
+		   ||	strcasecmp(value, "y") == 0
+		   ||	strcasecmp(value, "1") == 0){
+		return 1;
+	}
+	return 0;
+}
diff --git a/lib/ais/utils.h b/lib/ais/utils.h
--- a/lib/ais/utils.h
+++ b/lib/ais/utils.h
@@ -120,6 +120,8 @@ extern int get_config_opt(unsigned int o
 extern int get_config_opt(unsigned int object_service_handle,
 			    char *key, char **value, const char *fallback);
 
+extern int ais_get_boolean(const char *s);
+
 extern GHashTable *membership_list;
 extern pthread_t crm_wait_thread;
 extern int plugin_log_level;
_______________________________________________
Pacemaker mailing list
[email protected]
http://list.clusterlabs.org/mailman/listinfo/pacemaker

Reply via email to