diff --git a/crm/pengine/pengine.h b/crm/pengine/pengine.h index 8f0c373c2a..2c50b5d303 100644 --- a/crm/pengine/pengine.h +++ b/crm/pengine/pengine.h @@ -1,225 +1,217 @@ #ifndef PENGINE__H #define PENGINE__H -typedef GSList* GSListPtr; - - typedef struct node_s node_t; typedef struct color_s color_t; typedef struct rsc_to_node_s rsc_to_node_t; typedef struct rsc_to_rsc_s rsc_to_rsc_t; typedef struct resource_s resource_t; typedef struct order_constraint_s order_constraint_t; typedef struct action_s action_t; typedef struct action_wrapper_s action_wrapper_t; enum con_type { type_none, rsc_to_rsc, rsc_to_node, rsc_to_attr, base_weight }; enum node_type { node_ping, node_member }; enum con_strength { ignore, must, should, should_not, must_not, startstop }; enum con_modifier { modifier_none, set, inc, dec }; enum action_tasks { no_action, stop_rsc, start_rsc, shutdown_crm, stonith_op }; enum action_order { dontcare, before, after }; struct node_shared_s { char *id; gboolean online; gboolean unclean; gboolean shutdown; GSListPtr running_rsc; // resource_t* GHashTable *attrs; // char* => char* enum node_type type; }; struct node_s { float weight; gboolean fixed; struct node_shared_s *details; }; struct color_shared_s { int id; GSListPtr candidate_nodes; // node_t* node_t *chosen_node; }; struct color_s { int id; struct color_shared_s *details; float local_weight; }; struct rsc_to_rsc_s { char *id; resource_t *rsc_lh; // gboolean is_placement; resource_t *rsc_rh; enum con_strength strength; }; struct rsc_to_node_s { char *id; resource_t *rsc_lh; float weight; GSListPtr node_list_rh; // node_t* enum con_modifier modifier; }; struct resource_s { char *id; xmlNodePtr xml; int priority; node_t *cur_node; gboolean runnable; gboolean provisional; action_t *stop; action_t *start; GSListPtr candidate_colors; // color_t* GSListPtr allowed_nodes; // node_t* GSListPtr node_cons; // rsc_to_node_t* GSListPtr rsc_cons; // resource_t* color_t *color; }; struct action_wrapper_s { enum con_strength strength; action_t *action; }; struct action_s { int id; resource_t *rsc; node_t *node; enum action_tasks task; gboolean runnable; gboolean processed; gboolean optional; gboolean failed; gboolean complete; int seen_count; GSListPtr actions_before; // action_warpper_t* GSListPtr actions_after; // action_warpper_t* }; struct order_constraint_s { int id; action_t *lh_action; action_t *rh_action; enum con_strength strength; // enum action_order order; }; extern gboolean stage0(xmlNodePtr cib, GSListPtr *nodes, GSListPtr *rscs, GSListPtr *cons, GSListPtr *actions, GSListPtr *action_constraints, GSListPtr *stonith_list, GSListPtr *shutdown_list); extern gboolean stage1(GSListPtr node_constraints, GSListPtr nodes, GSListPtr resources); extern gboolean stage2(GSListPtr sorted_rscs, GSListPtr sorted_nodes, GSListPtr *colors); extern gboolean stage3(GSListPtr colors); extern gboolean stage4(GSListPtr colors); extern gboolean stage5(GSListPtr resources); extern gboolean stage6(GSListPtr *actions, GSListPtr *action_constraints, GSListPtr stonith, GSListPtr shutdown); extern gboolean stage7(GSListPtr resources, GSListPtr actions, GSListPtr action_constraints, GSListPtr *action_sets); extern gboolean stage8(GSListPtr action_sets, xmlNodePtr *graph); extern gboolean summary(GSListPtr resources); extern gboolean pe_input_dispatch(IPC_Channel *sender, void *user_data); -#define slist_iter(w, x, y, z, a) for(z = 0; z < g_slist_length(y); z++) { \ - x *w = (x*)g_slist_nth_data(y, z); \ - a; \ - } - extern gboolean pe_debug; extern gboolean pe_debug_saved; #define pdebug_action(x) if(pe_debug) { \ x; \ } #define pdebug(x...) if(pe_debug) { \ cl_log(LOG_DEBUG, x); \ } #define pe_debug_on() pe_debug_saved = pe_debug; pe_debug = TRUE; #define pe_debug_off() pe_debug_saved = pe_debug; pe_debug = FALSE; #define pe_debug_restore() pe_debug = pe_debug_saved; #define safe_val(def, x,y) (x==NULL?def:x->y) #define safe_val3(def, t,u,v) safe_val(def, safe_val(NULL, t,u),v) #define safe_val4(def, t,u,v,w) safe_val(def, safe_val(NULL, safe_val(NULL, t,u),v),w) #define safe_val5(def, t,u,v,w,x) safe_val(def, safe_val(NULL, safe_val(NULL, safe_val(NULL, t,u),v),w),x) #define safe_val6(def, t,u,v,w,x,y) safe_val(def, safe_val(NULL, safe_val(NULL, safe_val(NULL, safe_val(NULL, t,u),v),w),x),y) #define safe_val7(def, t,u,v,w,x,y,z) safe_val(def, safe_val(NULL, safe_val(NULL, safe_val(NULL, safe_val(NULL, safe_val(NULL, t,u),v),w),x),y),z) #endif diff --git a/include/crm/crm.h b/include/crm/crm.h index 94b82ce4a1..740b32d9ae 100644 --- a/include/crm/crm.h +++ b/include/crm/crm.h @@ -1,101 +1,108 @@ -/* $Id: crm.h,v 1.5 2004/04/29 15:24:31 andrew Exp $ */ +/* $Id: crm.h,v 1.6 2004/05/06 12:09:35 andrew Exp $ */ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef CRM__H #define CRM__H #include #include +#include /* Clean these up at some point, some probably should be runtime options */ #define WORKING_DIR HA_VARLIBDIR"/heartbeat/crm" #define BIN_DIR "/usr/lib/heartbeat" #define MAXDATASIZE 65535 // ipc comms #define SOCKET_LEN 1024 #define APPNAME_LEN 256 #define LOG_DIR "/var/log" #define MAX_IPC_FAIL 5 #define CIB_FILENAME WORKING_DIR"/cib.xml" #define CIB_BACKUP WORKING_DIR"/cib_backup.xml" #define MSG_LOG 1 #define INTEGRATED_CIB 1 #define DOT_FSA_ACTIONS 1 #define DOT_ALL_FSA_INPUTS 1 //#define FSA_TRACE 1 +#define USE_FAKE_LRM 1 #include #include #include #define safe_str_eq(x, y) x!=NULL && y!=NULL && strcmp(x,y) == 0 -#define safe_str_neq(x, y) x!=NULL && y!=NULL && strcmp(x,y) != 0 +#define safe_str_neq(x, y) x != y && (x==NULL || y==NULL || strcmp(x,y) != 0) /* Developmental debug stuff */ #if 1 # define CRM_DEBUG(w...) cl_log(LOG_DEBUG, w) #else /* these wont work yet, need to cast to void */ # define CRM_DEBUG(w...) if(0) { cl_log(LOG_DEBUG, w); } #endif /* Seriously detailed debug stuff */ #if 0 # define FNIN() cl_log(LOG_DEBUG, "#---#---# Entering %s...", __FUNCTION__) # define FNOUT() { cl_log(LOG_DEBUG, "#---#---# Leaving %s...", __FUNCTION__); return; } # define FNRET(x) { cl_log(LOG_DEBUG, "#---#---# Leaving %s...", __FUNCTION__); return x; } #else # define FNIN() ; # define FNOUT() return; # define FNRET(x) return x; #endif /* Sub-systems */ #define CRM_SYSTEM_DC "dc" #define CRM_SYSTEM_DCIB "dcib" // The master CIB #define CRM_SYSTEM_CIB "cib" #define CRM_SYSTEM_CRMD "crmd" #define CRM_SYSTEM_LRMD "lrmd" #define CRM_SYSTEM_PENGINE "pengine" #define CRM_SYSTEM_TENGINE "tengine" /* Valid operations */ #define CRM_OPERATION_BUMP "bump" #define CRM_OPERATION_QUERY "query" #define CRM_OPERATION_CREATE "create" #define CRM_OPERATION_UPDATE "update" #define CRM_OPERATION_DELETE "delete" #define CRM_OPERATION_ERASE "erase" #define CRM_OPERATION_STORE "store" #define CRM_OPERATION_REPLACE "replace" #define CRM_OPERATION_FORWARD "forward" #define CRM_OPERATION_JOINACK "join_ack" #define CRM_OPERATION_WELCOME "welcome" #define CRM_OPERATION_PING "ping" #define CRM_OPERATION_VOTE "vote" #define CRM_OPERATION_ANNOUNCE "announce" #define CRM_OPERATION_HBEAT "dc_beat" #define CRM_OPERATION_SHUTDOWN "shutdown" #define CRM_OPERATION_SHUTDOWN_REQ "req_shutdown" -#define CRM_XMLCOMPRESS_OFF 0 -#define CRM_XMLCOMPRESS_ON 9 +typedef GSList* GSListPtr; + +#define slist_iter(w, x, y, z, a) for(z = 0; z < g_slist_length(y); z++) { \ + x *w = (x*)g_slist_nth_data(y, z); \ + a; \ + } + #endif