Send Linux-ha-cvs mailing list submissions to
        linux-ha-cvs@lists.linux-ha.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."


Today's Topics:

   1. Linux-HA CVS: lib by andrew from 
      (linux-ha-cvs@lists.linux-ha.org)


----------------------------------------------------------------------

Message: 1
Date: Mon, 14 Aug 2006 03:06:33 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/pengine


Modified Files:
        clone.c common.c group.c unpack.c utils.c 


Log Message:
Finish creating generic, self-documenting option processing code
Use the above to impliment the meta-data command for the pengine and crmd

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/pengine/clone.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- clone.c     21 Jun 2006 14:48:01 -0000      1.5
+++ clone.c     14 Aug 2006 09:06:32 -0000      1.6
@@ -1,4 +1,4 @@
-/* $Id: clone.c,v 1.5 2006/06/21 14:48:01 andrew Exp $ */
+/* $Id: clone.c,v 1.6 2006/08/14 09:06:32 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -165,7 +165,7 @@
        }
 
        if(clone_data->xml_obj_child == NULL) {
-               pe_config_err("%s has nothing to clone", rsc->id);
+               crm_config_err("%s has nothing to clone", rsc->id);
                return FALSE;
        }
        
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/pengine/common.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- common.c    14 Aug 2006 09:00:57 -0000      1.3
+++ common.c    14 Aug 2006 09:06:32 -0000      1.4
@@ -1,4 +1,4 @@
-/* $Id: common.c,v 1.3 2006/08/14 09:00:57 andrew Exp $ */
+/* $Id: common.c,v 1.4 2006/08/14 09:06:32 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -30,8 +30,75 @@
 
 gboolean was_processing_error = FALSE;
 gboolean was_processing_warning = FALSE;
-gboolean was_config_error = FALSE;
-gboolean was_config_warning = FALSE;
+
+static gboolean
+check_quorum(const char *value) 
+{
+       if(safe_str_eq(value, "stop")) {
+               return TRUE;
+
+       } else if(safe_str_eq(value, "freeze")) {
+               return TRUE;
+
+       } else if(safe_str_eq(value, "ignore")) {
+               return TRUE;
+       }
+       return FALSE;
+}
+
+static gboolean
+check_stonith_action(const char *value) 
+{
+       if(safe_str_eq(value, "reboot")) {
+               return TRUE;
+
+       } else if(safe_str_eq(value, "poweroff")) {
+               return TRUE;
+       }
+       return FALSE;
+}
+
+pe_cluster_option pe_opts[] = {
+       /* name, old-name, validate, default, description */
+       { "no-quorum-policy", "no_quorum_policy", "enum", "stop, freeze, 
ignore", "stop", &check_quorum, "What to do when the cluster does not have 
quorum", NULL },
+       { "symmetric-cluster", "symmetric_cluster", "boolean", NULL, "true", 
&check_boolean, "All resources can run anywhere by default", NULL },
+       { "stonith-enabled", "stonith_enabled", "boolean", NULL, "false", 
&check_boolean, "Failed nodes are STONITH'd", NULL },
+       { "stonith-action", "stonith_action", "enum", "reboot, poweroff", 
"reboot", &check_stonith_action, "Action to send to STONITH device", NULL },
+       { "default-resource-stickiness", "default_resource_stickiness", 
"integer", NULL, "0", &check_number, "", NULL },
+       { "default-resource-failure-stickiness", 
"default_resource_failure_stickiness", "integer", NULL, "0", &check_number, "", 
NULL },
+       { "is-managed-default", "is_managed_default", "boolean", NULL, "true", 
&check_boolean, "Should the cluster start/stop resources as required", NULL },
+       { "network-delay", "transition_idle_timeout", "time", NULL, "60s", 
&check_time, "Round trip delay over the network (excluding action execution)", 
"The \"correct\" value will depend on the speed and load of your network." },
+       { "default-action-timeout", "default_action_timeout", "time", NULL, 
"20s", &check_time, "How long to wait for actions to complete", NULL },
+       { "stop-orphan-resources", "stop_orphan_resources", "boolean", NULL, 
"true", &check_boolean, "Should deleted resources be stopped", NULL },
+       { "stop-orphan-actions", "stop_orphan_actions", "boolean", NULL, 
"true", &check_boolean, "Should deleted actions be cancelled", NULL },
+       { "remove-after-stop", "remove_after_stop", "boolean", NULL, "false", 
&check_boolean, NULL, NULL },
+/*     { "", "", , "0", "", NULL }, */
+       { "pe-error-series-max", NULL, "integer", NULL, "-1", &check_number, 
"", NULL },
+       { "pe-warn-series-max",  NULL, "integer", NULL, "-1", &check_number, 
"", NULL },
+       { "pe-input-series-max", NULL, "integer", NULL, "-1", &check_number, 
"", NULL },
+       { "startup-fencing", "startup_fencing", "boolean", NULL, "true", 
&check_boolean, "STONITH unseen nodes", "Advanced Use Only!  Not using the 
default is very unsafe!" }
+};
+
+void
+pe_metadata(void)
+{
+       config_metadata("Policy Engine", "1.0",
+                       "Policy Engine Options",
+                       "This is a fake resource that details the options that 
can be configured for the Policy Engine.",
+                       pe_opts, DIMOF(pe_opts));
+}
+
+void
+verify_pe_options(GHashTable *options)
+{
+       verify_all_options(options, pe_opts, DIMOF(pe_opts));
+}
+
+const char *
+pe_pref(GHashTable *options, const char *name)
+{
+       return get_cluster_pref(options, pe_opts, DIMOF(pe_opts), name);
+}
 
 const char *
 fail2text(enum action_fail_response fail)
@@ -294,60 +361,3 @@
                g_hash_table_insert(hash, crm_strdup(name), crm_strdup(value));
        }
 }
-
-
-static gboolean
-check_action_timeout(const char *value) 
-{
-       long tmp = crm_get_msec(value);
-       if(tmp < 5) {
-               return FALSE;
-       }
-       return TRUE;
-}
-
-const char *
-default_action_timeout(GHashTable* options)
-{
-       return cluster_option(options, &check_action_timeout,
-                             "default_action_timeout",
-                             "transition_idle_timeout", "60s");
-}
-
-const char *
-cluster_option(GHashTable* options, gboolean(*validate)(const char*),
-              const char *name, const char *old_name, const char *def_value)
-{
-       const char *value = NULL;
-       CRM_ASSERT(name != NULL);
-       CRM_ASSERT(options != NULL);
-
-       return "60s";
-       
-       value = g_hash_table_lookup(options, name);
-       if(value == NULL && old_name) {
-               value = g_hash_table_lookup(options, old_name);
-               if(value != NULL) {
-                       pe_config_warn("Using deprecated name '%s' for"
-                                      " cluster option '%s'", old_name, name);
-               }
-       }
-
-       if(value == NULL) {
-               g_hash_table_insert(
-                       options, crm_strdup(name), crm_strdup(def_value));
-               value = g_hash_table_lookup(options, name);
-               crm_notice("Using default value '%s' for cluster option '%s'",
-                          value, name);
-       }
-       
-       if(validate && validate(value) == FALSE) {
-               pe_config_err("Value '%s' for cluster option '%s' is invalid."
-                             "  Defaulting to %s", value, name, def_value);
-               g_hash_table_replace(options, crm_strdup(name),
-                                    crm_strdup(def_value));
-               value = g_hash_table_lookup(options, name);
-       }
-       
-       return value;
-}
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/pengine/group.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- group.c     25 Jun 2006 14:56:13 -0000      1.5
+++ group.c     14 Aug 2006 09:06:32 -0000      1.6
@@ -1,4 +1,4 @@
-/* $Id: group.c,v 1.5 2006/06/25 14:56:13 lars Exp $ */
+/* $Id: group.c,v 1.6 2006/08/14 09:06:32 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -124,10 +124,10 @@
        if(group_data->num_children == 0) {
 #if 0
                /* Bug #1287 */
-               pe_config_err("Group %s did not have any children", rsc->id);
+               crm_config_err("Group %s did not have any children", rsc->id);
                return FALSE;
 #else
-               pe_config_warn("Group %s did not have any children", rsc->id);
+               crm_config_warn("Group %s did not have any children", rsc->id);
                return TRUE;
 #endif
        }
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/pengine/unpack.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- unpack.c    14 Aug 2006 09:00:57 -0000      1.15
+++ unpack.c    14 Aug 2006 09:06:32 -0000      1.16
@@ -1,4 +1,4 @@
-/* $Id: unpack.c,v 1.15 2006/08/14 09:00:57 andrew Exp $ */
+/* $Id: unpack.c,v 1.16 2006/08/14 09:06:32 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -35,22 +35,17 @@
 #include <crm/pengine/rules.h>
 #include <unpack.h>
 
-#define get_cluster_pref(pref) value = g_hash_table_lookup(config_hash, pref); 
\
-       if(value == NULL) {                                             \
-               pe_config_warn("No value specified for cluster preference: %s", 
pref); \
-       }
-
 
 
 gboolean
-unpack_config(crm_data_t * config, pe_working_set_t *data_set)
+unpack_config(crm_data_t *config, pe_working_set_t *data_set)
 {
        const char *name = NULL;
        const char *value = NULL;
        GHashTable *config_hash = g_hash_table_new_full(
                g_str_hash,g_str_equal, g_hash_destroy_str,g_hash_destroy_str);
 
-       data_set->config_hash = config_hash;    
+       data_set->config_hash = config_hash;
 
        unpack_instance_attributes(
                config, XML_CIB_TAG_PROPSET, NULL, config_hash,
@@ -67,7 +62,7 @@
                        g_hash_table_insert(
                                config_hash,crm_strdup(name),crm_strdup(value));
                }
-               pe_config_err("Creating <nvpair id=%s name=%s/> directly"
+               crm_config_err("Creating <nvpair id=%s name=%s/> directly"
                              "beneath <crm_config> has been depreciated since"
                              " 2.0.1", ID(a_child), name);
                );
@@ -76,50 +71,43 @@
                config, a_child, XML_CIB_TAG_NVPAIR,
 
                name = crm_element_value(a_child, XML_NVPAIR_ATTR_NAME);
-               pe_config_err("Creating <nvpair id=%s name=%s/> directly"
+               crm_config_err("Creating <nvpair id=%s name=%s/> directly"
                              "beneath <crm_config> has been depreciated since"
                              " 2.0.1 and is now disabled", ID(a_child), name);
                );
 #endif
+       verify_pe_options(data_set->config_hash);
        
-       data_set->transition_idle_timeout = crm_strdup(
-               default_action_timeout(data_set->config_hash));
-       crm_debug("default_action_timeout set to: %s", 
data_set->transition_idle_timeout);
+       value = pe_pref(data_set->config_hash, "default-action-timeout");
+       data_set->transition_idle_timeout = crm_strdup(value);
+       crm_debug("Default action timeout: %s", 
data_set->transition_idle_timeout);
 
-       get_cluster_pref("default_"XML_RSC_ATTR_STICKINESS);
+       value = pe_pref(data_set->config_hash, "default-resource-stickiness");
        data_set->default_resource_stickiness = char2score(value);
        crm_info("Default stickiness: %d",
                 data_set->default_resource_stickiness);
 
-       get_cluster_pref("default_"XML_RSC_ATTR_FAIL_STICKINESS);
+       value = pe_pref(data_set->config_hash, 
"default-resource-failure-stickiness");
        data_set->default_resource_fail_stickiness = char2score(value);
        crm_info("Default failure stickiness: %d",
                 data_set->default_resource_fail_stickiness);
        
-       get_cluster_pref("stonith_enabled");
-       if(value != NULL) {
-               cl_str_to_boolean(value, &data_set->stonith_enabled);
-       }
+       value = pe_pref(data_set->config_hash, "stonith-enabled");
+       cl_str_to_boolean(value, &data_set->stonith_enabled);
        crm_info("STONITH of failed nodes is %s",
                 data_set->stonith_enabled?"enabled":"disabled");       
 
-       get_cluster_pref("stonith_action");
-       if(value == NULL || safe_str_neq(value, "poweroff")) {
-               value = "reboot";
-       }
-       data_set->stonith_action = value;
+       data_set->stonith_action = pe_pref(data_set->config_hash, 
"stonith-action");
        crm_info("STONITH will %s nodes", data_set->stonith_action);    
        
-       get_cluster_pref("symmetric_cluster");
-       if(value != NULL) {
-               cl_str_to_boolean(value, &data_set->symmetric_cluster);
-       }
+       value = pe_pref(data_set->config_hash, "symmetric-cluster");
+       cl_str_to_boolean(value, &data_set->symmetric_cluster);
        if(data_set->symmetric_cluster) {
                crm_info("Cluster is symmetric"
                         " - resources can run anywhere by default");
        }
 
-       get_cluster_pref("no_quorum_policy");
+       value = pe_pref(data_set->config_hash, "no-quorum-policy");
        if(safe_str_eq(value, "ignore")) {
                data_set->no_quorum_policy = no_quorum_ignore;
                
@@ -142,31 +130,23 @@
                        break;
        }
 
-       get_cluster_pref("stop_orphan_resources");
-       if(value != NULL) {
-               cl_str_to_boolean(value, &data_set->stop_rsc_orphans);
-       }
+       value = pe_pref(data_set->config_hash, "stop-orphan-resources");
+       cl_str_to_boolean(value, &data_set->stop_rsc_orphans);
        crm_info("Orphan resources are %s",
                 data_set->stop_rsc_orphans?"stopped":"ignored");       
        
-       get_cluster_pref("stop_orphan_actions");
-       if(value != NULL) {
-               cl_str_to_boolean(value, &data_set->stop_action_orphans);
-       }
+       value = pe_pref(data_set->config_hash, "stop-orphan-actions");
+       cl_str_to_boolean(value, &data_set->stop_action_orphans);
        crm_info("Orphan resource actions are %s",
                 data_set->stop_action_orphans?"stopped":"ignored");    
 
-       get_cluster_pref("remove_after_stop");
-       if(value != NULL) {
-               cl_str_to_boolean(value, &data_set->remove_after_stop);
-       }
+       value = pe_pref(data_set->config_hash, "remove-after-stop");
+       cl_str_to_boolean(value, &data_set->remove_after_stop);
        crm_info("Stopped resources are removed from the status section: %s",
                 data_set->remove_after_stop?"true":"false");   
        
-       get_cluster_pref("is_managed_default");
-       if(value != NULL) {
-               cl_str_to_boolean(value, &data_set->is_managed_default);
-       }
+       value = pe_pref(data_set->config_hash, "is-managed-default");
+       cl_str_to_boolean(value, &data_set->is_managed_default);
        crm_info("By default resources are %smanaged",
                 data_set->is_managed_default?"":"not ");
 
@@ -180,8 +160,8 @@
        const char *id     = NULL;
        const char *uname  = NULL;
        const char *type   = NULL;
-       const char *blind_faith = g_hash_table_lookup(
-               data_set->config_hash, "startup_fencing");
+       const char *blind_faith = pe_pref(
+               data_set->config_hash, "startup-fencing");
 
        crm_debug_2("Begining unpack... %s",
                    xml_nodes?crm_element_name(xml_nodes):"<none>");
@@ -196,11 +176,11 @@
                crm_debug_3("Processing node %s/%s", uname, id);
 
                if(id == NULL) {
-                       pe_config_err("Must specify id tag in <node>");
+                       crm_config_err("Must specify id tag in <node>");
                        continue;
                }
                if(type == NULL) {
-                       pe_config_err("Must specify type tag in <node>");
+                       crm_config_err("Must specify type tag in <node>");
                        continue;
                }
                crm_malloc0(new_node, sizeof(node_t));
@@ -290,7 +270,7 @@
                        print_resource(LOG_DEBUG_3, "Added", new_rsc, FALSE);
 
                } else {
-                       pe_config_err("Failed unpacking %s %s",
+                       crm_config_err("Failed unpacking %s %s",
                                      crm_element_name(xml_obj),
                                      crm_element_value(xml_obj, XML_ATTR_ID));
                        if(new_rsc != NULL && new_rsc->fns != NULL) {
@@ -339,7 +319,7 @@
                        continue;
 
                } else if(this_node == NULL) {
-                       pe_config_warn("Node %s in status section no longer 
exists",
+                       crm_config_warn("Node %s in status section no longer 
exists",
                                       uname);
                        continue;
                }
@@ -484,7 +464,7 @@
                crm_element_value(node_state, XML_CIB_ATTR_EXPSTATE);
        
        if(this_node == NULL) {
-               pe_config_err("No node to check");
+               crm_config_err("No node to check");
                return online;
        }
 
@@ -679,7 +659,7 @@
        const char *rsc_id   = crm_element_value(rsc_entry, XML_ATTR_ID);
        
        crm_log_xml_info(rsc_entry, "Orphan resource");
-       pe_config_warn("Nothing known about resource %s running on %s",
+       crm_config_warn("Nothing known about resource %s running on %s",
                       rsc_id, node->details->uname);
        rsc = create_fake_resource(rsc_id, rsc_entry, data_set);
        
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/pengine/utils.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- utils.c     14 Aug 2006 09:00:57 -0000      1.9
+++ utils.c     14 Aug 2006 09:06:32 -0000      1.10
@@ -1,4 +1,4 @@
-/* $Id: utils.c,v 1.9 2006/08/14 09:00:57 andrew Exp $ */
+/* $Id: utils.c,v 1.10 2006/08/14 09:06:32 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -589,7 +589,7 @@
        class = g_hash_table_lookup(action->rsc->meta, "class");
        if(safe_str_eq(class, "stonith")) {
                if(action->needs == rsc_req_stonith) {
-                       pe_config_err("Stonith resources (eg. %s) cannot 
require"
+                       crm_config_err("Stonith resources (eg. %s) cannot 
require"
                                      " fencing to start", action->rsc->id);
                }
                action->needs = rsc_req_nothing;
@@ -606,16 +606,16 @@
                        action->rsc->meta, "on_stopfail");
                if(value != NULL) {
 #if CRM_DEPRECATED_SINCE_2_0_2
-                       pe_config_err("The \"on_stopfail\" attribute used in"
+                       crm_config_err("The \"on_stopfail\" attribute used in"
                                      " %s has been deprecated since 2.0.2",
                                      action->rsc->id);
 #else
-                       pe_config_err("The \"on_stopfail\" attribute used in"
+                       crm_config_err("The \"on_stopfail\" attribute used in"
                                      " %s has been deprecated since 2.0.2"
                                      " and is now disabled", action->rsc->id);
                        value = NULL;
 #endif
-                       pe_config_err("Please use specify the \"on_fail\""
+                       crm_config_err("Please use specify the \"on_fail\""
                                      " attribute on the \"stop\" operation"
                                      " instead");
                }
@@ -706,7 +706,7 @@
        if(g_hash_table_lookup(action->meta, "timeout") == NULL) {
                g_hash_table_insert(
                       action->meta, crm_strdup("timeout"),
-                      
crm_strdup(default_action_timeout(data_set->config_hash)));
+                      crm_strdup(pe_pref(data_set->config_hash, 
"default-action-timeout")));
        }
        
        for(;lpc < DIMOF(fields); lpc++) {




------------------------------

_______________________________________________
Linux-ha-cvs mailing list
Linux-ha-cvs@lists.linux-ha.org
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 33, Issue 20
********************************************

Reply via email to