Send Linux-ha-cvs mailing list submissions to
[email protected]
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: crm by andrew from
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Wed, 7 Jun 2006 06:47:04 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: crm by andrew from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : andrew
Host :
Project : linux-ha
Module : crm
Dir : linux-ha/crm/pengine
Modified Files:
Makefile.am graph.c group.c master.c native.c pengine.c
ptest.c
Added Files:
allocate.c allocate.h clone.c
Removed Files:
color.c complex.c complex.h incarnation.c pe_rules.h
pe_utils.h pengine.h rules.c stages.c unpack.c utils.c
Log Message:
Split the PE into three distinct parts:
- a library for processing rules
- a library for determining the current cluster status
- and a library for calculating the next cluster state
Most tools (such as crm_mon) will only need to use the 2nd library
The first library can be used by the crmd to parse its options (without
needing the rest of the PE)
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/pengine/Makefile.am,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- Makefile.am 3 Apr 2006 09:51:56 -0000 1.33
+++ Makefile.am 7 Jun 2006 12:46:57 -0000 1.34
@@ -40,9 +40,8 @@
$(top_builddir)/lib/clplumbing/libplumb.la \
$(top_builddir)/lib/pils/libpils.la \
$(top_builddir)/lib/crm/common/libcrmcommon.la \
+ $(top_builddir)/lib/crm/pengine/libpe_status.la \
libpengine.la \
- $(top_builddir)/lib/crm/cib/libcib.la \
- $(top_builddir)/lib/apphb/libapphb.la \
$(GLIBLIB) \
$(CURSESLIBS) \
$(LIBRT)
@@ -57,34 +56,28 @@
halib_PROGRAMS = ptest pengine
## SOURCES
+noinst_HEADERS = allocate.h
+#utils.h pengine.h
-libpengine_la_SOURCES = color.c unpack.c graph.c rules.c pengine.c \
- utils.c complex.c native.c stages.c \
- group.c incarnation.c master.c
-
-libpengine_la_LDFLAGS = -version-info 2:0:1
-
-noinst_HEADERS = pe_utils.h pengine.h complex.h pe_rules.h
-
-ptest_SOURCES = ptest.c
-
-ptest_CFLAGS = -DHA_VARLIBDIR='"@HA_VARLIBDIR@"'
-ptest_LDFLAGS =
-ptest_LDADD = $(COMMONLIBS) \
- $(top_builddir)/lib/crm/transition/libtransitioner.la
+libpengine_la_LDFLAGS = -version-info 3:0:0
+# -L$(top_builddir)/lib/pils -lpils -export-dynamic -module -avoid-version
+libpengine_la_SOURCES = pengine.c allocate.c \
+ native.c group.c clone.c master.c graph.c
pengine_SOURCES = main.c
-
pengine_CFLAGS = -DHA_VARLIBDIR='"@HA_VARLIBDIR@"'
-pengine_LDFLAGS =
-pengine_LDADD = $(COMMONLIBS) \
- $(top_builddir)/lib/crm/transition/libtransitioner.la \
- $(top_builddir)/lib/hbclient/libhbclient.la
+pengine_LDADD = $(COMMONLIBS) $(top_builddir)/lib/crm/cib/libcib.la
+# libcib for get_object_root()
+# $(top_builddir)/lib/hbclient/libhbclient.la
-#
+ptest_SOURCES = ptest.c
+ptest_CFLAGS = -DHA_VARLIBDIR='"@HA_VARLIBDIR@"'
+ptest_LDADD = $(COMMONLIBS) \
+ $(top_builddir)/lib/crm/cib/libcib.la \
+ $(top_builddir)/lib/crm/transition/libtransitioner.la
clean-generic:
- rm -f *.log *.debug *~
+ rm -f *.log *.debug *~ .gres.* testcases/.gres.*
install-exec-local:
$(mkinstalldirs) $(DESTDIR)/$(pe_varlibdir)
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/pengine/graph.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -3 -r1.96 -r1.97
--- graph.c 7 Jun 2006 07:34:38 -0000 1.96
+++ graph.c 7 Jun 2006 12:46:57 -0000 1.97
@@ -1,4 +1,4 @@
-/* $Id: graph.c,v 1.96 2006/06/07 07:34:38 andrew Exp $ */
+/* $Id: graph.c,v 1.97 2006/06/07 12:46:57 andrew Exp $ */
/*
* Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
*
@@ -28,8 +28,8 @@
#include <glib.h>
-#include <pengine.h>
-#include <pe_utils.h>
+#include <lib/crm/pengine/utils.h>
+#include <allocate.h>
gboolean update_action(action_t *action);
@@ -46,8 +46,6 @@
return TRUE;
}
-#define UPDATE_THEM 1
-
gboolean
update_action(action_t *action)
{
@@ -212,7 +210,7 @@
if(stonith_op != NULL) {
slist_iter(
rsc, resource_t, data_set->resources, lpc,
- rsc->fns->stonith_ordering(rsc, stonith_op, data_set);
+ rsc->cmds->stonith_ordering(rsc, stonith_op, data_set);
);
}
@@ -225,7 +223,6 @@
if(rsc->is_managed == FALSE) {
crm_debug_2("Skipping fencing constraints for unmanaged
resource: %s", rsc->id);
continue;
-
}
key = stop_key(rsc);
@@ -266,7 +263,7 @@
if(parent) {
crm_info("Re-creating actions for %s",
parent->id);
- parent->fns->create_actions(
+ parent->cmds->create_actions(
parent, data_set);
}
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/pengine/group.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -3 -r1.63 -r1.64
--- group.c 30 May 2006 07:47:44 -0000 1.63
+++ group.c 7 Jun 2006 12:46:57 -0000 1.64
@@ -1,4 +1,4 @@
-/* $Id: group.c,v 1.63 2006/05/30 07:47:44 andrew Exp $ */
+/* $Id: group.c,v 1.64 2006/06/07 12:46:57 andrew Exp $ */
/*
* Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
*
@@ -19,10 +19,11 @@
#include <portability.h>
-#include <pengine.h>
-#include <pe_utils.h>
+#include <lib/crm/pengine/pengine.h>
+#include <lib/crm/pengine/utils.h>
#include <crm/msg_xml.h>
#include <clplumbing/cl_misc.h>
+#include <allocate.h>
extern gboolean rsc_colocation_new(
const char *id, enum con_strength strength,
@@ -55,110 +56,16 @@
void group_assign_color(resource_t *rsc, color_t *group_color);
-gboolean group_unpack(resource_t *rsc, pe_working_set_t *data_set)
-{
- resource_t *self = NULL;
- crm_data_t *xml_obj = rsc->xml;
- crm_data_t *xml_self = copy_xml(rsc->xml);
- group_variant_data_t *group_data = NULL;
- const char *group_ordered = g_hash_table_lookup(
- rsc->meta, XML_RSC_ATTR_ORDERED);
- const char *group_colocated = g_hash_table_lookup(
- rsc->meta, "collocated");
- const char *clone_id = NULL;
-
- crm_debug_3("Processing resource %s...", rsc->id);
-/* rsc->id = "dummy_group_rsc_id"; */
-
- crm_malloc0(group_data, sizeof(group_variant_data_t));
- group_data->num_children = 0;
- group_data->self = NULL;
- group_data->child_list = NULL;
- group_data->first_child = NULL;
- group_data->last_child = NULL;
- rsc->variant_opaque = group_data;
-
- group_data->ordered = TRUE;
- group_data->colocated = TRUE;
-
- if(group_ordered != NULL) {
- cl_str_to_boolean(group_ordered, &(group_data->ordered));
- }
- if(group_colocated != NULL) {
- cl_str_to_boolean(group_colocated, &(group_data->colocated));
- }
-
- /* this is a bit of a hack - but simplifies everything else */
- ha_msg_mod(xml_self, F_XML_TAGNAME, XML_CIB_TAG_RESOURCE);
-/* set_id(xml_self, "self", -1); */
-
- if(common_unpack(xml_self, &self, NULL, data_set)) {
- group_data->self = self;
- self->restart_type = pe_restart_restart;
-
- } else {
- crm_log_xml_err(xml_self, "Couldnt unpack dummy child");
- return FALSE;
- }
-
- clone_id = crm_element_value(rsc->xml, XML_RSC_ATTR_INCARNATION);
-
- xml_child_iter_filter(
- xml_obj, xml_native_rsc, XML_CIB_TAG_RESOURCE,
-
- resource_t *new_rsc = NULL;
- crm_xml_add(xml_native_rsc, XML_RSC_ATTR_INCARNATION, clone_id);
- if(common_unpack(xml_native_rsc, &new_rsc,
- rsc, data_set) == FALSE) {
- pe_err("Failed unpacking resource %s",
- crm_element_value(xml_obj, XML_ATTR_ID));
- if(new_rsc != NULL && new_rsc->fns != NULL) {
- new_rsc->fns->free(new_rsc);
- }
- }
-
- group_data->num_children++;
- group_data->child_list = g_list_append(
- group_data->child_list, new_rsc);
-
- if(group_data->first_child == NULL) {
- group_data->first_child = new_rsc;
-
- } else if(group_data->colocated) {
- rsc_colocation_new(
- "pe_group_internal_colo", pecs_must,
- group_data->first_child, new_rsc,
- NULL, NULL);
- }
- group_data->last_child = new_rsc;
- print_resource(LOG_DEBUG_3, "Added", new_rsc, FALSE);
- );
-
- if(group_data->num_children == 0) {
- pe_config_err("Group %s did not have any children", rsc->id);
- return FALSE;
- }
-
- crm_debug_3("Added %d children to resource %s...",
- group_data->num_children, rsc->id);
-
- return TRUE;
-}
-
-
-resource_t *
-group_find_child(resource_t *rsc, const char *id)
-{
- group_variant_data_t *group_data = NULL;
- get_group_variant_data(group_data, rsc);
- return pe_find_resource(group_data->child_list, id);
-}
-
-GListPtr group_children(resource_t *rsc)
+void group_set_cmds(resource_t *rsc)
{
group_variant_data_t *group_data = NULL;
get_group_variant_data(group_data, rsc);
- return group_data->child_list;
+ group_data->self->cmds =
&resource_class_alloc_functions[group_data->self->variant];
+ slist_iter(
+ child_rsc, resource_t, group_data->child_list, lpc,
+ child_rsc->cmds =
&resource_class_alloc_functions[child_rsc->variant];
+ child_rsc->cmds->set_cmds(child_rsc);
+ );
}
int group_num_allowed_nodes(resource_t *rsc)
@@ -169,7 +76,7 @@
pe_config_err("Cannot clone non-colocated group: %s", rsc->id);
return 0;
}
- return group_data->self->fns->num_allowed_nodes(group_data->self);
+ return group_data->self->cmds->num_allowed_nodes(group_data->self);
}
color_t *
@@ -183,7 +90,7 @@
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- group_color = child_rsc->fns->color(child_rsc, data_set);
+ group_color = child_rsc->cmds->color(child_rsc, data_set);
CRM_CHECK(group_color != NULL, continue);
native_assign_color(rsc, group_color);
);
@@ -217,7 +124,7 @@
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- child_rsc->fns->create_actions(child_rsc, data_set);
+ child_rsc->cmds->create_actions(child_rsc, data_set);
group_update_pseudo_status(rsc, child_rsc);
);
@@ -270,7 +177,7 @@
group_variant_data_t *group_data = NULL;
get_group_variant_data(group_data, rsc);
- group_data->self->fns->internal_constraints(group_data->self, data_set);
+ group_data->self->cmds->internal_constraints(group_data->self,
data_set);
custom_action_order(
group_data->self, stopped_key(group_data->self), NULL,
@@ -290,7 +197,7 @@
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- child_rsc->fns->internal_constraints(child_rsc, data_set);
+ child_rsc->cmds->internal_constraints(child_rsc, data_set);
if(group_data->ordered == FALSE) {
order_start_start(
@@ -371,7 +278,7 @@
CRM_CHECK(group_data->self != NULL, return);
if(group_data->colocated) {
- group_data->first_child->fns->rsc_colocation_lh(
+ group_data->first_child->cmds->rsc_colocation_lh(
group_data->first_child, rsc_rh, constraint);
return;
}
@@ -384,7 +291,7 @@
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- child_rsc->fns->rsc_colocation_lh(
+ child_rsc->cmds->rsc_colocation_lh(
child_rsc, rsc_rh, constraint);
);
}
@@ -401,7 +308,7 @@
print_resource(LOG_DEBUG_3, "LHS", rsc_lh, TRUE);
if(group_data->colocated) {
- group_data->first_child->fns->rsc_colocation_rh(
+ group_data->first_child->cmds->rsc_colocation_rh(
rsc_lh, group_data->first_child, constraint);
return;
}
@@ -414,7 +321,7 @@
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- child_rsc->fns->rsc_colocation_rh(
+ child_rsc->cmds->rsc_colocation_rh(
rsc_lh, child_rsc, constraint);
);
}
@@ -448,7 +355,7 @@
crm_free(start_id);
crm_free(stop_id);
- group_data->self->fns->rsc_order_lh(group_data->self, order);
+ group_data->self->cmds->rsc_order_lh(group_data->self, order);
}
void group_rsc_order_rh(
@@ -463,7 +370,7 @@
return;
}
- group_data->self->fns->rsc_order_rh(lh_action, group_data->self, order);
+ group_data->self->cmds->rsc_order_rh(lh_action, group_data->self,
order);
}
void group_rsc_location(resource_t *rsc, rsc_to_node_t *constraint)
@@ -473,11 +380,11 @@
crm_debug_3("Processing actions from %s", group_data->self->id);
- group_data->self->fns->rsc_location(group_data->self, constraint);
+ group_data->self->cmds->rsc_location(group_data->self, constraint);
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- child_rsc->fns->rsc_location(child_rsc, constraint);
+ child_rsc->cmds->rsc_location(child_rsc, constraint);
);
}
@@ -489,104 +396,16 @@
crm_debug_3("Processing actions from %s", rsc->id);
CRM_CHECK(group_data->self != NULL, return);
- group_data->self->fns->expand(group_data->self, data_set);
+ group_data->self->cmds->expand(group_data->self, data_set);
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- child_rsc->fns->expand(child_rsc, data_set);
+ child_rsc->cmds->expand(child_rsc, data_set);
);
}
-gboolean group_active(resource_t *rsc, gboolean all)
-{
- group_variant_data_t *group_data = NULL;
- get_group_variant_data(group_data, rsc);
-
- slist_iter(
- child_rsc, resource_t, group_data->child_list, lpc,
- gboolean child_active = child_rsc->fns->active(child_rsc, all);
- if(all == FALSE && child_active) {
- return TRUE;
- } else if(child_active == FALSE) {
- return FALSE;
- }
- );
- if(all) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-void group_print(
- resource_t *rsc, const char *pre_text, long options, void *print_data)
-{
- const char *child_text = NULL;
- group_variant_data_t *group_data = NULL;
- get_group_variant_data(group_data, rsc);
- if(pre_text != NULL) {
- child_text = " ";
- } else {
- child_text = " ";
- }
-
- status_print("%sResource Group: %s",
- pre_text?pre_text:"", rsc->id);
-
- if(options & pe_print_html) {
- status_print("\n<ul>\n");
-
- } else if((options & pe_print_log) == 0) {
- status_print("\n");
- }
-
- slist_iter(
- child_rsc, resource_t, group_data->child_list, lpc,
-
- if(options & pe_print_html) {
- status_print("<li>\n");
- }
- child_rsc->fns->print(
- child_rsc, child_text, options, print_data);
- if(options & pe_print_html) {
- status_print("</li>\n");
- }
- );
-
- if(options & pe_print_html) {
- status_print("</ul>\n");
- }
-}
-
-void group_free(resource_t *rsc)
-{
- group_variant_data_t *group_data = NULL;
- CRM_CHECK(rsc != NULL, return);
- get_group_variant_data(group_data, rsc);
-
- crm_debug_3("Freeing %s", rsc->id);
-
- slist_iter(
- child_rsc, resource_t, group_data->child_list, lpc,
-
- crm_debug_3("Freeing child %s", child_rsc->id);
- child_rsc->fns->free(child_rsc);
- );
-
- crm_debug_3("Freeing child list");
- pe_free_shallow_adv(group_data->child_list, FALSE);
-
- if(group_data->self != NULL) {
- free_xml(group_data->self->xml);
- group_data->self->fns->free(group_data->self);
- }
-
- common_free(rsc);
-}
-
-
void
group_agent_constraints(resource_t *rsc)
{
@@ -596,28 +415,8 @@
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- child_rsc->fns->agent_constraints(child_rsc);
- );
-}
-
-enum rsc_role_e
-group_resource_state(resource_t *rsc)
-{
- enum rsc_role_e group_role = RSC_ROLE_UNKNOWN;
- group_variant_data_t *group_data = NULL;
- get_group_variant_data(group_data, rsc);
-
- slist_iter(
- child_rsc, resource_t, group_data->child_list, lpc,
-
- if(child_rsc->next_role > group_role) {
- group_role = rsc->next_role;
- }
- if(child_rsc->failed) {
- rsc->failed = TRUE;
- }
+ child_rsc->cmds->agent_constraints(child_rsc);
);
- return group_role;
}
void
@@ -630,7 +429,7 @@
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- child_rsc->fns->create_notify_element(
+ child_rsc->cmds->create_notify_element(
child_rsc, op, n_data, data_set);
);
}
@@ -646,7 +445,7 @@
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- any_created = child_rsc->fns->create_probe(
+ any_created = child_rsc->cmds->create_probe(
child_rsc, node, complete, force, data_set) ||
any_created;
);
return any_created;
@@ -664,7 +463,7 @@
slist_iter(
child_rsc, resource_t, group_data->child_list, lpc,
- child_rsc->fns->stonith_ordering(
+ child_rsc->cmds->stonith_ordering(
child_rsc, stonith_op, data_set);
);
#endif
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/pengine/master.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- master.c 7 Jun 2006 10:09:32 -0000 1.21
+++ master.c 7 Jun 2006 12:46:58 -0000 1.22
@@ -1,4 +1,4 @@
-/* $Id: master.c,v 1.21 2006/06/07 10:09:32 andrew Exp $ */
+/* $Id: master.c,v 1.22 2006/06/07 12:46:58 andrew Exp $ */
/*
* Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
*
@@ -19,9 +19,9 @@
#include <portability.h>
-#include <pengine.h>
-#include <pe_utils.h>
#include <crm/msg_xml.h>
+#include <allocate.h>
+#include <lib/crm/pengine/utils.h>
extern void clone_create_notifications(
resource_t *rsc, action_t *action, action_t *action_complete,
@@ -54,13 +54,6 @@
CRM_ASSERT(rsc->variant == pe_master); \
data = (clone_variant_data_t *)rsc->variant_opaque;
-gboolean master_unpack(resource_t *rsc, pe_working_set_t *data_set)
-{
- add_hash_param(rsc->parameters, crm_meta_name("stateful"),
- XML_BOOLEAN_TRUE);
- return clone_unpack(rsc, data_set);
-}
-
static void
child_promoting_constraints(
clone_variant_data_t *clone_data, enum pe_ordering type,
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/pengine/native.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -3 -r1.148 -r1.149
--- native.c 2 Jun 2006 15:36:21 -0000 1.148
+++ native.c 7 Jun 2006 12:46:59 -0000 1.149
@@ -1,4 +1,4 @@
-/* $Id: native.c,v 1.148 2006/06/02 15:36:21 andrew Exp $ */
+/* $Id: native.c,v 1.149 2006/06/07 12:46:59 andrew Exp $ */
/*
* Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
*
@@ -19,9 +19,11 @@
#include <portability.h>
-#include <pengine.h>
-#include <pe_utils.h>
+#include <lib/crm/pengine/pengine.h>
+#include <crm/pengine/rules.h>
+#include <lib/crm/pengine/utils.h>
#include <crm/msg_xml.h>
+#include <allocate.h>
#define DELETE_THEN_REFRESH 1
@@ -56,7 +58,7 @@
void NoRoleChange(resource_t *rsc, node_t *current, node_t *next,
pe_working_set_t *data_set);
gboolean StopRsc(resource_t *rsc, node_t *next, pe_working_set_t *data_set);
gboolean StartRsc(resource_t *rsc, node_t *next, pe_working_set_t *data_set);
-gboolean DemoteRsc(resource_t *rsc, node_t *next, pe_working_set_t *data_set);
+extern gboolean DemoteRsc(resource_t *rsc, node_t *next, pe_working_set_t
*data_set);
gboolean PromoteRsc(resource_t *rsc, node_t *next, pe_working_set_t *data_set);
gboolean RoleError(resource_t *rsc, node_t *next, pe_working_set_t *data_set);
gboolean NullOp(resource_t *rsc, node_t *next, pe_working_set_t *data_set);
@@ -93,168 +95,18 @@
CRM_ASSERT(rsc->variant_opaque != NULL); \
data = (native_variant_data_t *)rsc->variant_opaque;
-void
-native_add_running(resource_t *rsc, node_t *node, pe_working_set_t *data_set)
+void native_set_cmds(resource_t *rsc)
{
- CRM_CHECK(node != NULL, return);
-
- slist_iter(
- a_node, node_t, rsc->running_on, lpc,
- CRM_CHECK(a_node != NULL, return);
- if(safe_str_eq(a_node->details->id, node->details->id)) {
- return;
- }
- );
-
- rsc->running_on = g_list_append(rsc->running_on, node);
- if(rsc->variant == pe_native) {
- node->details->running_rsc = g_list_append(
- node->details->running_rsc, rsc);
- }
-
- if(rsc->variant != pe_native) {
- } else if(rsc->is_managed == FALSE) {
- crm_info("resource %s isnt managed", rsc->id);
- rsc2node_new(
- "not_managed_default", rsc, INFINITY, node, data_set);
- return;
-
-#if 0
- } else if(rsc->failed) {
- crm_info("Skipping resource stickiness for failed resource %s",
- rsc->id);
-#endif
- } else if(rsc->stickiness > 0 || rsc->stickiness < 0) {
- rsc2node_new("stickiness", rsc, rsc->stickiness, node,data_set);
- crm_debug("Resource %s: preferring current location (%s/%s)",
- rsc->id, node->details->uname, node->details->id);
- }
-
- if(rsc->variant == pe_native && g_list_length(rsc->running_on) > 1) {
- const char *type = crm_element_value(rsc->xml, XML_ATTR_TYPE);
- const char *class = crm_element_value(
- rsc->xml, XML_AGENT_ATTR_CLASS);
-
-
- /* these are errors because hardly any gets it right
- * at the moment and this way the might notice
- */
- pe_err("Resource %s::%s:%s appears to be active on %d nodes.",
- class, type, rsc->id, g_list_length(rsc->running_on));
- cl_log(LOG_ERR, "See %s for more information.",
- HAURL("v2/faq/resource_too_active"));
-
- if(rsc->recovery_type == recovery_stop_only) {
- native_assign_color(rsc, data_set->no_color);
-
- } else if(rsc->recovery_type == recovery_block) {
- rsc->is_managed = FALSE;
- }
-
- } else {
- crm_debug_2("Resource %s is active on: %s",
- rsc->id, node->details->uname);
- }
-
- if(rsc->parent != NULL) {
- native_add_running(rsc->parent, node, data_set);
- }
-
-}
-
-
-gboolean native_unpack(resource_t *rsc, pe_working_set_t *data_set)
-{
- native_variant_data_t *native_data = NULL;
-
- crm_debug_3("Processing resource %s...", rsc->id);
-
- crm_malloc0(native_data, sizeof(native_variant_data_t));
-
- rsc->allowed_nodes = NULL;
- rsc->running_on = NULL;
-
- rsc->variant_opaque = native_data;
- return TRUE;
-}
-
-
-resource_t *
-native_find_child(resource_t *rsc, const char *id)
-{
- return NULL;
-}
-
-GListPtr native_children(resource_t *rsc)
-{
- return NULL;
-}
-
-static void
-hash_copy_field(gpointer key, gpointer value, gpointer user_data)
-{
- const char *name = key;
- const char *s_value = value;
-
- GHashTable *hash_copy = user_data;
- g_hash_table_insert(hash_copy, crm_strdup(name), crm_strdup(s_value));
-}
-
-char *
-native_parameter(
- resource_t *rsc, node_t *node, gboolean create, const char *name,
- pe_working_set_t *data_set)
-{
- char *value_copy = NULL;
- const char *value = NULL;
- GHashTable *hash = rsc->parameters;
- GHashTable *local_hash = NULL;
-
- CRM_CHECK(rsc != NULL, return NULL);
- CRM_CHECK(name != NULL && strlen(name) != 0, return NULL);
-
- crm_debug_2("Looking up %s in %s", name, rsc->id);
-
- if(create) {
- if(node != NULL) {
- crm_debug_2("Creating hash with node %s",
- node->details->uname);
- } else {
- crm_debug_2("Creating default hash");
- }
-
- local_hash = g_hash_table_new_full(
- g_str_hash, g_str_equal,
- g_hash_destroy_str, g_hash_destroy_str);
-
- g_hash_table_foreach(
- rsc->parameters, hash_copy_field, local_hash);
- unpack_instance_attributes(
- rsc->xml, XML_TAG_ATTR_SETS, node, local_hash,
- NULL, 0, data_set);
-
- hash = local_hash;
- }
-
- value = g_hash_table_lookup(hash, name);
- if(value == NULL) {
- /* try meta attributes instead */
- value = g_hash_table_lookup(rsc->meta, name);
- }
-
- if(value != NULL) {
- value_copy = crm_strdup(value);
- }
- if(local_hash != NULL) {
- g_hash_table_destroy(local_hash);
- }
- return value_copy;
}
int native_num_allowed_nodes(resource_t *rsc)
{
int num_nodes = 0;
+ if(rsc->next_role == RSC_ROLE_STOPPED) {
+ return 0;
+ }
+
if(rsc->color) {
crm_debug_4("Colored case");
num_nodes = num_allowed_nodes4color(rsc->color);
@@ -330,7 +182,7 @@
if(rsc->provisional == FALSE) {
return rsc->color;
}
-
+
rsc->rsc_cons = g_list_sort(
rsc->rsc_cons, sort_cons_strength);
@@ -342,10 +194,10 @@
print_rsc_colocation(
"Pre-Processing constraint", constraint,FALSE));
- rsc->fns->rsc_colocation_lh(
+ rsc->cmds->rsc_colocation_lh(
rsc, constraint->rsc_rh, constraint);
);
-
+
if( native_choose_color(rsc, data_set->no_color) ) {
crm_debug_3("Colored resource %s with color %d",
rsc->id, rsc->color->id);
@@ -376,7 +228,7 @@
crm_action_debug_3(
print_rsc_colocation(
"Post-Processing constraint",constraint,FALSE));
- rsc->fns->rsc_colocation_lh(
+ rsc->cmds->rsc_colocation_lh(
rsc, constraint->rsc_rh, constraint);
);
#endif
@@ -529,8 +381,9 @@
}
unpack_instance_attributes(
- rsc->xml, XML_TAG_ATTR_SETS, chosen, rsc->parameters,
- NULL, 0, data_set);
+ rsc->xml, XML_TAG_ATTR_SETS,
+ chosen?chosen->details->attrs:NULL,
+ rsc->parameters, NULL, data_set->now);
crm_debug("%s: %s->%s", rsc->id,
role2text(rsc->role), role2text(rsc->next_role));
@@ -604,7 +457,7 @@
crm_debug_2("Processing colocation constraint between %s and %s",
rsc_lh->id, rsc_rh->id);
- rsc_rh->fns->rsc_colocation_rh(rsc_lh, rsc_rh, constraint);
+ rsc_rh->cmds->rsc_colocation_rh(rsc_lh, rsc_rh, constraint);
}
static gboolean
@@ -830,7 +683,7 @@
}
if(rh_rsc) {
- rh_rsc->fns->rsc_order_rh(
+ rh_rsc->cmds->rsc_order_rh(
lh_action_iter, rh_rsc, order);
} else if(order->rh_action) {
@@ -936,198 +789,6 @@
);
}
-gboolean native_active(resource_t *rsc, gboolean all)
-{
- slist_iter(
- a_node, node_t, rsc->running_on, lpc,
-
- if(a_node->details->online == FALSE) {
- crm_debug("Resource %s: node %s is offline",
- rsc->id, a_node->details->uname);
- } else if(a_node->details->unclean) {
- crm_debug("Resource %s: node %s is unclean",
- rsc->id, a_node->details->uname);
- } else {
- crm_debug("Resource %s active on %s",
- rsc->id, a_node->details->uname);
- return TRUE;
- }
- );
-
- return FALSE;
-}
-
-struct print_data_s
-{
- long options;
- void *print_data;
-};
-
-static void native_print_attr(gpointer key, gpointer value, gpointer user_data)
-{
- long options = ((struct print_data_s*)user_data)->options;
- void *print_data = ((struct print_data_s*)user_data)->print_data;
- status_print("Option: %s = %s\n", (char*)key, (char*)value);
-}
-
-void
-native_print(
- resource_t *rsc, const char *pre_text, long options, void *print_data)
-{
- node_t *node = NULL;
- const char *prov = NULL;
- const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
-
- if(safe_str_eq(class, "ocf")) {
- prov = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
- }
-
- if(rsc->running_on != NULL) {
- node = rsc->running_on->data;
- }
-
- if(options & pe_print_html) {
- if(rsc->is_managed == FALSE) {
- status_print("<font color=\"yellow\">");
-
- } else if(rsc->failed) {
- status_print("<font color=\"red\">");
-
- } else if(rsc->variant == pe_native
- && g_list_length(rsc->running_on) == 0) {
- status_print("<font color=\"red\">");
-
- } else if(g_list_length(rsc->running_on) > 1) {
- status_print("<font color=\"orange\">");
-
- } else {
- status_print("<font color=\"green\">");
- }
- }
-
- if((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
- const char *desc = NULL;
- desc = crm_element_value(rsc->xml, XML_ATTR_DESC);
- status_print("%s%s\t(%s%s%s:%s)%s%s",
- pre_text?pre_text:"", rsc->id,
- prov?prov:"", prov?"::":"",
- class, crm_element_value(rsc->xml, XML_ATTR_TYPE),
- desc?": ":"", desc?desc:"");
-
- } else {
- status_print("%s%s\t(%s%s%s:%s):\t%s %s%s%s",
- pre_text?pre_text:"", rsc->id,
- prov?prov:"", prov?"::":"",
- class, crm_element_value(rsc->xml, XML_ATTR_TYPE),
- (rsc->variant!=pe_native)?"":role2text(rsc->role),
-
(rsc->variant!=pe_native)?"":node!=NULL?node->details->uname:"",
- rsc->is_managed?"":" (unmanaged)", rsc->failed?"
FAILED":"");
-
-#if CURSES_ENABLED
- if(options & pe_print_ncurses) {
- move(-1, 0);
- }
-#endif
- }
-
- if(options & pe_print_html) {
- status_print(" </font> ");
- }
-
- if((options & pe_print_rsconly)) {
-
- } else if(g_list_length(rsc->running_on) > 1) {
- if(options & pe_print_html) {
- status_print("<ul>\n");
- } else if((options & pe_print_printf)
- || (options & pe_print_ncurses)) {
- status_print("[");
- }
-
- slist_iter(node, node_t, rsc->running_on, lpc,
- if(options & pe_print_html) {
- status_print("<li>\n%s",
- node->details->uname);
-
- } else if((options & pe_print_printf)
- || (options & pe_print_ncurses)) {
- status_print("\t%s", node->details->uname);
-
- } else if((options & pe_print_log)) {
- status_print("\t%d : %s",
- lpc, node->details->uname);
-
- } else {
- status_print("%s", node->details->uname);
- }
- if(options & pe_print_html) {
- status_print("</li>\n");
-
- }
- );
-
- if(options & pe_print_html) {
- status_print("</ul>\n");
- } else if((options & pe_print_printf)
- || (options & pe_print_ncurses)) {
- status_print(" ]");
- }
- }
-
- if(options & pe_print_html) {
- status_print("<br/>\n");
- } else if((options & pe_print_printf) || (options & pe_print_ncurses)) {
- status_print("\n");
- }
-
- if(options & pe_print_details) {
- struct print_data_s pdata;
- pdata.options = options;
- pdata.print_data = print_data;
- g_hash_table_foreach(rsc->parameters, native_print_attr,
&pdata);
- }
-
- if(options & pe_print_dev) {
- status_print("%s\t(%s%svariant=%s, priority=%f)",
- pre_text, rsc->provisional?"provisional, ":"",
- rsc->runnable?"":"non-startable, ",
- crm_element_name(rsc->xml),
- (double)rsc->priority);
-
- status_print("%s\t%d candidate colors, %d allowed nodes,"
- " %d rsc_cons",
- pre_text, g_list_length(rsc->candidate_colors),
- g_list_length(rsc->allowed_nodes),
- g_list_length(rsc->rsc_cons));
- }
-
- if(options & pe_print_max_details) {
- status_print("%s\t=== Actions.\n", pre_text);
- slist_iter(
- action, action_t, rsc->actions, lpc,
- log_action(LOG_DEBUG_4, "\trsc action: ", action,
FALSE);
- );
-
- status_print("%s\t=== Colors\n", pre_text);
- slist_iter(
- color, color_t, rsc->candidate_colors, lpc,
- print_color("\t", color, FALSE)
- );
-
- status_print("%s\t=== Allowed Nodes\n", pre_text);
- slist_iter(
- node, node_t, rsc->allowed_nodes, lpc,
- print_node("\t", node, FALSE);
- );
- }
-}
-
-void native_free(resource_t *rsc)
-{
- crm_debug_4("Freeing Allowed Nodes");
- crm_free(rsc->color);
- common_free(rsc);
-}
void native_rsc_colocation_rh_must(resource_t *rsc_lh, gboolean update_lh,
@@ -1579,20 +1240,6 @@
);
}
-
-enum rsc_role_e
-native_resource_state(resource_t *rsc)
-{
- if(rsc->next_role != RSC_ROLE_UNKNOWN) {
- return rsc->next_role;
- }
- if(rsc->role != RSC_ROLE_UNKNOWN) {
- return rsc->role;
- }
-
- return RSC_ROLE_STOPPED;
-}
-
void
create_notifications(resource_t *rsc, pe_working_set_t *data_set)
{
@@ -1760,8 +1407,7 @@
CRM_CHECK(node != NULL, return NULL);
if(node->details->online == FALSE) {
- crm_debug("Skipping notification for %s on %s",
- rsc->id, node->details->uname);
+ crm_info("Skipping notification for %s", rsc->id);
return NULL;
}
@@ -1938,61 +1584,6 @@
return TRUE;
}
-gboolean
-DeleteRsc(resource_t *rsc, node_t *node, pe_working_set_t *data_set)
-{
- action_t *delete = NULL;
- action_t *refresh = NULL;
-
- char *stop = NULL;
- char *start = NULL;
-
- if(rsc->failed) {
- crm_debug_2("Resource %s not deleted from %s: failed",
- rsc->id, node->details->uname);
- return FALSE;
-
- } else if(node == NULL) {
- crm_debug_2("Resource %s not deleted: NULL node", rsc->id);
- return FALSE;
-
- } else if(node->details->unclean || node->details->online == FALSE) {
- crm_debug_2("Resource %s not deleted from %s: unrunnable",
- rsc->id, node->details->uname);
- return FALSE;
- }
-
- stop = stop_key(rsc);
- start = start_key(rsc);
-
- crm_notice("Removing %s from %s",
- rsc->id, node->details->uname);
-
- delete = delete_action(rsc, node);
-
- custom_action_order(
- rsc, stop, NULL, rsc, NULL, delete,
- pe_ordering_optional, data_set);
-
- custom_action_order(
- rsc, NULL, delete, rsc, start, NULL,
- pe_ordering_manditory, data_set);
-
-#if DELETE_THEN_REFRESH
- refresh = custom_action(
- NULL, crm_strdup(CRM_OP_LRM_REFRESH), CRM_OP_LRM_REFRESH,
- node, FALSE, TRUE, data_set);
- add_hash_param(refresh->meta, XML_ATTR_TE_NOWAIT, XML_BOOLEAN_TRUE);
-
- custom_action_order(
- rsc, NULL, delete, NULL, NULL, refresh,
- pe_ordering_optional, data_set);
-#endif
-
-
- return TRUE;
-}
-
gboolean
StartRsc(resource_t *rsc, node_t *next, pe_working_set_t *data_set)
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/pengine/pengine.c,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -3 -r1.113 -r1.114
--- pengine.c 2 Jun 2006 15:39:14 -0000 1.113
+++ pengine.c 7 Jun 2006 12:46:59 -0000 1.114
@@ -1,4 +1,4 @@
-/* $Id: pengine.c,v 1.113 2006/06/02 15:39:14 andrew Exp $ */
+/* $Id: pengine.c,v 1.114 2006/06/07 12:46:59 andrew Exp $ */
/*
* Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
*
@@ -29,18 +29,13 @@
#include <glib.h>
-#include <pengine.h>
-#include <pe_utils.h>
+#include <crm/pengine/status.h>
+#include <lib/crm/pengine/pengine.h>
+#include <lib/crm/pengine/utils.h>
crm_data_t * do_calculations(
pe_working_set_t *data_set, crm_data_t *xml_input, ha_time_t *now);
-gboolean was_processing_error = FALSE;
-gboolean was_processing_warning = FALSE;
-gboolean was_config_error = FALSE;
-gboolean was_config_warning = FALSE;
-unsigned int pengine_input_loglevel = LOG_INFO;
-
#define PE_WORKING_DIR HA_VARLIBDIR"/heartbeat/pengine"
@@ -114,24 +109,10 @@
do_calculations(&data_set, xml_data, NULL);
crm_log_xml_debug_3(data_set.graph, "[out]");
-#if 1
if(send_ipc_reply(sender, msg, data_set.graph) == FALSE) {
crm_err("Answer could not be sent");
}
-#else
- HA_Message *reply = NULL;
- reply = create_reply(msg, NULL);
- if (reply != NULL) {
- char *tmp_file = mktemp(HA_VARRUNHBDIR"/tgraph-XXXXXX");
- write_xml_file(data_set.graph, tmp_file, FALSE);
- ha_msg_add(reply, "on-disk-graph", tmp_file);
- crm_free(tmp_file);
- if(send_ipc_message(sender, reply) == FALSE) {
- crm_err("Answer could not be sent");
- }
- }
-#endif
series_id = get_series();
series_wrap = series[series_id].wrap;
value = g_hash_table_lookup(
@@ -226,7 +207,7 @@
check_and_exit(-1);
#endif
- crm_debug_5("unpack");
+ crm_debug_5("unpack constraints");
stage0(data_set);
#if MEMCHECK_STAGE_0
@@ -312,91 +293,3 @@
return data_set->graph;
}
-
-void
-cleanup_calculations(pe_working_set_t *data_set)
-{
- GListPtr iterator = NULL;
-
- if(data_set == NULL) {
- return;
- }
-
- if(data_set->config_hash != NULL) {
- g_hash_table_destroy(data_set->config_hash);
- }
-
- crm_free(data_set->dc_uuid);
- crm_free(data_set->transition_idle_timeout);
-
- crm_debug_3("deleting order cons");
- pe_free_ordering(data_set->ordering_constraints);
-
- crm_debug_3("deleting actions");
- pe_free_actions(data_set->actions);
-
- crm_debug_3("deleting resources");
- pe_free_resources(data_set->resources);
-
- crm_debug_3("deleting nodes");
- pe_free_nodes(data_set->nodes);
-
- crm_debug_3("deleting colors");
- pe_free_colors(data_set->colors);
-
- crm_debug_3("deleting node cons");
- iterator = data_set->placement_constraints;
- while(iterator) {
- pe_free_rsc_to_node(iterator->data);
- iterator = iterator->next;
- }
- if(data_set->placement_constraints != NULL) {
- g_list_free(data_set->placement_constraints);
- }
- free_xml(data_set->graph);
- free_ha_date(data_set->now);
- free_xml(data_set->input);
- data_set->stonith_action = NULL;
-}
-
-
-void
-set_working_set_defaults(pe_working_set_t *data_set)
-{
- data_set->input = NULL;
- data_set->now = NULL;
- data_set->graph = NULL;
-
- data_set->transition_idle_timeout = crm_strdup("60s");
- data_set->dc_uuid = NULL;
- data_set->dc_node = NULL;
- data_set->have_quorum = FALSE;
- data_set->stonith_enabled = FALSE;
- data_set->stonith_action = NULL;
- data_set->symmetric_cluster = TRUE;
- data_set->is_managed_default = TRUE;
- data_set->no_quorum_policy = no_quorum_freeze;
-
- data_set->remove_after_stop = FALSE;
- data_set->stop_action_orphans = TRUE;
- data_set->stop_rsc_orphans = TRUE;
-
- data_set->config_hash = NULL;
- data_set->nodes = NULL;
- data_set->resources = NULL;
- data_set->ordering_constraints = NULL;
- data_set->placement_constraints = NULL;
-
- data_set->no_color = NULL;
- data_set->colors = NULL;
- data_set->actions = NULL;
-
- data_set->num_synapse = 0;
- data_set->max_valid_nodes = 0;
- data_set->order_id = 1;
- data_set->action_id = 1;
- data_set->color_id = 0;
-
- data_set->default_resource_stickiness = 0;
- data_set->default_resource_fail_stickiness = 0;
-}
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/pengine/ptest.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -3 -r1.75 -r1.76
--- ptest.c 17 May 2006 07:59:02 -0000 1.75
+++ ptest.c 7 Jun 2006 12:46:59 -0000 1.76
@@ -1,4 +1,4 @@
-/* $Id: ptest.c,v 1.75 2006/05/17 07:59:02 andrew Exp $ */
+/* $Id: ptest.c,v 1.76 2006/06/07 12:46:59 andrew Exp $ */
/*
* Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
@@ -42,8 +42,8 @@
# include <getopt.h>
#endif
#include <glib.h>
-#include <pengine.h>
-#include <pe_utils.h>
+#include <lib/crm/pengine/pengine.h>
+#include <lib/crm/pengine/utils.h>
gboolean use_stdin = FALSE;
gboolean inhibit_exit = FALSE;
------------------------------
_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
End of Linux-ha-cvs Digest, Vol 31, Issue 21
********************************************