diff --git a/include/crm/ais.h b/include/crm/ais.h index cf00fff5cd..2ae29e04fc 100644 --- a/include/crm/ais.h +++ b/include/crm/ais.h @@ -1,412 +1,411 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRM_AIS__H # define CRM_AIS__H # include # include # include # include # include # define AIS_IPC_MESSAGE_SIZE 8192*128 # if SUPPORT_COROSYNC # if CS_USES_LIBQB # include # include typedef struct qb_ipc_request_header cs_ipc_header_request_t; typedef struct qb_ipc_response_header cs_ipc_header_response_t; # else # include # include # include static inline int qb_to_cs_error(int a) { return a; } typedef coroipc_request_header_t cs_ipc_header_request_t; typedef coroipc_response_header_t cs_ipc_header_response_t; # endif # else typedef struct { int size __attribute__ ((aligned(8))); int id __attribute__ ((aligned(8))); } __attribute__ ((aligned(8))) cs_ipc_header_request_t; typedef struct { int size __attribute__ ((aligned(8))); int id __attribute__ ((aligned(8))); int error __attribute__ ((aligned(8))); } __attribute__ ((aligned(8))) cs_ipc_header_response_t; # endif # define CRM_MESSAGE_IPC_ACK 0 # ifndef CRM_SERVICE # define CRM_SERVICE PCMK_SERVICE_ID # endif # define MAX_NAME 256 # define AIS_IPC_NAME "ais-crm-ipc" /* *INDENT-OFF* */ #define CRM_NODE_LOST "lost" #define CRM_NODE_MEMBER "member" #define CRM_NODE_ACTIVE CRM_NODE_MEMBER #define CRM_NODE_INACTIVE CRM_NODE_LOST #define CRM_NODE_EVICTED "evicted" typedef struct crm_ais_host_s AIS_Host; typedef struct crm_ais_msg_s AIS_Message; enum crm_ais_msg_class { crm_class_cluster = 0, crm_class_members = 1, crm_class_notify = 2, crm_class_nodeid = 3, crm_class_rmpeer = 4, crm_class_quorum = 5, }; /* order here matters - its used to index into the crm_children array */ enum crm_ais_msg_types { crm_msg_none = 0, crm_msg_ais = 1, crm_msg_lrmd = 2, crm_msg_cib = 3, crm_msg_crmd = 4, crm_msg_attrd = 5, crm_msg_stonithd = 6, crm_msg_te = 7, crm_msg_pe = 8, crm_msg_stonith_ng = 9, }; enum crm_proc_flag { crm_proc_none = 0x00000001, /* 3 messaging types */ crm_proc_heartbeat = 0x00000100, crm_proc_plugin = 0x00000200, crm_proc_cpg = 0x00000400, crm_proc_lrmd = 0x00001000, crm_proc_cib = 0x00002000, crm_proc_crmd = 0x00004000, crm_proc_attrd = 0x00008000, crm_proc_pe = 0x00010000, crm_proc_te = 0x00020000, crm_proc_stonithd = 0x00100000, crm_proc_stonith_ng= 0x00200000, crm_proc_mgmtd = 0x01000000, }; /* *INDENT-ON* */ typedef struct crm_peer_node_s { uint32_t id; uint64_t born; uint64_t last_seen; int32_t votes; uint32_t processes; char *uname; char *state; char *uuid; char *addr; char *version; } crm_node_t; struct crm_ais_host_s { uint32_t id; uint32_t pid; gboolean local; enum crm_ais_msg_types type; uint32_t size; char uname[MAX_NAME]; } __attribute__ ((packed)); struct crm_ais_msg_s { cs_ipc_header_response_t header __attribute__ ((aligned(8))); uint32_t id; gboolean is_compressed; AIS_Host host; AIS_Host sender; uint32_t size; uint32_t compressed_size; /* 584 bytes */ char data[0]; } __attribute__ ((packed)); struct crm_ais_nodeid_resp_s { cs_ipc_header_response_t header __attribute__ ((aligned(8))); uint32_t id; uint32_t counter; char uname[MAX_NAME]; char cname[MAX_NAME]; } __attribute__ ((packed)); struct crm_ais_quorum_resp_s { cs_ipc_header_response_t header __attribute__ ((aligned(8))); uint64_t id; uint32_t votes; uint32_t expected_votes; uint32_t quorate; } __attribute__ ((packed)); static inline const char * msg_type2text(enum crm_ais_msg_types type) { const char *text = "unknown"; switch (type) { case crm_msg_none: text = "unknown"; break; case crm_msg_ais: text = "ais"; break; case crm_msg_cib: text = "cib"; break; case crm_msg_crmd: text = "crmd"; break; case crm_msg_pe: text = "pengine"; break; case crm_msg_te: text = "tengine"; break; case crm_msg_lrmd: text = "lrmd"; break; case crm_msg_attrd: text = "attrd"; break; case crm_msg_stonithd: text = "stonithd"; break; case crm_msg_stonith_ng: text = "stonith-ng"; break; } return text; } static inline const char * peer2text(enum crm_proc_flag proc) { const char *text = "unknown"; switch (proc) { case crm_proc_none: text = "unknown"; break; case crm_proc_plugin: text = "ais"; break; case crm_proc_heartbeat: text = "heartbeat"; break; case crm_proc_cib: text = "cib"; break; case crm_proc_crmd: text = "crmd"; break; case crm_proc_pe: text = "pengine"; break; case crm_proc_te: text = "tengine"; break; case crm_proc_lrmd: text = "lrmd"; break; case crm_proc_attrd: text = "attrd"; break; case crm_proc_stonithd: text = "stonithd"; break; case crm_proc_stonith_ng: text = "stonith-ng"; break; case crm_proc_mgmtd: text = "mgmtd"; break; case crm_proc_cpg: text = "corosync-cpg"; break; } return text; } static inline enum crm_proc_flag text2proc(const char *proc) { /* We only care about these two so far */ if(proc && strcmp(proc, "cib") == 0) { return crm_proc_cib; } else if(proc && strcmp(proc, "crmd") == 0) { return crm_proc_crmd; } return crm_proc_none; } static inline const char * ais_dest(const struct crm_ais_host_s *host) { if (host->local) { return "local"; } else if (host->size > 0) { return host->uname; } else { return ""; } } # define ais_data_len(msg) (msg->is_compressed?msg->compressed_size:msg->size) static inline AIS_Message * ais_msg_copy(const AIS_Message * source) { AIS_Message *target = malloc(sizeof(AIS_Message) + ais_data_len(source)); memcpy(target, source, sizeof(AIS_Message)); memcpy(target->data, source->data, ais_data_len(target)); return target; } static inline const char * ais_error2text(int error) { const char *text = "unknown"; # if SUPPORT_COROSYNC switch (error) { case CS_OK: text = "None"; break; case CS_ERR_LIBRARY: text = "Library error"; break; case CS_ERR_VERSION: text = "Version error"; break; case CS_ERR_INIT: text = "Initialization error"; break; case CS_ERR_TIMEOUT: text = "Timeout"; break; case CS_ERR_TRY_AGAIN: text = "Try again"; break; case CS_ERR_INVALID_PARAM: text = "Invalid parameter"; break; case CS_ERR_NO_MEMORY: text = "No memory"; break; case CS_ERR_BAD_HANDLE: text = "Bad handle"; break; case CS_ERR_BUSY: text = "Busy"; break; case CS_ERR_ACCESS: text = "Access error"; break; case CS_ERR_NOT_EXIST: text = "Doesn't exist"; break; case CS_ERR_NAME_TOO_LONG: text = "Name too long"; break; case CS_ERR_EXIST: text = "Exists"; break; case CS_ERR_NO_SPACE: text = "No space"; break; case CS_ERR_INTERRUPT: text = "Interrupt"; break; case CS_ERR_NAME_NOT_FOUND: text = "Name not found"; break; case CS_ERR_NO_RESOURCES: text = "No resources"; break; case CS_ERR_NOT_SUPPORTED: text = "Not supported"; break; case CS_ERR_BAD_OPERATION: text = "Bad operation"; break; case CS_ERR_FAILED_OPERATION: text = "Failed operation"; break; case CS_ERR_MESSAGE_ERROR: text = "Message error"; break; case CS_ERR_QUEUE_FULL: text = "Queue full"; break; case CS_ERR_QUEUE_NOT_AVAILABLE: text = "Queue not available"; break; case CS_ERR_BAD_FLAGS: text = "Bad flags"; break; case CS_ERR_TOO_BIG: text = "To big"; break; case CS_ERR_NO_SECTIONS: text = "No sections"; break; } # endif return text; } -extern enum crm_ais_msg_types crm_system_type; -extern enum crm_ais_msg_types text2msg_type(const char *text); -extern char *get_ais_data(const AIS_Message * msg); -extern gboolean check_message_sanity(const AIS_Message * msg, const char *data); +enum crm_ais_msg_types text2msg_type(const char *text); +char *get_ais_data(const AIS_Message * msg); +gboolean check_message_sanity(const AIS_Message * msg, const char *data); #endif diff --git a/include/crm/attrd.h b/include/crm/attrd.h index 3711b2453b..32a3426787 100644 --- a/include/crm/attrd.h +++ b/include/crm/attrd.h @@ -1,50 +1,50 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRM_ATTRD__H # define CRM_ATTRD__H # include #define attrd_channel T_ATTRD #define F_ATTRD_KEY "attr_key" #define F_ATTRD_ATTRIBUTE "attr_name" #define F_ATTRD_TASK "task" #define F_ATTRD_VALUE "attr_value" #define F_ATTRD_SET "attr_set" #define F_ATTRD_SECTION "attr_section" #define F_ATTRD_DAMPEN "attr_dampening" #define F_ATTRD_IGNORE_LOCALLY "attr_ignore_locally" #define F_ATTRD_HOST "attr_host" #define F_ATTRD_USER "attr_user" -extern gboolean attrd_update_delegate(crm_ipc_t *ipc, char command, const char *host, +gboolean attrd_update_delegate(crm_ipc_t *ipc, char command, const char *host, const char *name, const char *value, const char *section, const char *set, const char *dampen, const char *user_name); /* API compatability functions */ gboolean attrd_update(crm_ipc_t *cluster, char command, const char *host, const char *name, const char *value, const char *section, const char *set, const char *dampen) QB_GNUC_DEPRECATED; gboolean attrd_lazy_update(char command, const char *host, const char *name, const char *value, const char *section, const char *set, const char *dampen) QB_GNUC_DEPRECATED; gboolean attrd_update_no_mainloop(int *connection, char command, const char *host, const char *name, const char *value, const char *section, const char *set, const char *dampen) QB_GNUC_DEPRECATED; #endif diff --git a/include/crm/cib.h b/include/crm/cib.h index 1373b72ac0..f7fc25c024 100644 --- a/include/crm/cib.h +++ b/include/crm/cib.h @@ -1,311 +1,311 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CIB__H # define CIB__H # include # include # define CIB_FEATURE_SET "2.0" # define USE_PESKY_FRAGMENTS 1 /* use compare_version() for doing comparisons */ enum cib_variant { cib_undefined, cib_native, cib_file, cib_remote, cib_database, cib_edir }; enum cib_state { cib_connected_command, cib_connected_query, cib_disconnected }; enum cib_conn_type { cib_command, cib_query, cib_no_connection, cib_command_nonblocking, }; /* *INDENT-OFF* */ enum cib_call_options { cib_none = 0x00000000, cib_verbose = 0x00000001, cib_xpath = 0x00000002, cib_multiple = 0x00000004, cib_can_create = 0x00000008, cib_discard_reply = 0x00000010, cib_no_children = 0x00000020, cib_scope_local = 0x00000100, cib_dryrun = 0x00000200, cib_sync_call = 0x00001000, cib_inhibit_notify = 0x00010000, cib_quorum_override = 0x00100000, cib_inhibit_bcast = 0x01000000, cib_force_diff = 0x10000000 }; #define cib_default_options = cib_none enum cib_errors { cib_ok = 0, cib_operation = -1, cib_create_msg = -2, cib_not_connected = -3, cib_not_authorized = -4, cib_send_failed = -5, cib_reply_failed = -6, cib_return_code = -7, cib_output_ptr = -8, cib_output_data = -9, cib_connection = -10, cib_authentication = -11, cib_missing = -12, cib_variant = -28, CIBRES_MISSING_ID = -13, CIBRES_MISSING_TYPE = -14, CIBRES_MISSING_FIELD = -15, CIBRES_OBJTYPE_MISMATCH = -16, CIBRES_CORRUPT = -17, CIBRES_OTHER = -18, cib_unknown = -19, cib_STALE = -20, cib_EXISTS = -21, cib_NOTEXISTS = -22, cib_ACTIVATION = -23, cib_NOSECTION = -24, cib_NOOBJECT = -25, cib_NOPARENT = -26, cib_NODECOPY = -27, cib_NOTSUPPORTED = -29, cib_registration_msg = -30, cib_callback_token = -31, cib_callback_register = -32, cib_msg_field_add = -33, cib_client_gone = -34, cib_not_master = -35, cib_client_corrupt = -36, cib_master_timeout = -37, cib_revision_unsupported= -38, cib_revision_unknown = -39, cib_missing_data = -40, cib_remote_timeout = -41, cib_no_quorum = -42, cib_diff_failed = -43, cib_diff_resync = -44, cib_old_data = -45, cib_id_check = -46, cib_dtd_validation = -47, cib_bad_section = -48, cib_bad_digest = -49, cib_bad_permissions = -50, cib_bad_config = -51, cib_invalid_argument = -52, cib_transform_failed = -53, cib_permission_denied = -54, }; /* *INDENT-ON* */ enum cib_update_op { CIB_UPDATE_OP_NONE = 0, CIB_UPDATE_OP_ADD, CIB_UPDATE_OP_MODIFY, CIB_UPDATE_OP_DELETE, CIB_UPDATE_OP_MAX }; enum cib_section { cib_section_none, cib_section_all, cib_section_nodes, cib_section_constraints, cib_section_resources, cib_section_crmconfig, cib_section_status }; # define CIB_OP_SLAVE "cib_slave" # define CIB_OP_SLAVEALL "cib_slave_all" # define CIB_OP_MASTER "cib_master" # define CIB_OP_SYNC "cib_sync" # define CIB_OP_SYNC_ONE "cib_sync_one" # define CIB_OP_ISMASTER "cib_ismaster" # define CIB_OP_BUMP "cib_bump" # define CIB_OP_QUERY "cib_query" # define CIB_OP_CREATE "cib_create" # define CIB_OP_UPDATE "cib_update" # define CIB_OP_MODIFY "cib_modify" # define CIB_OP_DELETE "cib_delete" # define CIB_OP_ERASE "cib_erase" # define CIB_OP_REPLACE "cib_replace" # define CIB_OP_NOTIFY "cib_notify" # define CIB_OP_APPLY_DIFF "cib_apply_diff" # define CIB_OP_UPGRADE "cib_upgrade" # define CIB_OP_DELETE_ALT "cib_delete_alt" # define F_CIB_CLIENTID "cib_clientid" # define F_CIB_CALLOPTS "cib_callopt" # define F_CIB_CALLID "cib_callid" # define F_CIB_CALLDATA "cib_calldata" # define F_CIB_OPERATION "cib_op" # define F_CIB_ISREPLY "cib_isreplyto" # define F_CIB_SECTION "cib_section" # define F_CIB_HOST "cib_host" # define F_CIB_RC "cib_rc" # define F_CIB_DELEGATED "cib_delegated_from" # define F_CIB_OBJID "cib_object" # define F_CIB_OBJTYPE "cib_object_type" # define F_CIB_EXISTING "cib_existing_object" # define F_CIB_SEENCOUNT "cib_seen" # define F_CIB_TIMEOUT "cib_timeout" # define F_CIB_UPDATE "cib_update" # define F_CIB_CALLBACK_TOKEN "cib_async_id" # define F_CIB_GLOBAL_UPDATE "cib_update" # define F_CIB_UPDATE_RESULT "cib_update_result" # define F_CIB_CLIENTNAME "cib_clientname" # define F_CIB_NOTIFY_TYPE "cib_notify_type" # define F_CIB_NOTIFY_ACTIVATE "cib_notify_activate" # define F_CIB_UPDATE_DIFF "cib_update_diff" # define F_CIB_USER "cib_user" # define T_CIB "cib" # define T_CIB_NOTIFY "cib_notify" /* notify sub-types */ # define T_CIB_PRE_NOTIFY "cib_pre_notify" # define T_CIB_POST_NOTIFY "cib_post_notify" # define T_CIB_UPDATE_CONFIRM "cib_update_confirmation" # define T_CIB_DIFF_NOTIFY "cib_diff_notify" # define T_CIB_REPLACE_NOTIFY "cib_refresh_notify" # define cib_channel_ro "cib_ro" # define cib_channel_rw "cib_rw" # define cib_channel_shm "cib_shm" typedef struct cib_s cib_t; typedef struct cib_api_operations_s { int (*variant_op) (cib_t * cib, const char *op, const char *host, const char *section, xmlNode * data, xmlNode ** output_data, int call_options); int (*signon) (cib_t * cib, const char *name, enum cib_conn_type type); int (*signon_raw) (cib_t * cib, const char *name, enum cib_conn_type type, int *async_fd, int *unused); int (*signoff) (cib_t * cib); int (*free) (cib_t * cib); int (*set_op_callback) (cib_t * cib, void (*callback) (const xmlNode * msg, int callid, int rc, xmlNode * output)); int (*add_notify_callback) (cib_t * cib, const char *event, void (*callback) (const char *event, xmlNode * msg)); int (*del_notify_callback) (cib_t * cib, const char *event, void (*callback) (const char *event, xmlNode * msg)); int (*set_connection_dnotify) (cib_t * cib, void (*dnotify) (gpointer user_data)); int (*inputfd) (cib_t * cib); int (*noop) (cib_t * cib, int call_options); int (*ping) (cib_t * cib, xmlNode ** output_data, int call_options); int (*query) (cib_t * cib, const char *section, xmlNode ** output_data, int call_options); int (*query_from) (cib_t * cib, const char *host, const char *section, xmlNode ** output_data, int call_options); int (*is_master) (cib_t * cib); int (*set_master) (cib_t * cib, int call_options); int (*set_slave) (cib_t * cib, int call_options); int (*set_slave_all) (cib_t * cib, int call_options); int (*sync) (cib_t * cib, const char *section, int call_options); int (*sync_from) (cib_t * cib, const char *host, const char *section, int call_options); int (*upgrade) (cib_t * cib, int call_options); int (*bump_epoch) (cib_t * cib, int call_options); int (*create) (cib_t * cib, const char *section, xmlNode * data, int call_options); int (*modify) (cib_t * cib, const char *section, xmlNode * data, int call_options); int (*update) (cib_t * cib, const char *section, xmlNode * data, int call_options); int (*replace) (cib_t * cib, const char *section, xmlNode * data, int call_options); int (*delete) (cib_t * cib, const char *section, xmlNode * data, int call_options); int (*erase) (cib_t * cib, xmlNode ** output_data, int call_options); int (*delete_absolute) (cib_t * cib, const char *section, xmlNode * data, int call_options); int (*quit) (cib_t * cib, int call_options); int (*register_notification) (cib_t * cib, const char *callback, int enabled); gboolean(*register_callback) (cib_t * cib, int call_id, int timeout, gboolean only_success, void *user_data, const char *callback_name, void (*callback) (xmlNode *, int, int, xmlNode *, void *)); int (*delegated_variant_op) (cib_t * cib, const char *op, const char *host, const char *section, xmlNode * data, xmlNode ** output_data, int call_options, const char *user_name); } cib_api_operations_t; struct cib_s { enum cib_state state; enum cib_conn_type type; enum cib_variant variant; int call_id; int call_timeout; void *variant_opaque; GList *notify_list; void (*op_callback) (const xmlNode * msg, int call_id, int rc, xmlNode * output); cib_api_operations_t *cmds; }; /* Core functions */ -extern cib_t *cib_new(void); -extern cib_t *cib_native_new(void); -extern cib_t *cib_file_new(const char *filename); -extern cib_t *cib_remote_new(const char *server, const char *user, const char *passwd, int port, +cib_t *cib_new(void); +cib_t *cib_native_new(void); +cib_t *cib_file_new(const char *filename); +cib_t *cib_remote_new(const char *server, const char *user, const char *passwd, int port, gboolean encrypted); -extern cib_t *cib_new_no_shadow(void); -extern char *get_shadow_file(const char *name); -extern cib_t *cib_shadow_new(const char *name); +cib_t *cib_new_no_shadow(void); +char *get_shadow_file(const char *name); +cib_t *cib_shadow_new(const char *name); -extern void cib_delete(cib_t * cib); +void cib_delete(cib_t * cib); -extern void cib_dump_pending_callbacks(void); -extern int num_cib_op_callbacks(void); -extern void remove_cib_op_callback(int call_id, gboolean all_callbacks); +void cib_dump_pending_callbacks(void); +int num_cib_op_callbacks(void); +void remove_cib_op_callback(int call_id, gboolean all_callbacks); # define add_cib_op_callback(cib, id, flag, data, fn) cib->cmds->register_callback(cib, id, 120, flag, data, #fn, fn) # include # include # define CIB_LIBRARY "libcib.so.1" #endif diff --git a/include/crm/cib_ops.h b/include/crm/cib_ops.h index 1e93086229..f16fb5a79e 100644 --- a/include/crm/cib_ops.h +++ b/include/crm/cib_ops.h @@ -1,96 +1,96 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CIB_OPS__H # define CIB_OPS__H # include # include # include # include # include # include # include # include # include # include # include # include enum cib_errors cib_process_query(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_process_erase(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_process_bump(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_process_replace(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_process_create(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_process_modify(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_process_delete(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_process_diff(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_process_upgrade(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_process_xpath(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer); enum cib_errors cib_update_counter(xmlNode * xml_obj, const char *field, gboolean reset); -extern xmlNode *diff_cib_object(xmlNode * old_cib, xmlNode * new_cib, gboolean suppress); -extern gboolean apply_cib_diff(xmlNode * old, xmlNode * diff, xmlNode ** new); -extern gboolean cib_config_changed(xmlNode * last, xmlNode * next, xmlNode ** diff); -extern gboolean update_results(xmlNode * failed, xmlNode * target, const char *operation, +xmlNode *diff_cib_object(xmlNode * old_cib, xmlNode * new_cib, gboolean suppress); +gboolean apply_cib_diff(xmlNode * old, xmlNode * diff, xmlNode ** new); +gboolean cib_config_changed(xmlNode * last, xmlNode * next, xmlNode ** diff); +gboolean update_results(xmlNode * failed, xmlNode * target, const char *operation, int return_code); #endif diff --git a/include/crm/cib_util.h b/include/crm/cib_util.h index 04f0464306..ce910b2bd5 100644 --- a/include/crm/cib_util.h +++ b/include/crm/cib_util.h @@ -1,136 +1,136 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CIB_UTIL__H # define CIB_UTIL__H /* Utility functions */ -extern const char *get_object_path(const char *object_type); -extern const char *get_object_parent(const char *object_type); -extern xmlNode *get_object_root(const char *object_type, xmlNode * the_root); -extern xmlNode *create_cib_fragment_adv(xmlNode * update, const char *section, const char *source); +const char *get_object_path(const char *object_type); +const char *get_object_parent(const char *object_type); +xmlNode *get_object_root(const char *object_type, xmlNode * the_root); +xmlNode *create_cib_fragment_adv(xmlNode * update, const char *section, const char *source); /* Error Interpretation*/ -extern const char *cib_error2string(enum cib_errors); +const char *cib_error2string(enum cib_errors); -extern xmlNode *createEmptyCib(void); -extern gboolean verifyCibXml(xmlNode * cib); -extern int cib_section2enum(const char *a_section); +xmlNode *createEmptyCib(void); +gboolean verifyCibXml(xmlNode * cib); +int cib_section2enum(const char *a_section); # define create_cib_fragment(update,cib_section) create_cib_fragment_adv(update, cib_section, __FUNCTION__) -extern void fix_cib_diff(xmlNode * last, xmlNode * next, xmlNode * local_diff, gboolean changed); +void fix_cib_diff(xmlNode * last, xmlNode * next, xmlNode * local_diff, gboolean changed); -extern xmlNode *diff_cib_object(xmlNode * old, xmlNode * new, gboolean suppress); +xmlNode *diff_cib_object(xmlNode * old, xmlNode * new, gboolean suppress); -extern gboolean apply_cib_diff(xmlNode * old, xmlNode * diff, xmlNode ** new); +gboolean apply_cib_diff(xmlNode * old, xmlNode * diff, xmlNode ** new); -extern void log_cib_diff(int log_level, xmlNode * diff, const char *function); +void log_cib_diff(int log_level, xmlNode * diff, const char *function); -extern gboolean cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates, +gboolean cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates, int *_admin_epoch, int *_epoch, int *_updates); -extern gboolean cib_version_details(xmlNode * cib, int *admin_epoch, int *epoch, int *updates); +gboolean cib_version_details(xmlNode * cib, int *admin_epoch, int *epoch, int *updates); -extern enum cib_errors update_attr_delegate(cib_t * the_cib, int call_options, +enum cib_errors update_attr_delegate(cib_t * the_cib, int call_options, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *attr_value, gboolean to_console, const char *user_name); static inline enum cib_errors update_attr(cib_t * the_cib, int call_options, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *attr_value, gboolean to_console) { return update_attr_delegate(the_cib, call_options, section, node_uuid, set_type, set_name, attr_id, attr_name, attr_value, to_console, NULL); } -extern enum cib_errors find_nvpair_attr_delegate(cib_t * the_cib, const char *attr, +enum cib_errors find_nvpair_attr_delegate(cib_t * the_cib, const char *attr, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, gboolean to_console, char **value, const char *user_name); static inline enum cib_errors find_nvpair_attr(cib_t * the_cib, const char *attr, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, gboolean to_console, char **value) { return find_nvpair_attr_delegate(the_cib, attr, section, node_uuid, set_type, set_name, attr_id, attr_name, to_console, value, NULL); } -extern enum cib_errors read_attr_delegate(cib_t * the_cib, +enum cib_errors read_attr_delegate(cib_t * the_cib, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, char **attr_value, gboolean to_console, const char *user_name); static inline enum cib_errors read_attr(cib_t * the_cib, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, char **attr_value, gboolean to_console) { return read_attr_delegate(the_cib, section, node_uuid, set_type, set_name, attr_id, attr_name, attr_value, to_console, NULL); } -extern enum cib_errors delete_attr_delegate(cib_t * the_cib, int options, +enum cib_errors delete_attr_delegate(cib_t * the_cib, int options, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *attr_value, gboolean to_console, const char *user_name); static inline enum cib_errors delete_attr(cib_t * the_cib, int options, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *attr_value, gboolean to_console) { return delete_attr_delegate(the_cib, options, section, node_uuid, set_type, set_name, attr_id, attr_name, attr_value, to_console, NULL); } -extern enum cib_errors query_node_uuid(cib_t * the_cib, const char *uname, char **uuid); +enum cib_errors query_node_uuid(cib_t * the_cib, const char *uname, char **uuid); -extern enum cib_errors query_node_uname(cib_t * the_cib, const char *uuid, char **uname); +enum cib_errors query_node_uname(cib_t * the_cib, const char *uuid, char **uname); -extern enum cib_errors set_standby(cib_t * the_cib, +enum cib_errors set_standby(cib_t * the_cib, const char *uuid, const char *scope, const char *standby_value); -extern const char *feature_set(xmlNode * xml_obj); +const char *feature_set(xmlNode * xml_obj); -extern gboolean startCib(const char *filename); -extern xmlNode *get_cib_copy(cib_t * cib); -extern xmlNode *cib_get_generation(cib_t * cib); -extern int cib_compare_generation(xmlNode * left, xmlNode * right); -extern gboolean determine_host(cib_t * cib_conn, char **node_uname, char **node_uuid); +gboolean startCib(const char *filename); +xmlNode *get_cib_copy(cib_t * cib); +xmlNode *cib_get_generation(cib_t * cib); +int cib_compare_generation(xmlNode * left, xmlNode * right); +gboolean determine_host(cib_t * cib_conn, char **node_uname, char **node_uuid); -extern void cib_metadata(void); -extern void verify_cib_options(GHashTable * options); -extern const char *cib_pref(GHashTable * options, const char *name); -extern gboolean cib_read_config(GHashTable * options, xmlNode * current_cib); -extern gboolean cib_internal_config_changed(xmlNode * diff); +void cib_metadata(void); +void verify_cib_options(GHashTable * options); +const char *cib_pref(GHashTable * options, const char *name); +gboolean cib_read_config(GHashTable * options, xmlNode * current_cib); +gboolean cib_internal_config_changed(xmlNode * diff); #endif diff --git a/include/crm/cluster.h b/include/crm/cluster.h index 63230bd0a1..efbb6b13cb 100644 --- a/include/crm/cluster.h +++ b/include/crm/cluster.h @@ -1,129 +1,128 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRM_COMMON_CLUSTER__H # define CRM_COMMON_CLUSTER__H # include # include # include # if SUPPORT_HEARTBEAT # include # include # endif extern gboolean crm_have_quorum; extern GHashTable *crm_peer_cache; extern GHashTable *crm_peer_id_cache; extern unsigned long long crm_peer_seq; -extern void crm_peer_init(void); -extern void crm_peer_destroy(void); -extern char *get_corosync_uuid(uint32_t id, const char *uname); -extern const char *get_node_uuid(uint32_t id, const char *uname); -extern int get_corosync_id(int id, const char *uuid); +void crm_peer_init(void); +void crm_peer_destroy(void); +char *get_corosync_uuid(uint32_t id, const char *uname); +const char *get_node_uuid(uint32_t id, const char *uname); +int get_corosync_id(int id, const char *uuid); -extern gboolean crm_cluster_connect(char **our_uname, char **our_uuid, void *dispatch, +gboolean crm_cluster_connect(char **our_uname, char **our_uuid, void *dispatch, void *destroy, # if SUPPORT_HEARTBEAT ll_cluster_t ** hb_conn # else void **unused # endif ); -extern gboolean init_cman_connection(gboolean(*dispatch) (unsigned long long, gboolean), +gboolean init_cman_connection(gboolean(*dispatch) (unsigned long long, gboolean), void (*destroy) (gpointer)); -extern gboolean init_quorum_connection(gboolean(*dispatch) (unsigned long long, gboolean), +gboolean init_quorum_connection(gboolean(*dispatch) (unsigned long long, gboolean), void (*destroy) (gpointer)); -extern gboolean send_cluster_message(const char *node, enum crm_ais_msg_types service, +gboolean send_cluster_message(const char *node, enum crm_ais_msg_types service, xmlNode * data, gboolean ordered); -extern void destroy_crm_node(gpointer data); +void destroy_crm_node(gpointer data); -extern crm_node_t *crm_get_peer(unsigned int id, const char *uname); +crm_node_t *crm_get_peer(unsigned int id, const char *uname); -extern void crm_update_peer_proc(const char *source, crm_node_t *peer, uint32_t flag, const char *status); -extern crm_node_t *crm_update_peer(const char *source, unsigned int id, uint64_t born, uint64_t seen, int32_t votes, +void crm_update_peer_proc(const char *source, crm_node_t *peer, uint32_t flag, const char *status); +crm_node_t *crm_update_peer(const char *source, unsigned int id, uint64_t born, uint64_t seen, int32_t votes, uint32_t children, const char *uuid, const char *uname, const char *addr, const char *state); -extern guint crm_active_peers(void); -extern gboolean crm_is_peer_active(const crm_node_t * node); -extern guint reap_crm_member(uint32_t id); -extern int crm_terminate_member(int nodeid, const char *uname, IPC_Channel * cluster); -extern int crm_terminate_member_no_mainloop(int nodeid, const char *uname, int *connection); -extern gboolean crm_get_cluster_name(char **cname); +guint crm_active_peers(void); +gboolean crm_is_peer_active(const crm_node_t * node); +guint reap_crm_member(uint32_t id); +int crm_terminate_member(int nodeid, const char *uname, IPC_Channel * cluster); +int crm_terminate_member_no_mainloop(int nodeid, const char *uname, int *connection); +gboolean crm_get_cluster_name(char **cname); # if SUPPORT_HEARTBEAT gboolean crm_is_heartbeat_peer_active(const crm_node_t * node); -extern gboolean ccm_have_quorum(oc_ed_t event); -extern const char *ccm_event_name(oc_ed_t event); -extern crm_node_t *crm_update_ccm_node(const oc_ev_membership_t * oc, int offset, const char *state, +gboolean ccm_have_quorum(oc_ed_t event); +const char *ccm_event_name(oc_ed_t event); +crm_node_t *crm_update_ccm_node(const oc_ev_membership_t * oc, int offset, const char *state, uint64_t seq); # endif # if SUPPORT_COROSYNC extern int ais_fd_sync; -extern GFDSource *ais_source; gboolean crm_is_corosync_peer_active(const crm_node_t * node); -extern gboolean send_ais_text(int class, const char *data, gboolean local, +gboolean send_ais_text(int class, const char *data, gboolean local, const char *node, enum crm_ais_msg_types dest); -extern gboolean get_ais_nodeid(uint32_t * id, char **uname); +gboolean get_ais_nodeid(uint32_t * id, char **uname); # endif -extern void empty_uuid_cache(void); -extern const char *get_uuid(const char *uname); -extern const char *get_uname(const char *uuid); -extern void set_uuid(xmlNode * node, const char *attr, const char *uname); -extern void unget_uuid(const char *uname); +void empty_uuid_cache(void); +const char *get_uuid(const char *uname); +const char *get_uname(const char *uuid); +void set_uuid(xmlNode * node, const char *attr, const char *uname); +void unget_uuid(const char *uname); enum crm_status_type { crm_status_uname, crm_status_nstate, crm_status_processes, }; enum crm_ais_msg_types text2msg_type(const char *text); -extern void +void crm_set_status_callback(void (*dispatch) (enum crm_status_type, crm_node_t *, const void *)); /* *INDENT-OFF* */ enum cluster_type_e { pcmk_cluster_unknown = 0x0001, pcmk_cluster_invalid = 0x0002, pcmk_cluster_heartbeat = 0x0004, pcmk_cluster_classic_ais = 0x0010, pcmk_cluster_corosync = 0x0020, pcmk_cluster_cman = 0x0040, }; /* *INDENT-ON* */ -extern enum cluster_type_e get_cluster_type(void); -extern const char *name_for_cluster_type(enum cluster_type_e type); +enum cluster_type_e get_cluster_type(void); +const char *name_for_cluster_type(enum cluster_type_e type); -extern gboolean is_corosync_cluster(void); -extern gboolean is_cman_cluster(void); -extern gboolean is_openais_cluster(void); -extern gboolean is_classic_ais_cluster(void); -extern gboolean is_heartbeat_cluster(void); +gboolean is_corosync_cluster(void); +gboolean is_cman_cluster(void); +gboolean is_openais_cluster(void); +gboolean is_classic_ais_cluster(void); +gboolean is_heartbeat_cluster(void); #endif diff --git a/include/crm/common/ipc.h b/include/crm/common/ipc.h index 4561024ffd..fc02b393ab 100644 --- a/include/crm/common/ipc.h +++ b/include/crm/common/ipc.h @@ -1,79 +1,79 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRM_COMMON_IPC__H # define CRM_COMMON_IPC__H # include # include # include /* clplumbing based IPC */ # define create_reply(request, xml_response_data) create_reply_adv(request, xml_response_data, __FUNCTION__); -extern xmlNode *create_reply_adv(xmlNode * request, xmlNode * xml_response_data, +xmlNode *create_reply_adv(xmlNode * request, xmlNode * xml_response_data, const char *origin); # define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from) create_request_adv(task, xml_data, host_to, sys_to, sys_from, uuid_from, __FUNCTION__) -extern xmlNode *create_request_adv(const char *task, xmlNode * xml_data, const char *host_to, +xmlNode *create_request_adv(const char *task, xmlNode * xml_data, const char *host_to, const char *sys_to, const char *sys_from, const char *uuid_from, const char *origin); /* Libqb based IPC */ #include enum ipcs_send_flags { ipcs_send_none = 0x0000, ipcs_send_event = 0x0001, ipcs_send_info = 0x0010, ipcs_send_error = 0x0020, }; ssize_t crm_ipcs_send(qb_ipcs_connection_t *c, xmlNode *msg, enum ipcs_send_flags flags); xmlNode *crm_ipcs_recv(qb_ipcs_connection_t *c, void *data, size_t size); int crm_ipcs_client_pid(qb_ipcs_connection_t *c); void crm_ipcs_send_ack(qb_ipcs_connection_t *c, const char *tag, const char *function, int line); #include typedef struct crm_ipc_s crm_ipc_t; crm_ipc_t *crm_ipc_new(const char *name, size_t max_size); bool crm_ipc_connect(crm_ipc_t *client); void crm_ipc_close(crm_ipc_t *client); void crm_ipc_destroy(crm_ipc_t *client); int crm_ipc_send(crm_ipc_t *client, xmlNode *message, xmlNode **reply, int32_t ms_timeout); int crm_ipc_get_fd(crm_ipc_t *client); bool crm_ipc_connected(crm_ipc_t *client); int crm_ipc_ready(crm_ipc_t *client); long crm_ipc_read(crm_ipc_t *client); const char *crm_ipc_buffer(crm_ipc_t *client); const char *crm_ipc_name(crm_ipc_t *client); /* Utils */ xmlNode *create_hello_message(const char *uuid, const char *client_name, const char *major_version, const char *minor_version); #endif diff --git a/include/crm/common/iso8601.h b/include/crm/common/iso8601.h index a2c26b17d1..7c8287dc1e 100644 --- a/include/crm/common/iso8601.h +++ b/include/crm/common/iso8601.h @@ -1,160 +1,160 @@ /* * Copyright (C) 2005 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * http://en.wikipedia.org/wiki/ISO_8601 * */ #ifndef CRM_COMMON_ISO8601 # define CRM_COMMON_ISO8601 # include # include # include typedef struct ha_has_time_s { gboolean years; gboolean months; gboolean days; gboolean weeks; gboolean weekdays; gboolean weekyears; gboolean yeardays; gboolean hours; gboolean minutes; gboolean seconds; } ha_has_time_t; typedef struct ha_time_s { time_t tm_now; int years; int months; int days; int weeks; int weekdays; int weekyears; int yeardays; int hours; int minutes; int seconds; struct ha_time_s *offset; struct ha_time_s *normalized; struct ha_has_time_s *has; } ha_time_t; enum date_fields { date_month, date_day }; typedef struct ha_time_period_s { ha_time_t *start; ha_time_t *end; ha_time_t *diff; } ha_time_period_t; # define ha_log_date 0x01 # define ha_log_time 0x02 # define ha_log_local 0x04 # define ha_date_ordinal 0x10 # define ha_date_weeks 0x20 -extern int str_lookup(const char *str, enum date_fields); +int str_lookup(const char *str, enum date_fields); -extern char *date_to_string(ha_time_t * dt, int flags); -extern void log_date(int log_level, const char *prefix, ha_time_t * dt, int flags); -extern void log_time_period(int log_level, ha_time_period_t * dtp, int flags); +char *date_to_string(ha_time_t * dt, int flags); +void log_date(int log_level, const char *prefix, ha_time_t * dt, int flags); +void log_time_period(int log_level, ha_time_period_t * dtp, int flags); -extern ha_time_t *parse_time(char **time_str, ha_time_t * atime, gboolean with_offset); -extern ha_time_t *parse_time_offset(char **offset_str); -extern ha_time_t *parse_date(char **date_str); -extern ha_time_t *parse_time_duration(char **duration_str); -extern ha_time_period_t *parse_time_period(char **period_str); +ha_time_t *parse_time(char **time_str, ha_time_t * atime, gboolean with_offset); +ha_time_t *parse_time_offset(char **offset_str); +ha_time_t *parse_date(char **date_str); +ha_time_t *parse_time_duration(char **duration_str); +ha_time_period_t *parse_time_period(char **period_str); /* ha_time_interval_t *parse_time_interval(char **interval_str); */ unsigned long long int date_in_seconds(ha_time_t * a_date); unsigned long long int date_in_seconds_since_epoch(ha_time_t * a_date); -extern int compare_date(ha_time_t * lhs, ha_time_t * rhs); - -extern gboolean parse_int(char **str, int field_width, int uppper_bound, int *result); -extern gboolean check_for_ordinal(const char *str); - -extern void ha_set_time(ha_time_t * lhs, ha_time_t * rhs, gboolean offset); -extern void ha_set_tm_time(ha_time_t * lhs, struct tm *rhs); -extern void ha_set_timet_time(ha_time_t * lhs, time_t * rhs); -extern ha_time_t *add_time(ha_time_t * lhs, ha_time_t * rhs); -extern ha_time_t *subtract_time(ha_time_t * lhs, ha_time_t * rhs); -extern ha_time_t *subtract_duration(ha_time_t * time, ha_time_t * duration); -extern void reset_tm(struct tm *some_tm); -extern void add_seconds(ha_time_t * a_time, int extra); -extern void add_minutes(ha_time_t * a_time, int extra); -extern void add_hours(ha_time_t * a_time, int extra); -extern void add_days(ha_time_t * a_time, int extra); -extern void add_weekdays(ha_time_t * a_time, int extra); -extern void add_yeardays(ha_time_t * a_time, int extra); -extern void add_weeks(ha_time_t * a_time, int extra); -extern void add_months(ha_time_t * a_time, int extra); -extern void add_years(ha_time_t * a_time, int extra); -extern void add_ordinalyears(ha_time_t * a_time, int extra); -extern void add_weekyears(ha_time_t * a_time, int extra); -extern void sub_seconds(ha_time_t * a_time, int extra); -extern void sub_minutes(ha_time_t * a_time, int extra); -extern void sub_hours(ha_time_t * a_time, int extra); -extern void sub_days(ha_time_t * a_time, int extra); -extern void sub_weekdays(ha_time_t * a_time, int extra); -extern void sub_yeardays(ha_time_t * a_time, int extra); -extern void sub_weeks(ha_time_t * a_time, int extra); -extern void sub_months(ha_time_t * a_time, int extra); -extern void sub_years(ha_time_t * a_time, int extra); -extern void sub_ordinalyears(ha_time_t * a_time, int extra); -extern void sub_weekyears(ha_time_t * a_time, int extra); +int compare_date(ha_time_t * lhs, ha_time_t * rhs); + +gboolean parse_int(char **str, int field_width, int uppper_bound, int *result); +gboolean check_for_ordinal(const char *str); + +void ha_set_time(ha_time_t * lhs, ha_time_t * rhs, gboolean offset); +void ha_set_tm_time(ha_time_t * lhs, struct tm *rhs); +void ha_set_timet_time(ha_time_t * lhs, time_t * rhs); +ha_time_t *add_time(ha_time_t * lhs, ha_time_t * rhs); +ha_time_t *subtract_time(ha_time_t * lhs, ha_time_t * rhs); +ha_time_t *subtract_duration(ha_time_t * time, ha_time_t * duration); +void reset_tm(struct tm *some_tm); +void add_seconds(ha_time_t * a_time, int extra); +void add_minutes(ha_time_t * a_time, int extra); +void add_hours(ha_time_t * a_time, int extra); +void add_days(ha_time_t * a_time, int extra); +void add_weekdays(ha_time_t * a_time, int extra); +void add_yeardays(ha_time_t * a_time, int extra); +void add_weeks(ha_time_t * a_time, int extra); +void add_months(ha_time_t * a_time, int extra); +void add_years(ha_time_t * a_time, int extra); +void add_ordinalyears(ha_time_t * a_time, int extra); +void add_weekyears(ha_time_t * a_time, int extra); +void sub_seconds(ha_time_t * a_time, int extra); +void sub_minutes(ha_time_t * a_time, int extra); +void sub_hours(ha_time_t * a_time, int extra); +void sub_days(ha_time_t * a_time, int extra); +void sub_weekdays(ha_time_t * a_time, int extra); +void sub_yeardays(ha_time_t * a_time, int extra); +void sub_weeks(ha_time_t * a_time, int extra); +void sub_months(ha_time_t * a_time, int extra); +void sub_years(ha_time_t * a_time, int extra); +void sub_ordinalyears(ha_time_t * a_time, int extra); +void sub_weekyears(ha_time_t * a_time, int extra); /* conversion functions */ -extern int january1(int year); +int january1(int year); -extern gboolean convert_from_weekdays(ha_time_t * a_date); -extern gboolean convert_from_ordinal(ha_time_t * a_date); -extern gboolean convert_from_gregorian(ha_time_t * a_date); +gboolean convert_from_weekdays(ha_time_t * a_date); +gboolean convert_from_ordinal(ha_time_t * a_date); +gboolean convert_from_gregorian(ha_time_t * a_date); -extern gboolean is_leap_year(int year); +gboolean is_leap_year(int year); -extern int weeks_in_year(int year); -extern int days_per_month(int month, int year); +int weeks_in_year(int year); +int days_per_month(int month, int year); gboolean is_date_sane(ha_time_t * a_date); ha_time_t *new_ha_date(gboolean set_to_now); void free_ha_date(ha_time_t * a_date); void reset_time(ha_time_t * a_time); void log_tm_date(int log_level, struct tm *some_tm); #endif diff --git a/include/crm/common/mainloop.h b/include/crm/common/mainloop.h index bf0a159ce0..2e25dd8b26 100644 --- a/include/crm/common/mainloop.h +++ b/include/crm/common/mainloop.h @@ -1,74 +1,74 @@ /* * Copyright (C) 2009 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRM_COMMON_MAINLOOP__H # define CRM_COMMON_MAINLOOP__H # include typedef struct trigger_s crm_trigger_t; -extern crm_trigger_t *mainloop_add_trigger(int priority, int(*dispatch) (gpointer user_data), +crm_trigger_t *mainloop_add_trigger(int priority, int(*dispatch) (gpointer user_data), gpointer userdata); -extern void mainloop_set_trigger(crm_trigger_t * source); +void mainloop_set_trigger(crm_trigger_t * source); -extern void mainloop_trigger_complete(crm_trigger_t *trig); +void mainloop_trigger_complete(crm_trigger_t *trig); -extern gboolean mainloop_destroy_trigger(crm_trigger_t * source); +gboolean mainloop_destroy_trigger(crm_trigger_t * source); -extern gboolean crm_signal(int sig, void (*dispatch) (int sig)); +gboolean crm_signal(int sig, void (*dispatch) (int sig)); -extern gboolean mainloop_add_signal(int sig, void (*dispatch) (int sig)); +gboolean mainloop_add_signal(int sig, void (*dispatch) (int sig)); -extern gboolean mainloop_destroy_signal(int sig); +gboolean mainloop_destroy_signal(int sig); #include struct ipc_client_callbacks { int (*dispatch)(const char *buffer, ssize_t length, gpointer userdata); void (*destroy) (gpointer); }; qb_ipcs_service_t *mainloop_add_ipc_server( const char *name, enum qb_ipc_type type, struct qb_ipcs_service_handlers *callbacks); void mainloop_del_ipc_server(qb_ipcs_service_t *server); typedef struct mainloop_io_s mainloop_io_t; mainloop_io_t *mainloop_add_ipc_client( const char *name, size_t max_size, void *userdata, struct ipc_client_callbacks *callbacks); void mainloop_del_ipc_client(mainloop_io_t *client); crm_ipc_t *mainloop_get_ipc_client(mainloop_io_t *client); struct mainloop_fd_callbacks { int (*dispatch)(gpointer userdata); void (*destroy)(gpointer userdata); }; mainloop_io_t *mainloop_add_fd( const char *name, int fd, void *userdata, struct mainloop_fd_callbacks *callbacks); void mainloop_del_fd(mainloop_io_t *client); #endif diff --git a/include/crm/common/util.h b/include/crm/common/util.h index 9bccdde7f5..dc5c4e9c5e 100644 --- a/include/crm/common/util.h +++ b/include/crm/common/util.h @@ -1,400 +1,400 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRM_COMMON_UTIL__H # define CRM_COMMON_UTIL__H # include # include # include # include # include # include # if SUPPORT_HEARTBEAT # include # else # define NORMALNODE "normal" # define ACTIVESTATUS "active"/* fully functional, and all links are up */ # define DEADSTATUS "dead" /* Status of non-working link or machine */ # define PINGSTATUS "ping" /* Status of a working ping node */ # define JOINSTATUS "join" /* Status when an api client joins */ # define LEAVESTATUS "leave" /* Status when an api client leaves */ # define ONLINESTATUS "online"/* Status of an online client */ # define OFFLINESTATUS "offline" /* Status of an offline client */ # endif extern unsigned int crm_log_level; extern gboolean crm_config_error; extern gboolean crm_config_warning; # ifdef HAVE_GETOPT_H # include # else # define no_argument 0 # define required_argument 1 # endif # define pcmk_option_default 0x00000 # define pcmk_option_hidden 0x00001 # define pcmk_option_paragraph 0x00002 # define pcmk_option_example 0x00004 struct crm_option { /* Fields from 'struct option' in getopt.h */ /* name of long option */ const char *name; /* * one of no_argument, required_argument, and optional_argument: * whether option takes an argument */ int has_arg; /* if not NULL, set *flag to val when option found */ int *flag; /* if flag not NULL, value to set *flag to; else return value */ int val; /* Custom fields */ const char *desc; long flags; }; # define crm_config_err(fmt...) { crm_config_error = TRUE; crm_err(fmt); } # define crm_config_warn(fmt...) { crm_config_warning = TRUE; crm_warn(fmt); } -extern void crm_log_deinit(void); +void crm_log_deinit(void); -extern gboolean daemon_option_enabled(const char *daemon, const char *option); +gboolean daemon_option_enabled(const char *daemon, const char *option); gboolean crm_log_cli_init(const char *entity); gboolean crm_log_init(const char *entity, int level, gboolean daemon, gboolean to_stderr, int argc, char **argv, gboolean quiet); -extern void crm_log_args(int argc, char **argv); +void crm_log_args(int argc, char **argv); -extern int crm_should_log(int level); +int crm_should_log(int level); -extern void crm_bump_log_level(void); +void crm_bump_log_level(void); -extern void crm_enable_stderr(int enable); +void crm_enable_stderr(int enable); /* returns the old value */ -extern unsigned int set_crm_log_level(unsigned int level); +unsigned int set_crm_log_level(unsigned int level); -extern unsigned int get_crm_log_level(void); +unsigned int get_crm_log_level(void); -extern char *crm_itoa(int an_int); +char *crm_itoa(int an_int); -extern char *crm_strdup_fn(const char *a, const char *file, const char *fn, int line); +char *crm_strdup_fn(const char *a, const char *file, const char *fn, int line); -extern char *generate_hash_key(const char *crm_msg_reference, const char *sys); +char *generate_hash_key(const char *crm_msg_reference, const char *sys); -extern char *generate_hash_value(const char *src_node, const char *src_subsys); +char *generate_hash_value(const char *src_node, const char *src_subsys); -extern gboolean decodeNVpair(const char *srcstring, char separator, char **name, char **value); +gboolean decodeNVpair(const char *srcstring, char separator, char **name, char **value); -extern int compare_version(const char *version1, const char *version2); +int compare_version(const char *version1, const char *version2); -extern char *generateReference(const char *custom1, const char *custom2); +char *generateReference(const char *custom1, const char *custom2); -extern void g_hash_destroy_str(gpointer data); +void g_hash_destroy_str(gpointer data); -extern gboolean crm_is_true(const char *s); +gboolean crm_is_true(const char *s); -extern int crm_str_to_boolean(const char *s, int *ret); +int crm_str_to_boolean(const char *s, int *ret); -extern long long crm_get_msec(const char *input); -extern unsigned long long crm_get_interval(const char *input); +long long crm_get_msec(const char *input); +unsigned long long crm_get_interval(const char *input); -extern const char *op_status2text(op_status_t status); +const char *op_status2text(op_status_t status); -extern char *generate_op_key(const char *rsc_id, const char *op_type, int interval); +char *generate_op_key(const char *rsc_id, const char *op_type, int interval); -extern gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, int *interval); +gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, int *interval); -extern char *generate_notify_key(const char *rsc_id, const char *notify_type, const char *op_type); +char *generate_notify_key(const char *rsc_id, const char *notify_type, const char *op_type); -extern char *generate_transition_magic_v202(const char *transition_key, int op_status); +char *generate_transition_magic_v202(const char *transition_key, int op_status); -extern char *generate_transition_magic(const char *transition_key, int op_status, int op_rc); +char *generate_transition_magic(const char *transition_key, int op_status, int op_rc); -extern gboolean decode_transition_magic(const char *magic, char **uuid, +gboolean decode_transition_magic(const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc); -extern char *generate_transition_key(int action, int transition_id, int target_rc, +char *generate_transition_key(int action, int transition_id, int target_rc, const char *node); -extern gboolean decode_transition_key(const char *key, char **uuid, int *action, int *transition_id, +gboolean decode_transition_key(const char *key, char **uuid, int *action, int *transition_id, int *target_rc); -extern char *crm_concat(const char *prefix, const char *suffix, char join); +char *crm_concat(const char *prefix, const char *suffix, char join); -extern gboolean decode_op_key(const char *key, char **rsc_id, char **op_type, int *interval); +gboolean decode_op_key(const char *key, char **rsc_id, char **op_type, int *interval); -extern void filter_action_parameters(xmlNode * param_set, const char *version); -extern void filter_reload_parameters(xmlNode * param_set, const char *restart_string); +void filter_action_parameters(xmlNode * param_set, const char *version); +void filter_reload_parameters(xmlNode * param_set, const char *restart_string); # define safe_str_eq(a, b) crm_str_eq(a, b, FALSE) -extern gboolean crm_str_eq(const char *a, const char *b, gboolean use_case); +gboolean crm_str_eq(const char *a, const char *b, gboolean use_case); -extern gboolean safe_str_neq(const char *a, const char *b); -extern int crm_parse_int(const char *text, const char *default_text); -extern long long crm_int_helper(const char *text, char **end_text); +gboolean safe_str_neq(const char *a, const char *b); +int crm_parse_int(const char *text, const char *default_text); +long long crm_int_helper(const char *text, char **end_text); # define crm_atoi(text, default_text) crm_parse_int(text, default_text) -extern void crm_abort(const char *file, const char *function, int line, +void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork); -extern char *generate_series_filename(const char *directory, const char *series, int sequence, +char *generate_series_filename(const char *directory, const char *series, int sequence, gboolean bzip); -extern int get_last_sequence(const char *directory, const char *series); +int get_last_sequence(const char *directory, const char *series); -extern void write_last_sequence(const char *directory, const char *series, int sequence, int max); +void write_last_sequence(const char *directory, const char *series, int sequence, int max); -extern int crm_pid_active(long pid); -extern int crm_read_pidfile(const char *filename); -extern int crm_lock_pidfile(const char *filename); -extern void crm_make_daemon(const char *name, gboolean daemonize, const char *pidfile); +int crm_pid_active(long pid); +int crm_read_pidfile(const char *filename); +int crm_lock_pidfile(const char *filename); +void crm_make_daemon(const char *name, gboolean daemonize, const char *pidfile); typedef struct pe_cluster_option_s { const char *name; const char *alt_name; const char *type; const char *values; const char *default_value; gboolean(*is_valid) (const char *); const char *description_short; const char *description_long; } pe_cluster_option; -extern const char *cluster_option(GHashTable * options, gboolean(*validate) (const char *), +const char *cluster_option(GHashTable * options, gboolean(*validate) (const char *), const char *name, const char *old_name, const char *def_value); -extern const char *get_cluster_pref(GHashTable * options, pe_cluster_option * option_list, int len, +const char *get_cluster_pref(GHashTable * options, pe_cluster_option * option_list, int len, const char *name); -extern void config_metadata(const char *name, const char *version, const char *desc_short, +void config_metadata(const char *name, const char *version, const char *desc_short, const char *desc_long, pe_cluster_option * option_list, int len); -extern void verify_all_options(GHashTable * options, pe_cluster_option * option_list, int len); -extern gboolean check_time(const char *value); -extern gboolean check_timer(const char *value); -extern gboolean check_boolean(const char *value); -extern gboolean check_number(const char *value); +void verify_all_options(GHashTable * options, pe_cluster_option * option_list, int len); +gboolean check_time(const char *value); +gboolean check_timer(const char *value); +gboolean check_boolean(const char *value); +gboolean check_number(const char *value); -extern int char2score(const char *score); -extern char *score2char(int score); +int char2score(const char *score); +char *score2char(int score); -extern gboolean crm_is_writable(const char *dir, const char *file, +gboolean crm_is_writable(const char *dir, const char *file, const char *user, const char *group, gboolean need_both); # define set_bit(word, bit) word = crm_set_bit(__PRETTY_FUNCTION__, NULL, word, bit) # define clear_bit(word, bit) word = crm_clear_bit(__PRETTY_FUNCTION__, NULL, word, bit) # define set_bit_inplace set_bit # define clear_bit_inplace clear_bit static inline long long crm_clear_bit(const char *function, const char *target, long long word, long long bit) { long long rc = (word & ~bit); if(rc == word) { /* Unchanged */ } else if (target) { crm_trace("Bit 0x%.8llx for %s cleared by %s", bit, target, function); } else { crm_trace("Bit 0x%.8llx cleared by %s", bit, function); } return rc; } static inline long long crm_set_bit(const char *function, const char *target, long long word, long long bit) { long long rc = (word|bit); if(rc == word) { /* Unchanged */ } else if (target) { crm_trace("Bit 0x%.8llx for %s set by %s", bit, target, function); } else { crm_trace("Bit 0x%.8llx set by %s", bit, function); } return rc; } static inline gboolean is_not_set(long long word, long long bit) { return ((word & bit) == 0); } static inline gboolean is_set(long long word, long long bit) { return ((word & bit) == bit); } static inline gboolean is_set_any(long long word, long long bit) { return ((word & bit) != 0); } -extern xmlNode *cib_recv_remote_msg(void *session, gboolean encrypted); -extern void cib_send_remote_msg(void *session, xmlNode * msg, gboolean encrypted); -extern char *crm_meta_name(const char *field); -extern const char *crm_meta_value(GHashTable * hash, const char *field); +xmlNode *cib_recv_remote_msg(void *session, gboolean encrypted); +void cib_send_remote_msg(void *session, xmlNode * msg, gboolean encrypted); +char *crm_meta_name(const char *field); +const char *crm_meta_value(GHashTable * hash, const char *field); -extern void crm_set_options(const char *short_options, const char *usage, +void crm_set_options(const char *short_options, const char *usage, struct crm_option *long_options, const char *app_desc); -extern int crm_get_option(int argc, char **argv, int *index); -extern void crm_help(char cmd, int exit_code); +int crm_get_option(int argc, char **argv, int *index); +void crm_help(char cmd, int exit_code); -extern int rsc_op_expected_rc(lrm_op_t * op); -extern gboolean did_rsc_op_fail(lrm_op_t * op, int target_rc); +int rsc_op_expected_rc(lrm_op_t * op); +gboolean did_rsc_op_fail(lrm_op_t * op, int target_rc); extern int node_score_red; extern int node_score_green; extern int node_score_yellow; extern int node_score_infinity; # include -extern xmlNode *create_operation_update(xmlNode * parent, lrm_op_t * op, const char *caller_version, +xmlNode *create_operation_update(xmlNode * parent, lrm_op_t * op, const char *caller_version, int target_rc, const char *origin, int level); -extern void free_lrm_op(lrm_op_t * op); +void free_lrm_op(lrm_op_t * op); # if USE_GHASH_COMPAT typedef struct fake_ghi { GHashTable *hash; int nth; /* current index over the iteration */ int lpc; /* internal loop counter inside g_hash_table_find */ gpointer key; gpointer value; } GHashTableIter; static inline void g_hash_prepend_value(gpointer key, gpointer value, gpointer user_data) { GList **values = (GList **) user_data; *values = g_list_prepend(*values, value); } static inline GList * g_hash_table_get_values(GHashTable * hash_table) { GList *values = NULL; g_hash_table_foreach(hash_table, g_hash_prepend_value, &values); return values; } static inline gboolean g_hash_table_nth_data(gpointer key, gpointer value, gpointer user_data) { GHashTableIter *iter = (GHashTableIter *) user_data; if (iter->lpc++ == iter->nth) { iter->key = key; iter->value = value; return TRUE; } return FALSE; } static inline void g_hash_table_iter_init(GHashTableIter * iter, GHashTable * hash_table) { iter->hash = hash_table; iter->nth = 0; iter->lpc = 0; iter->key = NULL; iter->value = NULL; } static inline gboolean g_hash_table_iter_next(GHashTableIter * iter, gpointer * key, gpointer * value) { gboolean found = FALSE; iter->lpc = 0; iter->key = NULL; iter->value = NULL; if (iter->nth < g_hash_table_size(iter->hash)) { found = ! !g_hash_table_find(iter->hash, g_hash_table_nth_data, iter); iter->nth++; } if (key) *key = iter->key; if (value) *value = iter->value; return found; } # endif /* USE_GHASH_COMPAT */ # if ENABLE_ACL static inline gboolean is_privileged(const char *user) { if (user == NULL) { return FALSE; } else if (strcmp(user, CRM_DAEMON_USER) == 0) { return TRUE; } else if (strcmp(user, "root") == 0) { return TRUE; } return FALSE; } -extern void determine_request_user(char **user, IPC_Channel * channel, xmlNode * request, +void determine_request_user(char **user, IPC_Channel * channel, xmlNode * request, const char *field); # endif -extern void *find_library_function(void **handle, const char *lib, const char *fn); +void *find_library_function(void **handle, const char *lib, const char *fn); -extern void *convert_const_pointer(const void *ptr); +void *convert_const_pointer(const void *ptr); -extern char *crm_generate_uuid(void); +char *crm_generate_uuid(void); char *crm_md5sum(const char *buffer); void crm_enable_blackbox(int nsig); void crm_enable_blackbox_tracing(int nsig); void crm_write_blackbox(int nsig); #endif diff --git a/include/crm/common/xml.h b/include/crm/common/xml.h index e7eca9bd1f..51aae016c4 100644 --- a/include/crm/common/xml.h +++ b/include/crm/common/xml.h @@ -1,339 +1,339 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRM_COMMON_XML__H # define CRM_COMMON_XML__H # include # include # include # include # include # include # include # include # include # include typedef xmlNode crm_data_t; /* Encryption costs a LOT, don't do it unless we're hitting message limits * * For now, use 256k as the lower size, which means we can have 4 big data fields * before we hit heartbeat's message limit * * The previous limit was 10k, compressing 184 of 1071 messages accounted for 23% * of the total CPU used by the cib */ # define CRM_BZ2_BLOCKS 4 # define CRM_BZ2_WORK 20 # define CRM_BZ2_THRESHOLD 128 * 1024 # define XML_PARANOIA_CHECKS 0 -extern gboolean add_message_xml(xmlNode * msg, const char *field, xmlNode * xml); -extern xmlNode *get_message_xml(xmlNode * msg, const char *field); -extern GHashTable *xml2list(xmlNode * parent); +gboolean add_message_xml(xmlNode * msg, const char *field, xmlNode * xml); +xmlNode *get_message_xml(xmlNode * msg, const char *field); +GHashTable *xml2list(xmlNode * parent); # if CRM_DEPRECATED_SINCE_2_0_3 -extern GHashTable *xml2list_202(xmlNode * parent); +GHashTable *xml2list_202(xmlNode * parent); # endif -extern void hash2nvpair(gpointer key, gpointer value, gpointer user_data); -extern void hash2field(gpointer key, gpointer value, gpointer user_data); -extern void hash2metafield(gpointer key, gpointer value, gpointer user_data); -extern void hash2smartfield(gpointer key, gpointer value, gpointer user_data); +void hash2nvpair(gpointer key, gpointer value, gpointer user_data); +void hash2field(gpointer key, gpointer value, gpointer user_data); +void hash2metafield(gpointer key, gpointer value, gpointer user_data); +void hash2smartfield(gpointer key, gpointer value, gpointer user_data); -extern xmlDoc *getDocPtr(xmlNode * node); +xmlDoc *getDocPtr(xmlNode * node); /* * Replacement function for xmlCopyPropList which at the very least, * doesnt work the way *I* would expect it to. * * Copy all the attributes/properties from src into target. * * Not recursive, does not return anything. * */ -extern void copy_in_properties(xmlNode * target, xmlNode * src); -extern void expand_plus_plus(xmlNode * target, const char *name, const char *value); -extern void fix_plus_plus_recursive(xmlNode * target); +void copy_in_properties(xmlNode * target, xmlNode * src); +void expand_plus_plus(xmlNode * target, const char *name, const char *value); +void fix_plus_plus_recursive(xmlNode * target); void free_xml_from_parent(xmlNode * parent, xmlNode * a_node); # define zap_xml_from_parent(parent, xml_obj) free_xml_from_parent(parent, xml_obj); xml_obj = NULL /* * Create a node named "name" as a child of "parent" * If parent is NULL, creates an unconnected node. * * Returns the created node * */ -extern xmlNode *create_xml_node(xmlNode * parent, const char *name); +xmlNode *create_xml_node(xmlNode * parent, const char *name); /* * Make a copy of name and value and use the copied memory to create * an attribute for node. * * If node, name or value are NULL, nothing is done. * * If name or value are an empty string, nothing is done. * * Returns FALSE on failure and TRUE on success. * */ -extern const char *crm_xml_add(xmlNode * node, const char *name, const char *value); +const char *crm_xml_add(xmlNode * node, const char *name, const char *value); -extern const char *crm_xml_replace(xmlNode * node, const char *name, const char *value); +const char *crm_xml_replace(xmlNode * node, const char *name, const char *value); -extern const char *crm_xml_add_int(xmlNode * node, const char *name, int value); +const char *crm_xml_add_int(xmlNode * node, const char *name, int value); /* * Unlink the node and set its doc pointer to NULL so free_xml() * will act appropriately */ -extern void unlink_xml_node(xmlNode * node); +void unlink_xml_node(xmlNode * node); /* * */ -extern void purge_diff_markers(xmlNode * a_node); +void purge_diff_markers(xmlNode * a_node); /* * Returns a deep copy of src_node * */ -extern xmlNode *copy_xml(xmlNode * src_node); +xmlNode *copy_xml(xmlNode * src_node); /* * Add a copy of xml_node to new_parent */ -extern xmlNode *add_node_copy(xmlNode * new_parent, xmlNode * xml_node); +xmlNode *add_node_copy(xmlNode * new_parent, xmlNode * xml_node); -extern int add_node_nocopy(xmlNode * parent, const char *name, xmlNode * child); +int add_node_nocopy(xmlNode * parent, const char *name, xmlNode * child); /* * XML I/O Functions * * Whitespace between tags is discarded. */ -extern xmlNode *filename2xml(const char *filename); +xmlNode *filename2xml(const char *filename); -extern xmlNode *stdin2xml(void); +xmlNode *stdin2xml(void); -extern xmlNode *string2xml(const char *input); +xmlNode *string2xml(const char *input); -extern int write_xml_file(xmlNode * xml_node, const char *filename, gboolean compress); +int write_xml_file(xmlNode * xml_node, const char *filename, gboolean compress); -extern char *dump_xml_formatted(xmlNode * msg); +char *dump_xml_formatted(xmlNode * msg); -extern char *dump_xml_unformatted(xmlNode * msg); +char *dump_xml_unformatted(xmlNode * msg); /* * Diff related Functions */ -extern xmlNode *diff_xml_object(xmlNode * left, xmlNode * right, gboolean suppress); +xmlNode *diff_xml_object(xmlNode * left, xmlNode * right, gboolean suppress); -extern xmlNode *subtract_xml_object(xmlNode * parent, xmlNode * left, xmlNode * right, +xmlNode *subtract_xml_object(xmlNode * parent, xmlNode * left, xmlNode * right, gboolean full, const char *marker); -extern gboolean can_prune_leaf(xmlNode * xml_node); +gboolean can_prune_leaf(xmlNode * xml_node); -extern void print_xml_diff(FILE * where, xmlNode * diff); -extern void log_xml_diff(unsigned int log_level, xmlNode * diff, const char *function); +void print_xml_diff(FILE * where, xmlNode * diff); +void log_xml_diff(unsigned int log_level, xmlNode * diff, const char *function); -extern gboolean apply_xml_diff(xmlNode * old, xmlNode * diff, xmlNode ** new); +gboolean apply_xml_diff(xmlNode * old, xmlNode * diff, xmlNode ** new); /* * Searching & Modifying */ -extern xmlNode *find_xml_node(xmlNode * cib, const char *node_path, gboolean must_find); +xmlNode *find_xml_node(xmlNode * cib, const char *node_path, gboolean must_find); -extern xmlNode *find_entity(xmlNode * parent, const char *node_name, const char *id); +xmlNode *find_entity(xmlNode * parent, const char *node_name, const char *id); -extern void xml_remove_prop(xmlNode * obj, const char *name); +void xml_remove_prop(xmlNode * obj, const char *name); -extern gboolean replace_xml_child(xmlNode * parent, xmlNode * child, xmlNode * update, +gboolean replace_xml_child(xmlNode * parent, xmlNode * child, xmlNode * update, gboolean delete_only); -extern gboolean update_xml_child(xmlNode * child, xmlNode * to_update); +gboolean update_xml_child(xmlNode * child, xmlNode * to_update); -extern int find_xml_children(xmlNode ** children, xmlNode * root, +int find_xml_children(xmlNode ** children, xmlNode * root, const char *tag, const char *field, const char *value, gboolean search_matches); -extern int crm_element_value_int(xmlNode * data, const char *name, int *dest); -extern char *crm_element_value_copy(xmlNode * data, const char *name); -extern int crm_element_value_const_int(const xmlNode * data, const char *name, int *dest); -extern const char *crm_element_value_const(const xmlNode * data, const char *name); -extern xmlNode *get_xpath_object(const char *xpath, xmlNode * xml_obj, int error_level); -extern xmlNode *get_xpath_object_relative(const char *xpath, xmlNode * xml_obj, int error_level); +int crm_element_value_int(xmlNode * data, const char *name, int *dest); +char *crm_element_value_copy(xmlNode * data, const char *name); +int crm_element_value_const_int(const xmlNode * data, const char *name, int *dest); +const char *crm_element_value_const(const xmlNode * data, const char *name); +xmlNode *get_xpath_object(const char *xpath, xmlNode * xml_obj, int error_level); +xmlNode *get_xpath_object_relative(const char *xpath, xmlNode * xml_obj, int error_level); # define crm_element_name(xml) (xml)?(const char *)(xml)->name:NULL -extern const char *crm_element_value(xmlNode * data, const char *name); +const char *crm_element_value(xmlNode * data, const char *name); -extern void xml_validate(const xmlNode * root); +void xml_validate(const xmlNode * root); -extern gboolean xml_has_children(const xmlNode * root); +gboolean xml_has_children(const xmlNode * root); /* For ABI compatability with version < 1.1.4 */ -extern char *calculate_xml_digest(xmlNode * local_cib, gboolean sort, gboolean do_filter); +char *calculate_xml_digest(xmlNode * local_cib, gboolean sort, gboolean do_filter); -extern char *calculate_on_disk_digest(xmlNode * local_cib); -extern char *calculate_operation_digest(xmlNode * local_cib, const char *version); -extern char *calculate_xml_versioned_digest(xmlNode * input, gboolean sort, gboolean do_filter, +char *calculate_on_disk_digest(xmlNode * local_cib); +char *calculate_operation_digest(xmlNode * local_cib, const char *version); +char *calculate_xml_versioned_digest(xmlNode * input, gboolean sort, gboolean do_filter, const char *version); -extern gboolean validate_xml(xmlNode * xml_blob, const char *validation, gboolean to_logs); -extern gboolean validate_xml_verbose(xmlNode * xml_blob); -extern int update_validation(xmlNode ** xml_blob, int *best, gboolean transform, gboolean to_logs); -extern int get_schema_version(const char *name); -extern const char *get_schema_name(int version); -extern void crm_xml_cleanup(void); +gboolean validate_xml(xmlNode * xml_blob, const char *validation, gboolean to_logs); +gboolean validate_xml_verbose(xmlNode * xml_blob); +int update_validation(xmlNode ** xml_blob, int *best, gboolean transform, gboolean to_logs); +int get_schema_version(const char *name); +const char *get_schema_name(int version); +void crm_xml_cleanup(void); # if XML_PARANOIA_CHECKS # define crm_validate_data(obj) xml_validate(obj) # else # define crm_validate_data(obj) CRM_LOG_ASSERT(obj != NULL) # endif static inline xmlNode * __xml_first_child(xmlNode * parent) { xmlNode *child = NULL; if (parent) { child = parent->children; while (child && child->type != XML_ELEMENT_NODE) { child = child->next; } } return child; } static inline xmlNode * __xml_next(xmlNode * child) { if (child) { child = child->next; while (child && child->type != XML_ELEMENT_NODE) { child = child->next; } } return child; } /* These two child iterator macros are no longer to be used * They exist for compatability reasons and will be removed in a * future release */ # define xml_child_iter(parent, child, code) do { \ if(parent != NULL) { \ xmlNode *child = NULL; \ xmlNode *__crm_xml_iter = parent->children; \ while(__crm_xml_iter != NULL) { \ child = __crm_xml_iter; \ __crm_xml_iter = __crm_xml_iter->next; \ if(child->type == XML_ELEMENT_NODE) { \ code; \ } \ } \ } \ } while(0) # define xml_child_iter_filter(parent, child, filter, code) do { \ if(parent != NULL) { \ xmlNode *child = NULL; \ xmlNode *__crm_xml_iter = parent->children; \ while(__crm_xml_iter != NULL) { \ child = __crm_xml_iter; \ __crm_xml_iter = __crm_xml_iter->next; \ if(child->type == XML_ELEMENT_NODE) { \ if(filter == NULL \ || crm_str_eq(filter, (const char *)child->name, TRUE)) { \ code; \ } \ } \ } \ } \ } while(0) # define xml_prop_iter(parent, prop_name, prop_value, code) do { \ if(parent != NULL) { \ xmlAttrPtr prop_iter = parent->properties; \ const char *prop_name = NULL; \ const char *prop_value = NULL; \ while(prop_iter != NULL) { \ prop_name = (const char *)prop_iter->name; \ prop_value = crm_element_value(parent, prop_name); \ prop_iter = prop_iter->next; \ if(prop_name) { \ code; \ } \ } \ } \ } while(0) # define xml_prop_name_iter(parent, prop_name, code) do { \ if(parent != NULL) { \ xmlAttrPtr prop_iter = parent->properties; \ const char *prop_name = NULL; \ while(prop_iter != NULL) { \ prop_name = (const char *)prop_iter->name; \ prop_iter = prop_iter->next; \ if(prop_name) { \ code; \ } \ } \ } \ } while(0) # define free_xml(a_node) do { \ if((a_node) != NULL) { \ xmlNode *a_doc_top = NULL; \ xmlDoc *a_doc = (a_node)->doc; \ if (a_doc != NULL) { \ a_doc_top = xmlDocGetRootElement(a_doc); \ } \ if(a_doc != NULL && a_doc_top == (a_node)) { \ xmlFreeDoc(a_doc); \ \ } else { \ /* make sure the node is unlinked first */ \ xmlUnlinkNode(a_node); \ xmlFreeNode(a_node); \ } \ } \ } while(0) -extern xmlNode *first_named_child(xmlNode * parent, const char *name); +xmlNode *first_named_child(xmlNode * parent, const char *name); -extern xmlNode *convert_ipc_message(IPC_Message * msg, const char *field); -extern xmlNode *convert_ha_message(xmlNode * parent, HA_Message * msg, const char *field); +xmlNode *convert_ipc_message(IPC_Message * msg, const char *field); +xmlNode *convert_ha_message(xmlNode * parent, HA_Message * msg, const char *field); -extern HA_Message *convert_xml_message(xmlNode * msg); -extern xmlNode *sorted_xml(xmlNode * input, xmlNode * parent, gboolean recursive); -extern xmlXPathObjectPtr xpath_search(xmlNode * xml_top, const char *path); -extern gboolean cli_config_update(xmlNode ** xml, int *best_version, gboolean to_logs); -extern xmlNode *expand_idref(xmlNode * input, xmlNode * top); +HA_Message *convert_xml_message(xmlNode * msg); +xmlNode *sorted_xml(xmlNode * input, xmlNode * parent, gboolean recursive); +xmlXPathObjectPtr xpath_search(xmlNode * xml_top, const char *path); +gboolean cli_config_update(xmlNode ** xml, int *best_version, gboolean to_logs); +xmlNode *expand_idref(xmlNode * input, xmlNode * top); -extern xmlNode *getXpathResult(xmlXPathObjectPtr xpathObj, int index); +xmlNode *getXpathResult(xmlXPathObjectPtr xpathObj, int index); #endif diff --git a/include/crm/crm.h b/include/crm/crm.h index fd3124c09d..67e96f0dda 100644 --- a/include/crm/crm.h +++ b/include/crm/crm.h @@ -1,374 +1,374 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRM__H # define CRM__H # include # include # include # include # include # undef MIN # undef MAX # include # if LIBQB_LOGGING # include # else # include # endif # include -extern int log_data_element(int log_level, const char *file, const char *function, int line, +int log_data_element(int log_level, const char *file, const char *function, int line, const char *prefix, xmlNode * data, int depth, gboolean formatted); # define CRM_FEATURE_SET "3.0.6" # define MINIMUM_SCHEMA_VERSION "pacemaker-1.0" # define LATEST_SCHEMA_VERSION "pacemaker-"CRM_DTD_VERSION # define EOS '\0' # define DIMOF(a) ((int) (sizeof(a)/sizeof(a[0])) ) # ifndef __GNUC__ # define __builtin_expect(expr, result) (expr) # endif /* Some handy macros used by the Linux kernel */ # define __likely(expr) __builtin_expect(expr, 1) # define __unlikely(expr) __builtin_expect(expr, 0) # define CRM_DEPRECATED_SINCE_2_0_1 0 # define CRM_DEPRECATED_SINCE_2_0_2 0 # define CRM_DEPRECATED_SINCE_2_0_3 0 # define CRM_DEPRECATED_SINCE_2_0_4 0 # define CRM_DEPRECATED_SINCE_2_0_5 0 # define CRM_DEPRECATED_SINCE_2_0_6 1 # define CRM_DEPRECATED_SINCE_2_0_7 1 # define CRM_DEPRECATED_SINCE_2_0_8 1 # define CRM_DEPRECATED_SINCE_2_1_0 1 # define CRM_META "CRM_meta" # define CRM_ASSERT(expr) do { \ if(__unlikely((expr) == FALSE)) { \ crm_abort(__FILE__, __PRETTY_FUNCTION__, __LINE__, #expr, TRUE, FALSE); \ } \ } while(0) extern const char *crm_system_name; /* *INDENT-OFF* */ /* Clean these up at some point, some probably should be runtime options */ # define SOCKET_LEN 1024 # define APPNAME_LEN 256 # define MAX_IPC_FAIL 5 # define MAX_IPC_DELAY 120 # define MSG_LOG 1 # define DOT_FSA_ACTIONS 1 # define DOT_ALL_FSA_INPUTS 1 /* #define FSA_TRACE 1 */ # define INFINITY_S "INFINITY" # define MINUS_INFINITY_S "-INFINITY" # define INFINITY 1000000 /* 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" # define CRM_SYSTEM_STONITHD "stonithd" # define CRM_SYSTEM_MCP "pacemakerd" /* Valid operations */ # define CRM_OP_NOOP "noop" # define CRM_OP_JOIN_ANNOUNCE "join_announce" # define CRM_OP_JOIN_OFFER "join_offer" # define CRM_OP_JOIN_REQUEST "join_request" # define CRM_OP_JOIN_ACKNAK "join_ack_nack" # define CRM_OP_JOIN_CONFIRM "join_confirm" # define CRM_OP_DIE "die_no_respawn" # define CRM_OP_RETRIVE_CIB "retrieve_cib" # define CRM_OP_PING "ping" # define CRM_OP_VOTE "vote" # define CRM_OP_NOVOTE "no-vote" # define CRM_OP_HELLO "hello" # define CRM_OP_HBEAT "dc_beat" # define CRM_OP_PECALC "pe_calc" # define CRM_OP_ABORT "abort" # define CRM_OP_QUIT "quit" # define CRM_OP_LOCAL_SHUTDOWN "start_shutdown" # define CRM_OP_SHUTDOWN_REQ "req_shutdown" # define CRM_OP_SHUTDOWN "do_shutdown" # define CRM_OP_FENCE "stonith" # define CRM_OP_EVENTCC "event_cc" # define CRM_OP_TEABORT "te_abort" # define CRM_OP_TEABORTED "te_abort_confirmed" /* we asked */ # define CRM_OP_TE_HALT "te_halt" # define CRM_OP_TECOMPLETE "te_complete" # define CRM_OP_TETIMEOUT "te_timeout" # define CRM_OP_TRANSITION "transition" # define CRM_OP_REGISTER "register" # define CRM_OP_DEBUG_UP "debug_inc" # define CRM_OP_DEBUG_DOWN "debug_dec" # define CRM_OP_INVOKE_LRM "lrm_invoke" # define CRM_OP_LRM_REFRESH "lrm_refresh" # define CRM_OP_LRM_QUERY "lrm_query" # define CRM_OP_LRM_DELETE "lrm_delete" # define CRM_OP_LRM_FAIL "lrm_fail" # define CRM_OP_PROBED "probe_complete" # define CRM_OP_REPROBE "probe_again" # define CRM_OP_CLEAR_FAILCOUNT "clear_failcount" # define CRM_OP_RELAXED_SET "one-or-more" # define CRMD_STATE_ACTIVE "member" # define CRMD_STATE_INACTIVE "down" # define CRMD_JOINSTATE_DOWN CRMD_STATE_INACTIVE # define CRMD_JOINSTATE_PENDING "pending" # define CRMD_JOINSTATE_MEMBER CRMD_STATE_ACTIVE # define CRMD_JOINSTATE_NACK "banned" # define CRMD_ACTION_DELETE "delete" # define CRMD_ACTION_CANCEL "cancel" # define CRMD_ACTION_MIGRATE "migrate_to" # define CRMD_ACTION_MIGRATED "migrate_from" # define CRMD_ACTION_START "start" # define CRMD_ACTION_STARTED "running" # define CRMD_ACTION_STOP "stop" # define CRMD_ACTION_STOPPED "stopped" # define CRMD_ACTION_PROMOTE "promote" # define CRMD_ACTION_PROMOTED "promoted" # define CRMD_ACTION_DEMOTE "demote" # define CRMD_ACTION_DEMOTED "demoted" # define CRMD_ACTION_NOTIFY "notify" # define CRMD_ACTION_NOTIFIED "notified" # define CRMD_ACTION_STATUS "monitor" /* short names */ # define RSC_DELETE CRMD_ACTION_DELETE # define RSC_CANCEL CRMD_ACTION_CANCEL # define RSC_MIGRATE CRMD_ACTION_MIGRATE # define RSC_MIGRATED CRMD_ACTION_MIGRATED # define RSC_START CRMD_ACTION_START # define RSC_STARTED CRMD_ACTION_STARTED # define RSC_STOP CRMD_ACTION_STOP # define RSC_STOPPED CRMD_ACTION_STOPPED # define RSC_PROMOTE CRMD_ACTION_PROMOTE # define RSC_PROMOTED CRMD_ACTION_PROMOTED # define RSC_DEMOTE CRMD_ACTION_DEMOTE # define RSC_DEMOTED CRMD_ACTION_DEMOTED # define RSC_NOTIFY CRMD_ACTION_NOTIFY # define RSC_NOTIFIED CRMD_ACTION_NOTIFIED # define RSC_STATUS CRMD_ACTION_STATUS /* *INDENT-ON* */ typedef GList *GListPtr; /* LOG_DEBUG = 7, make LOG_TRACE ::= -VVVVV */ # ifdef LOG_TRACE # undef LOG_TRACE # endif # ifndef LOG_TRACE # define LOG_TRACE 12 # endif # define LOG_DEBUG_2 LOG_TRACE # define LOG_DEBUG_3 LOG_TRACE # define LOG_DEBUG_4 LOG_TRACE # define LOG_DEBUG_5 LOG_TRACE # define LOG_DEBUG_6 LOG_TRACE # define LOG_MSG LOG_TRACE /* * Throughout the macros below, note the leading, pre-comma, space in the * various ' , ##args' occurences to aid portability across versions of 'gcc'. * http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html#Variadic-Macros */ # define CRM_TRACE_INIT_DATA(name) QB_LOG_INIT_DATA(name) # define do_crm_log(level, fmt, args...) do { \ qb_log_from_external_source( __func__, __FILE__, fmt, level, __LINE__, 0, ##args); \ } while(0) /* level /MUST/ be a constant or compilation will fail */ # define do_crm_log_unlikely(level, fmt, args...) do { \ static struct qb_log_callsite *trace_cs = NULL; \ if(trace_cs == NULL) { \ trace_cs = qb_log_callsite_get(__func__, __FILE__, fmt, level, __LINE__, 0); \ } \ if (trace_cs && trace_cs->targets) { \ qb_log_from_external_source( \ __func__, __FILE__, fmt, level, __LINE__, 0, ##args); \ } \ } while(0) # define CRM_LOG_ASSERT(expr) do { \ if(__unlikely((expr) == FALSE)) { \ static struct qb_log_callsite *core_cs = NULL; \ if(core_cs == NULL) { \ core_cs = qb_log_callsite_get(__func__, __FILE__, "log-assert", LOG_TRACE, __LINE__, 0); \ } \ crm_abort(__FILE__, __PRETTY_FUNCTION__, __LINE__, #expr, \ core_cs?core_cs->targets:FALSE, TRUE); \ } \ } while(0) # define CRM_CHECK(expr, failure_action) do { \ if(__unlikely((expr) == FALSE)) { \ static struct qb_log_callsite *core_cs = NULL; \ if(core_cs == NULL) { \ core_cs = qb_log_callsite_get(__func__, __FILE__, "check-assert", LOG_TRACE, __LINE__, 0); \ } \ crm_abort(__FILE__, __PRETTY_FUNCTION__, __LINE__, #expr, \ core_cs?core_cs->targets:FALSE, TRUE); \ failure_action; \ } \ } while(0) # define do_crm_log_xml(level, text, xml) do { \ static struct qb_log_callsite *xml_cs = NULL; \ if(xml_cs == NULL) { \ xml_cs = qb_log_callsite_get(__func__, __FILE__, "xml-blog", level, __LINE__, 0); \ } \ if (xml_cs && xml_cs->targets) { \ log_data_element(level, __FILE__, __PRETTY_FUNCTION__, __LINE__, text, xml, 0, TRUE); \ } \ } while(0) # define do_crm_log_alias(level, file, function, line, fmt, args...) do { \ qb_log_from_external_source(function, file, fmt, level, line, 0, ##args); \ } while(0) # define do_crm_log_always(level, fmt, args...) qb_log(level, "%s: " fmt, __PRETTY_FUNCTION__ , ##args) # define crm_perror(level, fmt, args...) do { \ const char *err = strerror(errno); \ fprintf(stderr, fmt ": %s (%d)\n", ##args, err, errno); \ do_crm_log(level, fmt ": %s (%d)", ##args, err, errno); \ } while(0) # define crm_crit(fmt, args...) qb_logt(LOG_CRIT, 0, fmt , ##args) # define crm_err(fmt, args...) qb_logt(LOG_ERR, 0, fmt , ##args) # define crm_warn(fmt, args...) qb_logt(LOG_WARNING, 0, fmt , ##args) # define crm_notice(fmt, args...) qb_logt(LOG_NOTICE, 0, fmt , ##args) # define crm_info(fmt, args...) qb_logt(LOG_INFO, 0, fmt , ##args) # define crm_debug(fmt, args...) do_crm_log_unlikely(LOG_DEBUG, fmt , ##args) # define crm_trace(fmt, args...) do_crm_log_unlikely(LOG_TRACE, fmt , ##args) # include # define crm_log_xml_crit(xml, text) do_crm_log_xml(LOG_CRIT, text, xml) # define crm_log_xml_err(xml, text) do_crm_log_xml(LOG_ERR, text, xml) # define crm_log_xml_warn(xml, text) do_crm_log_xml(LOG_WARNING, text, xml) # define crm_log_xml_notice(xml, text) do_crm_log_xml(LOG_NOTICE, text, xml) # define crm_log_xml_info(xml, text) do_crm_log_xml(LOG_INFO, text, xml) # define crm_log_xml_debug(xml, text) do_crm_log_xml(LOG_DEBUG, text, xml) # define crm_log_xml_trace(xml, text) do_crm_log_xml(LOG_TRACE, text, xml) # define crm_str(x) (const char*)(x?x:"") # define crm_malloc0(malloc_obj, length) do { \ malloc_obj = malloc(length); \ if(malloc_obj == NULL) { \ crm_err("Failed allocation of %lu bytes", (unsigned long)length); \ CRM_ASSERT(malloc_obj != NULL); \ } \ memset(malloc_obj, 0, length); \ } while(0) # define crm_malloc(malloc_obj, length) do { \ malloc_obj = malloc(length); \ if(malloc_obj == NULL) { \ crm_err("Failed allocation of %lu bytes", (unsigned long)length); \ CRM_ASSERT(malloc_obj != NULL); \ } \ } while(0) # define crm_realloc(realloc_obj, length) do { \ realloc_obj = realloc(realloc_obj, length); \ CRM_ASSERT(realloc_obj != NULL); \ } while(0) # define crm_free(free_obj) do { free(free_obj); free_obj=NULL; } while(0) # define crm_strdup(str) crm_strdup_fn(str, __FILE__, __PRETTY_FUNCTION__, __LINE__) # define crm_str_hash g_str_hash_traditional -extern guint g_str_hash_traditional(gconstpointer v); +guint g_str_hash_traditional(gconstpointer v); -extern void update_all_trace_data(void); +void update_all_trace_data(void); static inline void slist_basic_destroy(GListPtr list) { GListPtr gIter = NULL; for (gIter = list; gIter != NULL; gIter = gIter->next) { free(gIter->data); } g_list_free(list); } /* These two macros are no longer to be used * They exist for compatability reasons and will be removed in a * future release * Use something like this instead: GListPtr gIter = rsc->children; for(; gIter != NULL; gIter = gIter->next) { resource_t *child_rsc = (resource_t*)gIter->data; ... } * */ # define slist_destroy(child_type, child, parent, a) do { \ GListPtr __crm_iter_head = parent; \ child_type *child = NULL; \ while(__crm_iter_head != NULL) { \ child = (child_type *) __crm_iter_head->data; \ __crm_iter_head = __crm_iter_head->next; \ { a; } \ } \ g_list_free(parent); \ } while(0) #endif diff --git a/include/crm/pengine/common.h b/include/crm/pengine/common.h index a08769af72..36d65dff1d 100644 --- a/include/crm/pengine/common.h +++ b/include/crm/pengine/common.h @@ -1,142 +1,142 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PE_COMMON__H # define PE_COMMON__H # include extern gboolean was_processing_error; extern gboolean was_processing_warning; /* order is significant here * items listed in order of accending severeness * more severe actions take precedent over lower ones */ enum action_fail_response { action_fail_ignore, action_fail_recover, action_fail_migrate, /* recover by moving it somewhere else */ action_fail_block, action_fail_stop, action_fail_standby, action_fail_fence }; /* the "done" action must be the "pre" action +1 */ enum action_tasks { no_action, monitor_rsc, stop_rsc, stopped_rsc, start_rsc, started_rsc, action_notify, action_notified, action_promote, action_promoted, action_demote, action_demoted, shutdown_crm, stonith_node }; enum rsc_recovery_type { recovery_stop_start, recovery_stop_only, recovery_block }; enum rsc_start_requirement { rsc_req_nothing, rsc_req_quorum, rsc_req_stonith }; enum rsc_role_e { RSC_ROLE_UNKNOWN, RSC_ROLE_STOPPED, RSC_ROLE_STARTED, RSC_ROLE_SLAVE, RSC_ROLE_MASTER, }; # define RSC_ROLE_MAX RSC_ROLE_MASTER+1 # define RSC_ROLE_UNKNOWN_S "Unknown" # define RSC_ROLE_STOPPED_S "Stopped" # define RSC_ROLE_STARTED_S "Started" # define RSC_ROLE_SLAVE_S "Slave" # define RSC_ROLE_MASTER_S "Master" /* *INDENT-OFF* */ enum pe_print_options { pe_print_log = 0x0001, pe_print_html = 0x0002, pe_print_ncurses = 0x0004, pe_print_printf = 0x0008, pe_print_dev = 0x0010, pe_print_details = 0x0020, pe_print_max_details = 0x0040, pe_print_rsconly = 0x0080, pe_print_ops = 0x0100, pe_print_suppres_nl = 0x0200, pe_print_xml = 0x0400, }; /* *INDENT-ON* */ -extern int merge_weights(int w1, int w2); +int merge_weights(int w1, int w2); -extern const char *task2text(enum action_tasks task); -extern enum action_tasks text2task(const char *task); +const char *task2text(enum action_tasks task); +enum action_tasks text2task(const char *task); -extern enum rsc_role_e text2role(const char *role); -extern const char *role2text(enum rsc_role_e role); +enum rsc_role_e text2role(const char *role); +const char *role2text(enum rsc_role_e role); -extern const char *fail2text(enum action_fail_response fail); +const char *fail2text(enum action_fail_response fail); -extern void add_hash_param(GHashTable * hash, const char *name, const char *value); -extern void append_hashtable(gpointer key, gpointer value, gpointer user_data); -extern void pe_metadata(void); -extern void verify_pe_options(GHashTable * options); -extern const char *pe_pref(GHashTable * options, const char *name); -extern void calculate_active_ops(GList * sorted_op_list, int *start_index, int *stop_index); +void add_hash_param(GHashTable * hash, const char *name, const char *value); +void append_hashtable(gpointer key, gpointer value, gpointer user_data); +void pe_metadata(void); +void verify_pe_options(GHashTable * options); +const char *pe_pref(GHashTable * options, const char *name); +void calculate_active_ops(GList * sorted_op_list, int *start_index, int *stop_index); /* Helper macros to avoid NULL pointers */ # define safe_val3(def, t,u,v) (t?t->u?t->u->v:def:def) # define safe_val5(def, t,u,v,w,x) (t?t->u?t->u->v?t->u->v->w?t->u->v->w->x:def:def:def:def) # define pe_err(fmt...) { was_processing_error = TRUE; crm_config_error = TRUE; crm_err(fmt); } # define pe_warn(fmt...) { was_processing_warning = TRUE; crm_config_warning = TRUE; crm_warn(fmt); } # define pe_proc_err(fmt...) { was_processing_error = TRUE; crm_err(fmt); } # define pe_proc_warn(fmt...) { was_processing_warning = TRUE; crm_warn(fmt); } static inline const char * recovery2text(enum rsc_recovery_type type) { switch (type) { case recovery_stop_only: return "shutting it down"; case recovery_stop_start: return "attempting recovery"; case recovery_block: return "waiting for an administrator"; } return "Unknown"; } #endif diff --git a/include/crm/pengine/complex.h b/include/crm/pengine/complex.h index fd34d96457..668aaba08f 100644 --- a/include/crm/pengine/complex.h +++ b/include/crm/pengine/complex.h @@ -1,104 +1,104 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PENGINE_COMPLEX__H # define PENGINE_COMPLEX__H # define n_object_classes 3 /*#define PE_OBJ_F_ ""*/ # define PE_OBJ_T_NATIVE "native" # define PE_OBJ_T_GROUP "group" # define PE_OBJ_T_INCARNATION "clone" # define PE_OBJ_T_MASTER "master" enum pe_obj_types { pe_unknown = -1, pe_native = 0, pe_group = 1, pe_clone = 2, pe_master = 3 }; -extern enum pe_obj_types get_resource_type(const char *name); -extern const char *get_resource_typename(enum pe_obj_types type); +enum pe_obj_types get_resource_type(const char *name); +const char *get_resource_typename(enum pe_obj_types type); typedef struct resource_object_functions_s { gboolean(*unpack) (resource_t *, pe_working_set_t *); resource_t *(*find_rsc) (resource_t * parent, const char *search, node_t * node, int flags); /* parameter result must be free'd */ char *(*parameter) (resource_t *, node_t *, gboolean, const char *, pe_working_set_t *); void (*print) (resource_t *, const char *, long, void *); gboolean(*active) (resource_t *, gboolean); enum rsc_role_e (*state) (const resource_t *, gboolean); node_t *(*location) (resource_t *, GListPtr *, gboolean); void (*free) (resource_t *); } resource_object_functions_t; -extern void common_update_score(resource_t * rsc, const char *id, int score); +void common_update_score(resource_t * rsc, const char *id, int score); -extern char *native_parameter(resource_t * rsc, node_t * node, gboolean create, const char *name, +char *native_parameter(resource_t * rsc, node_t * node, gboolean create, const char *name, pe_working_set_t * data_set); -extern gboolean native_unpack(resource_t * rsc, pe_working_set_t * data_set); -extern gboolean group_unpack(resource_t * rsc, pe_working_set_t * data_set); -extern gboolean clone_unpack(resource_t * rsc, pe_working_set_t * data_set); -extern gboolean master_unpack(resource_t * rsc, pe_working_set_t * data_set); +gboolean native_unpack(resource_t * rsc, pe_working_set_t * data_set); +gboolean group_unpack(resource_t * rsc, pe_working_set_t * data_set); +gboolean clone_unpack(resource_t * rsc, pe_working_set_t * data_set); +gboolean master_unpack(resource_t * rsc, pe_working_set_t * data_set); -extern resource_t *native_find_rsc(resource_t * rsc, const char *id, node_t * node, int flags); +resource_t *native_find_rsc(resource_t * rsc, const char *id, node_t * node, int flags); -extern gboolean native_active(resource_t * rsc, gboolean all); -extern gboolean group_active(resource_t * rsc, gboolean all); -extern gboolean clone_active(resource_t * rsc, gboolean all); -extern gboolean master_active(resource_t * rsc, gboolean all); +gboolean native_active(resource_t * rsc, gboolean all); +gboolean group_active(resource_t * rsc, gboolean all); +gboolean clone_active(resource_t * rsc, gboolean all); +gboolean master_active(resource_t * rsc, gboolean all); -extern void native_print(resource_t * rsc, const char *pre_text, long options, void *print_data); -extern void group_print(resource_t * rsc, const char *pre_text, long options, void *print_data); -extern void clone_print(resource_t * rsc, const char *pre_text, long options, void *print_data); -extern void master_print(resource_t * rsc, const char *pre_text, long options, void *print_data); +void native_print(resource_t * rsc, const char *pre_text, long options, void *print_data); +void group_print(resource_t * rsc, const char *pre_text, long options, void *print_data); +void clone_print(resource_t * rsc, const char *pre_text, long options, void *print_data); +void master_print(resource_t * rsc, const char *pre_text, long options, void *print_data); -extern void native_free(resource_t * rsc); -extern void group_free(resource_t * rsc); -extern void clone_free(resource_t * rsc); -extern void master_free(resource_t * rsc); +void native_free(resource_t * rsc); +void group_free(resource_t * rsc); +void clone_free(resource_t * rsc); +void master_free(resource_t * rsc); -extern enum rsc_role_e native_resource_state(const resource_t * rsc, gboolean current); -extern enum rsc_role_e group_resource_state(const resource_t * rsc, gboolean current); -extern enum rsc_role_e clone_resource_state(const resource_t * rsc, gboolean current); -extern enum rsc_role_e master_resource_state(const resource_t * rsc, gboolean current); +enum rsc_role_e native_resource_state(const resource_t * rsc, gboolean current); +enum rsc_role_e group_resource_state(const resource_t * rsc, gboolean current); +enum rsc_role_e clone_resource_state(const resource_t * rsc, gboolean current); +enum rsc_role_e master_resource_state(const resource_t * rsc, gboolean current); -extern node_t *native_location(resource_t * rsc, GListPtr * list, gboolean current); +node_t *native_location(resource_t * rsc, GListPtr * list, gboolean current); extern resource_object_functions_t resource_class_functions[]; -extern gboolean common_unpack(xmlNode * xml_obj, resource_t ** rsc, +gboolean common_unpack(xmlNode * xml_obj, resource_t ** rsc, resource_t * parent, pe_working_set_t * data_set); -extern void common_print(resource_t * rsc, const char *pre_text, long options, void *print_data); +void common_print(resource_t * rsc, const char *pre_text, long options, void *print_data); -extern void common_free(resource_t * rsc); -extern void native_add_running(resource_t * rsc, node_t * node, pe_working_set_t * data_set); -extern void get_meta_attributes(GHashTable * meta_hash, resource_t * rsc, +void common_free(resource_t * rsc); +void native_add_running(resource_t * rsc, node_t * node, pe_working_set_t * data_set); +void get_meta_attributes(GHashTable * meta_hash, resource_t * rsc, node_t * node, pe_working_set_t * data_set); -extern void get_rsc_attributes(GHashTable * meta_hash, resource_t * rsc, +void get_rsc_attributes(GHashTable * meta_hash, resource_t * rsc, node_t * node, pe_working_set_t * data_set); typedef struct resource_alloc_functions_s resource_alloc_functions_t; -extern resource_t *uber_parent(resource_t * rsc); -extern node_t *rsc_known_on(resource_t * rsc, GListPtr * list); +resource_t *uber_parent(resource_t * rsc); +node_t *rsc_known_on(resource_t * rsc, GListPtr * list); #endif diff --git a/include/crm/pengine/rules.h b/include/crm/pengine/rules.h index 5455e80978..737aaa8ed7 100644 --- a/include/crm/pengine/rules.h +++ b/include/crm/pengine/rules.h @@ -1,49 +1,49 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PENGINE_RULES__H # define PENGINE_RULES__H # include # include # include enum expression_type { not_expr, nested_rule, attr_expr, loc_expr, role_expr, time_expr }; -extern enum expression_type find_expression_type(xmlNode * expr); +enum expression_type find_expression_type(xmlNode * expr); -extern gboolean test_ruleset(xmlNode * ruleset, GHashTable * node_hash, ha_time_t * now); +gboolean test_ruleset(xmlNode * ruleset, GHashTable * node_hash, ha_time_t * now); -extern gboolean test_rule(xmlNode * rule, GHashTable * node_hash, +gboolean test_rule(xmlNode * rule, GHashTable * node_hash, enum rsc_role_e role, ha_time_t * now); -extern gboolean test_expression(xmlNode * expr, GHashTable * node_hash, +gboolean test_expression(xmlNode * expr, GHashTable * node_hash, enum rsc_role_e role, ha_time_t * now); -extern void unpack_instance_attributes(xmlNode * top, xmlNode * xml_obj, const char *set_name, +void unpack_instance_attributes(xmlNode * top, xmlNode * xml_obj, const char *set_name, GHashTable * node_hash, GHashTable * hash, const char *always_first, gboolean overwrite, ha_time_t * now); #endif diff --git a/include/crm/pengine/status.h b/include/crm/pengine/status.h index 01a26cf737..5f77472ef6 100644 --- a/include/crm/pengine/status.h +++ b/include/crm/pengine/status.h @@ -1,362 +1,362 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PENGINE_STATUS__H # define PENGINE_STATUS__H # include # include # include typedef struct node_s node_t; typedef struct pe_action_s action_t; typedef struct pe_action_s pe_action_t; typedef struct resource_s resource_t; typedef struct ticket_s ticket_t; typedef enum no_quorum_policy_e { no_quorum_freeze, no_quorum_stop, no_quorum_ignore, no_quorum_suicide } no_quorum_policy_t; enum node_type { node_ping, node_member }; enum pe_restart { pe_restart_restart, pe_restart_ignore }; enum pe_find { pe_find_renamed = 0x001, pe_find_partial = 0x002, pe_find_clone = 0x004, pe_find_current = 0x008, pe_find_inactive = 0x010, }; # define pe_flag_have_quorum 0x00000001ULL # define pe_flag_symmetric_cluster 0x00000002ULL # define pe_flag_is_managed_default 0x00000004ULL # define pe_flag_maintenance_mode 0x00000008ULL # define pe_flag_stonith_enabled 0x00000010ULL # define pe_flag_have_stonith_resource 0x00000020ULL # define pe_flag_stop_rsc_orphans 0x00000100ULL # define pe_flag_stop_action_orphans 0x00000200ULL # define pe_flag_stop_everything 0x00000400ULL # define pe_flag_start_failure_fatal 0x00001000ULL # define pe_flag_remove_after_stop 0x00002000ULL # define pe_flag_startup_probes 0x00010000ULL # define pe_flag_have_status 0x00020000ULL typedef struct pe_working_set_s { xmlNode *input; ha_time_t *now; /* options extracted from the input */ char *dc_uuid; node_t *dc_node; const char *stonith_action; const char *placement_strategy; unsigned long long flags; int stonith_timeout; int default_resource_stickiness; no_quorum_policy_t no_quorum_policy; GHashTable *config_hash; GHashTable *domains; GHashTable *tickets; GListPtr nodes; GListPtr resources; GListPtr placement_constraints; GListPtr ordering_constraints; GListPtr colocation_constraints; GListPtr ticket_constraints; GListPtr actions; xmlNode *failed; xmlNode *op_defaults; xmlNode *rsc_defaults; /* stats */ int num_synapse; int max_valid_nodes; int order_id; int action_id; /* final output */ xmlNode *graph; GHashTable *template_rsc_sets; } pe_working_set_t; struct node_shared_s { const char *id; const char *uname; gboolean online; gboolean standby; gboolean standby_onfail; gboolean pending; gboolean unclean; gboolean shutdown; gboolean expected_up; gboolean is_dc; int num_resources; GListPtr running_rsc; /* resource_t* */ GListPtr allocated_rsc; /* resource_t* */ GHashTable *attrs; /* char* => char* */ enum node_type type; GHashTable *utilization; }; struct node_s { int weight; gboolean fixed; int count; struct node_shared_s *details; }; # include # define pe_rsc_orphan 0x00000001ULL # define pe_rsc_managed 0x00000002ULL # define pe_rsc_block 0x00000004ULL /* Further operations are prohibited due to failure policy */ # define pe_rsc_notify 0x00000010ULL # define pe_rsc_unique 0x00000020ULL # define pe_rsc_provisional 0x00000100ULL # define pe_rsc_allocating 0x00000200ULL # define pe_rsc_merging 0x00000400ULL # define pe_rsc_try_reload 0x00001000ULL # define pe_rsc_reload 0x00002000ULL # define pe_rsc_failed 0x00010000ULL # define pe_rsc_shutdown 0x00020000ULL # define pe_rsc_runnable 0x00040000ULL # define pe_rsc_start_pending 0x00080000ULL # define pe_rsc_starting 0x00100000ULL # define pe_rsc_stopping 0x00200000ULL # define pe_rsc_failure_ignored 0x01000000ULL enum pe_graph_flags { pe_graph_none = 0x00000, pe_graph_updated_first = 0x00001, pe_graph_updated_then = 0x00002, pe_graph_disable = 0x00004, }; /* *INDENT-OFF* */ enum pe_action_flags { pe_action_pseudo = 0x00001, pe_action_runnable = 0x00002, pe_action_optional = 0x00004, pe_action_print_always = 0x00008, pe_action_have_node_attrs = 0x00010, pe_action_failure_is_fatal = 0x00020, pe_action_implied_by_stonith = 0x00040, pe_action_dumped = 0x00100, pe_action_processed = 0x00200, pe_action_clear = 0x00400, pe_action_dangle = 0x00800, pe_action_requires_any = 0x01000, /* This action requires one or mre of its dependancies to be runnable * We use this to clear the runnable flag before checking dependancies */ }; /* *INDENT-ON* */ struct resource_s { char *id; char *clone_name; char *long_name; xmlNode *xml; xmlNode *orig_xml; xmlNode *ops_xml; resource_t *parent; void *variant_opaque; enum pe_obj_types variant; resource_object_functions_t *fns; resource_alloc_functions_t *cmds; enum rsc_recovery_type recovery_type; enum pe_restart restart_type; int priority; int stickiness; int sort_index; int failure_timeout; int effective_priority; int migration_threshold; unsigned long long flags; GListPtr rsc_cons_lhs; /* rsc_colocation_t* */ GListPtr rsc_cons; /* rsc_colocation_t* */ GListPtr rsc_location; /* rsc_to_node_t* */ GListPtr actions; /* action_t* */ GListPtr rsc_tickets; /* rsc_ticket* */ node_t *allocated_to; GListPtr running_on; /* node_t* */ GHashTable *known_on; /* node_t* */ GHashTable *allowed_nodes; /* node_t* */ enum rsc_role_e role; enum rsc_role_e next_role; GHashTable *meta; GHashTable *parameters; GHashTable *utilization; GListPtr children; /* resource_t* */ GListPtr dangling_migrations; /* node_t* */ node_t *partial_migration_target; node_t *partial_migration_source; }; struct pe_action_s { int id; int priority; resource_t *rsc; node_t *node; xmlNode *op_entry; char *task; char *uuid; enum pe_action_flags flags; enum rsc_start_requirement needs; enum action_fail_response on_fail; enum rsc_role_e fail_role; action_t *pre_notify; action_t *pre_notified; action_t *post_notify; action_t *post_notified; int seen_count; GHashTable *meta; GHashTable *extra; GListPtr actions_before; /* action_warpper_t* */ GListPtr actions_after; /* action_warpper_t* */ }; typedef struct notify_data_s { GHashTable *keys; const char *action; action_t *pre; action_t *post; action_t *pre_done; action_t *post_done; GListPtr active; /* notify_entry_t* */ GListPtr inactive; /* notify_entry_t* */ GListPtr start; /* notify_entry_t* */ GListPtr stop; /* notify_entry_t* */ GListPtr demote; /* notify_entry_t* */ GListPtr promote; /* notify_entry_t* */ GListPtr master; /* notify_entry_t* */ GListPtr slave; /* notify_entry_t* */ } notify_data_t; struct ticket_s { char *id; gboolean granted; time_t last_granted; gboolean standby; GHashTable *state; }; enum pe_link_state { pe_link_not_dumped, pe_link_dumped, pe_link_dup, }; /* *INDENT-OFF* */ enum pe_ordering { pe_order_none = 0x0, /* deleted */ pe_order_optional = 0x1, /* pure ordering, nothing implied */ pe_order_implies_first = 0x10, /* If 'first' is required, ensure 'then' is too */ pe_order_implies_then = 0x20, /* If 'then' is required, ensure 'first' is too */ pe_order_runnable_left = 0x100, /* 'then' requires 'first' to be runnable */ pe_order_restart = 0x1000, /* 'then' is runnable if 'first' is optional or runnable */ pe_order_stonith_stop = 0x2000, /* only applies if the action is non-pseudo */ pe_order_serialize_only = 0x4000, /* serialize */ pe_order_implies_first_printed = 0x10000, /* Like ..implies_first but only ensures 'first' is printed, not manditory */ pe_order_implies_then_printed = 0x20000, /* Like ..implies_then but only ensures 'then' is printed, not manditory */ pe_order_asymmetrical = 0x100000, /* Indicates asymmetrical one way ordering constraint. */ pe_order_load = 0x200000, /* Only relevant if... */ pe_order_one_or_more = 0x400000, /* 'then' is only runnable if one or more of it's dependancies are too */ pe_order_trace = 0x4000000 /* test marker */ }; /* *INDENT-ON* */ typedef struct action_wrapper_s action_wrapper_t; struct action_wrapper_s { enum pe_ordering type; enum pe_link_state state; action_t *action; }; gboolean cluster_status(pe_working_set_t * data_set); -extern void set_working_set_defaults(pe_working_set_t * data_set); -extern void cleanup_calculations(pe_working_set_t * data_set); -extern resource_t *pe_find_resource(GListPtr rsc_list, const char *id_rh); -extern node_t *pe_find_node(GListPtr node_list, const char *uname); -extern node_t *pe_find_node_id(GListPtr node_list, const char *id); -extern GListPtr find_operations(const char *rsc, const char *node, gboolean active_filter, +void set_working_set_defaults(pe_working_set_t * data_set); +void cleanup_calculations(pe_working_set_t * data_set); +resource_t *pe_find_resource(GListPtr rsc_list, const char *id_rh); +node_t *pe_find_node(GListPtr node_list, const char *uname); +node_t *pe_find_node_id(GListPtr node_list, const char *id); +GListPtr find_operations(const char *rsc, const char *node, gboolean active_filter, pe_working_set_t * data_set); # define pe_set_action_bit(action, bit) action->flags = crm_set_bit(__FUNCTION__, action->uuid, action->flags, bit) # define pe_clear_action_bit(action, bit) action->flags = crm_clear_bit(__FUNCTION__, action->uuid, action->flags, bit) #endif diff --git a/include/crm/stonith-ng-internal.h b/include/crm/stonith-ng-internal.h index be66d45d64..39871f5d5a 100644 --- a/include/crm/stonith-ng-internal.h +++ b/include/crm/stonith-ng-internal.h @@ -1,62 +1,62 @@ /* * Copyright (C) 2011 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef STONITH_NG_INTERNAL__H # define STONITH_NG_INTERNAL__H # include # include # include typedef struct async_command_s { int id; int stdout; int options; int timeout; char *op; char *origin; char *client; char *remote; char *victim; char *action; char *device; GListPtr device_list; GListPtr device_next; void (*done)(GPid pid, gint status, gpointer user_data); guint timer_sigterm; guint timer_sigkill; } async_command_t; -extern int run_stonith_agent(const char *agent, const char *action, const char *victim, +int run_stonith_agent(const char *agent, const char *action, const char *victim, GHashTable * dev_hash, GHashTable * port_map, int *agent_result, char **output, async_command_t * track); -extern gboolean is_redhat_agent(const char *agent); +gboolean is_redhat_agent(const char *agent); xmlNode *create_level_registration_xml(const char *node, int level, stonith_key_value_t * device_list); xmlNode *create_device_registration_xml(const char *id, const char *namespace, const char *agent, stonith_key_value_t * params); #endif diff --git a/include/crm/stonith-ng.h b/include/crm/stonith-ng.h index a7da013ac8..88ca4c2d5a 100644 --- a/include/crm/stonith-ng.h +++ b/include/crm/stonith-ng.h @@ -1,317 +1,317 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef STONITH_NG__H # define STONITH_NG__H # include # include /* TO-DO: Work out how to drop this requirement */ # include /* *INDENT-OFF* */ enum stonith_state { stonith_connected_command, stonith_connected_query, stonith_disconnected, }; enum stonith_call_options { st_opt_none = 0x00000000, st_opt_verbose = 0x00000001, st_opt_allow_suicide = 0x00000002, st_opt_manual_ack = 0x00000008, st_opt_discard_reply = 0x00000010, st_opt_all_replies = 0x00000020, st_opt_topology = 0x00000040, st_opt_scope_local = 0x00000100, st_opt_cs_nodeid = 0x00000200, st_opt_sync_call = 0x00001000, }; #define stonith_default_options = stonith_none enum stonith_errors { stonith_ok = 0, stonith_pending = -1, st_err_generic = -2, st_err_internal = -3, st_err_not_supported = -4, st_err_connection = -5, st_err_missing = -6, st_err_exists = -7, st_err_timeout = -8, st_err_ipc = -9, st_err_peer = -10, st_err_unknown_operation = -11, st_err_unknown_device = -12, st_err_unknown_port = -13, st_err_none_available = -14, st_err_authentication = -15, st_err_signal = -16, st_err_agent_fork = -17, st_err_agent_args = -18, st_err_agent = -19, st_err_invalid_target = -20, st_err_invalid_level = -21, }; #define ST_LEVEL_MAX 10 #define F_STONITH_CLIENTID "st_clientid" #define F_STONITH_CALLOPTS "st_callopt" #define F_STONITH_CALLID "st_callid" #define F_STONITH_CALLDATA "st_calldata" #define F_STONITH_OPERATION "st_op" #define F_STONITH_TARGET "st_target" #define F_STONITH_REMOTE "st_remote_op" #define F_STONITH_RC "st_rc" #define F_STONITH_TIMEOUT "st_timeout" #define F_STONITH_CALLBACK_TOKEN "st_async_id" #define F_STONITH_CLIENTNAME "st_clientname" #define F_STONITH_NOTIFY_TYPE "st_notify_type" #define F_STONITH_NOTIFY_ACTIVATE "st_notify_activate" #define F_STONITH_NOTIFY_DEACTIVATE "st_notify_deactivate" #define F_STONITH_DELEGATE "st_delegate" #define F_STONITH_ORIGIN "st_origin" #define F_STONITH_HISTORY_LIST "st_history" #define F_STONITH_DATE "st_date" #define F_STONITH_STATE "st_state" #define F_STONITH_LEVEL "st_level" #define T_STONITH_NG "stonith-ng" #define T_STONITH_REPLY "st-reply" #define F_STONITH_DEVICE "st_device_id" #define F_STONITH_ACTION "st_device_action" #define T_STONITH_NOTIFY "st_notify" #define T_STONITH_NOTIFY_DISCONNECT "st_notify_disconnect" #define STONITH_ATTR_ARGMAP "pcmk_arg_map" #define STONITH_ATTR_HOSTARG "pcmk_host_argument" #define STONITH_ATTR_HOSTMAP "pcmk_host_map" #define STONITH_ATTR_HOSTLIST "pcmk_host_list" #define STONITH_ATTR_HOSTCHECK "pcmk_host_check" #define STONITH_ATTR_ACTION_OP "option" /* To be replaced by 'action' at some point */ #define STONITH_OP_EXEC "st_execute" #define STONITH_OP_QUERY "st_query" #define STONITH_OP_FENCE "st_fence" #define STONITH_OP_CONFIRM "st_confirm" #define STONITH_OP_DEVICE_ADD "st_device_register" #define STONITH_OP_DEVICE_DEL "st_device_remove" #define STONITH_OP_DEVICE_METADATA "st_device_metadata" #define STONITH_OP_FENCE_HISTORY "st_fence_history" #define STONITH_OP_LEVEL_ADD "st_level_add" #define STONITH_OP_LEVEL_DEL "st_level_remove" #define stonith_channel "st_command" #define stonith_channel_callback "st_callback" enum op_state { st_query, st_exec, st_done, st_failed, }; typedef struct stonith_key_value_s { char *key; char *value; struct stonith_key_value_s *next; } stonith_key_value_t; typedef struct stonith_history_s { char *target; char *action; char *origin; char *delegate; int completed; int state; struct stonith_history_s *next; } stonith_history_t; typedef struct stonith_s stonith_t; typedef struct stonith_api_operations_s { int (*free) (stonith_t *st); int (*connect) (stonith_t *st, const char *name, int *stonith_fd); int (*disconnect)(stonith_t *st); int (*remove_device)( stonith_t *st, int options, const char *name); int (*register_device)( stonith_t *st, int options, const char *id, const char *namespace, const char *agent, stonith_key_value_t *params); int (*remove_level)( stonith_t *st, int options, const char *node, int level); int (*register_level)( stonith_t *st, int options, const char *node, int level, stonith_key_value_t *device_list); int (*metadata)(stonith_t *st, int options, const char *device, const char *namespace, char **output, int timeout); int (*list)(stonith_t *stonith, int call_options, const char *namespace, stonith_key_value_t **devices, int timeout); int (*call)(stonith_t *st, int options, const char *id, const char *action, const char *port, int timeout); int (*query)(stonith_t *st, int options, const char *node, stonith_key_value_t **devices, int timeout); int (*fence)(stonith_t *st, int options, const char *node, const char *action, int timeout); int (*confirm)(stonith_t *st, int options, const char *node); int (*history)(stonith_t *st, int options, const char *node, stonith_history_t **output, int timeout); int (*register_notification)( stonith_t *st, const char *event, void (*notify)(stonith_t *st, const char *event, xmlNode *msg)); int (*remove_notification)(stonith_t *st, const char *event); int (*register_callback)( stonith_t *st, int call_id, int timeout, bool only_success, void *userdata, const char *callback_name, void (*callback)(stonith_t *st, const xmlNode *msg, int call, int rc, xmlNode *output, void *userdata)); int (*remove_callback)(stonith_t *st, int call_id, bool all_callbacks); } stonith_api_operations_t; struct stonith_s { enum stonith_state state; int call_id; int call_timeout; void *private; stonith_api_operations_t *cmds; }; /* *INDENT-ON* */ /* Core functions */ -extern stonith_t *stonith_api_new(void); -extern void stonith_api_delete(stonith_t * st); +stonith_t *stonith_api_new(void); +void stonith_api_delete(stonith_t * st); -extern const char *stonith_error2string(enum stonith_errors return_code); -extern void stonith_dump_pending_callbacks(stonith_t * st); +const char *stonith_error2string(enum stonith_errors return_code); +void stonith_dump_pending_callbacks(stonith_t * st); -extern const char *get_stonith_provider(const char *agent, const char *provider); +const char *get_stonith_provider(const char *agent, const char *provider); -extern bool stonith_dispatch(stonith_t * st); +bool stonith_dispatch(stonith_t * st); -extern stonith_key_value_t *stonith_key_value_add(stonith_key_value_t * kvp, const char *key, +stonith_key_value_t *stonith_key_value_add(stonith_key_value_t * kvp, const char *key, const char *value); -extern void stonith_key_value_freeall(stonith_key_value_t * kvp, int keys, int values); +void stonith_key_value_freeall(stonith_key_value_t * kvp, int keys, int values); /* Basic helpers that allows nodes to be fenced and the history to be * queried without mainloop or the caller understanding the full API * * At least one of nodeid and uname are required */ -extern int stonith_api_kick(int nodeid, const char *uname, int timeout, bool off); -extern time_t stonith_api_time(int nodeid, const char *uname, bool in_progress); +int stonith_api_kick(int nodeid, const char *uname, int timeout, bool off); +time_t stonith_api_time(int nodeid, const char *uname, bool in_progress); /* * Helpers for using the above functions without install-time dependancies * * Usage: * #include * * To turn a node off by corosync nodeid: * stonith_api_kick_helper(nodeid, 120, 1); * * To check the last fence date/time (also by nodeid): * last = stonith_api_time_helper(nodeid, 0); * * To check if fencing is in progress: * if(stonith_api_time_helper(nodeid, 1) > 0) { ... } * * eg. #include #include #include int main(int argc, char ** argv) { int rc = 0; int nodeid = 102; rc = stonith_api_time_helper(nodeid, 0); printf("%d last fenced at %s\n", nodeid, ctime(rc)); rc = stonith_api_kick_helper(nodeid, 120, 1); printf("%d fence result: %d\n", nodeid, rc); rc = stonith_api_time_helper(nodeid, 0); printf("%d last fenced at %s\n", nodeid, ctime(rc)); return 0; } */ # define STONITH_LIBRARY "libstonithd.so.1" static inline int stonith_api_kick_helper(int nodeid, int timeout, bool off) { static void *st_library = NULL; static int (*st_kick_fn) (int nodeid, const char *uname, int timeout, bool off) = NULL; if (st_library == NULL) { st_library = dlopen(STONITH_LIBRARY, RTLD_LAZY); } if (st_library && st_kick_fn == NULL) { st_kick_fn = dlsym(st_library, "stonith_api_kick"); } if (st_kick_fn == NULL) { return st_err_not_supported; } return (*st_kick_fn) (nodeid, NULL, timeout, off); } static inline time_t stonith_api_time_helper(int nodeid, bool in_progress) { static void *st_library = NULL; static time_t(*st_time_fn) (int nodeid, const char *uname, bool in_progress) = NULL; if (st_library == NULL) { st_library = dlopen(STONITH_LIBRARY, RTLD_LAZY); } if (st_library && st_time_fn == NULL) { st_time_fn = dlsym(st_library, "stonith_api_time"); } if (st_time_fn == NULL) { return 0; } return (*st_time_fn) (nodeid, NULL, in_progress); } #endif diff --git a/include/crm/transition.h b/include/crm/transition.h index 02eff0357e..d02e95dca3 100644 --- a/include/crm/transition.h +++ b/include/crm/transition.h @@ -1,157 +1,157 @@ /* * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include typedef enum { action_type_pseudo, action_type_rsc, action_type_crm } action_type_e; typedef struct te_timer_s crm_action_timer_t; typedef struct synapse_s { int id; int priority; gboolean ready; gboolean failed; gboolean executed; gboolean confirmed; GListPtr actions; /* crm_action_t* */ GListPtr inputs; /* crm_action_t* */ } synapse_t; typedef struct crm_action_s { int id; int timeout; int interval; GHashTable *params; action_type_e type; crm_action_timer_t *timer; synapse_t *synapse; gboolean sent_update; /* sent to the CIB */ gboolean executed; /* sent to the CRM */ gboolean confirmed; gboolean failed; gboolean can_fail; xmlNode *xml; } crm_action_t; enum timer_reason { timeout_action, timeout_action_warn, timeout_abort, }; struct te_timer_s { int source_id; int timeout; enum timer_reason reason; crm_action_t *action; }; /* order matters here */ enum transition_action { tg_done, tg_stop, tg_restart, tg_shutdown, }; typedef struct crm_graph_s { int id; char *source; int abort_priority; gboolean complete; const char *abort_reason; enum transition_action completion_action; int num_actions; int num_synapses; int batch_limit; int network_delay; int stonith_timeout; int transition_timeout; int fired; int pending; int skipped; int completed; int incomplete; GListPtr synapses; /* synpase_t* */ int migration_limit; GHashTable *migrating; } crm_graph_t; typedef struct crm_graph_functions_s { gboolean(*pseudo) (crm_graph_t * graph, crm_action_t * action); gboolean(*rsc) (crm_graph_t * graph, crm_action_t * action); gboolean(*crmd) (crm_graph_t * graph, crm_action_t * action); gboolean(*stonith) (crm_graph_t * graph, crm_action_t * action); } crm_graph_functions_t; enum transition_status { transition_active, transition_pending, /* active but no actions performed this time */ transition_complete, transition_stopped, transition_terminated, transition_action_failed, transition_failed, }; -extern void set_default_graph_functions(void); -extern void set_graph_functions(crm_graph_functions_t * fns); -extern crm_graph_t *unpack_graph(xmlNode * xml_graph, const char *reference); -extern int run_graph(crm_graph_t * graph); -extern gboolean update_graph(crm_graph_t * graph, crm_action_t * action); -extern void destroy_graph(crm_graph_t * graph); -extern const char *transition_status(enum transition_status state); -extern void print_graph(unsigned int log_level, crm_graph_t * graph); -extern void print_action(int log_level, const char *prefix, crm_action_t * action); -extern void update_abort_priority(crm_graph_t * graph, int priority, +void set_default_graph_functions(void); +void set_graph_functions(crm_graph_functions_t * fns); +crm_graph_t *unpack_graph(xmlNode * xml_graph, const char *reference); +int run_graph(crm_graph_t * graph); +gboolean update_graph(crm_graph_t * graph, crm_action_t * action); +void destroy_graph(crm_graph_t * graph); +const char *transition_status(enum transition_status state); +void print_graph(unsigned int log_level, crm_graph_t * graph); +void print_action(int log_level, const char *prefix, crm_action_t * action); +void update_abort_priority(crm_graph_t * graph, int priority, enum transition_action action, const char *abort_reason); -extern const char *actiontype2text(action_type_e type); +const char *actiontype2text(action_type_e type); #ifdef TESTING # define te_log_action(log_level, fmt, args...) { \ do_crm_log(log_level, fmt, ##args); \ fprintf(stderr, fmt"\n", ##args); \ } #else # define te_log_action(log_level, fmt, args...) do_crm_log(log_level, fmt, ##args) #endif #include -extern lrm_op_t *convert_graph_action(xmlNode * resource, crm_action_t * action, int status, +lrm_op_t *convert_graph_action(xmlNode * resource, crm_action_t * action, int status, int rc);