diff --git a/transitioner/Makefile.am b/transitioner/Makefile.am deleted file mode 100644 index eb6274f913..0000000000 --- a/transitioner/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -# -# 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 program 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 program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -MAINTAINERCLEANFILES = Makefile.in - -INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ - -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl - -halibdir = $(libdir)/@HB_PKG@ - -COMMONLIBS = \ - $(top_builddir)/lib/crm/common/libcrmcommon.la \ - $(top_builddir)/lib/crm/cib/libcib.la \ - $(CLUSTERLIBS) $(GLIBLIB) $(LIBRT) $(GNUTLSLIBS) - -## binary progs -halib_PROGRAMS = tengine ttest - -## SOURCES -noinst_HEADERS = tengine.h te_callbacks.h - -tengine_SOURCES = actions.c events.c utils.c callbacks.c main.c -tengine_LDADD = $(COMMONLIBS) $(CLUSTERLIBS) \ - $(top_builddir)/lib/crm/transition/libtransitioner.la - -ttest_SOURCES = actions.c events.c utils.c callbacks.c ttest.c -ttest_LDADD = $(COMMONLIBS) $(CLUSTERLIBS) \ - $(top_builddir)/lib/crm/transition/libtransitioner.la - -clean-generic: - rm -f *.log *.debug *~ - -install-exec-local: - -uninstall-local: diff --git a/transitioner/main.c b/transitioner/main.c deleted file mode 100644 index b11ff6f52e..0000000000 --- a/transitioner/main.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) 2004 Andrew Beekhof - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#define OPTARGS "hVc" - -GMainLoop* mainloop = NULL; -cib_t *te_cib_conn = NULL; - -void usage(const char* cmd, int exit_status); -int te_init(void); -gboolean tengine_shutdown(int nsig, gpointer unused); -extern void te_update_confirm(const char *event, xmlNode *msg); -extern void te_update_diff(const char *event, xmlNode *msg); -extern crm_graph_functions_t te_graph_fns; - -int -main(int argc, char ** argv) -{ - int flag; - int rc = 0; - int dummy = 0; - int argerr = 0; - gboolean allow_cores = TRUE; - - crm_log_init(CRM_SYSTEM_TENGINE, LOG_INFO, TRUE, FALSE, 0, NULL); - G_main_add_SignalHandler( - G_PRIORITY_HIGH, SIGTERM, tengine_shutdown, NULL, NULL); - - transition_trigger = G_main_add_TriggerHandler( - G_PRIORITY_LOW, te_graph_trigger, NULL, NULL); - - stonith_reconnect = G_main_add_TriggerHandler( - G_PRIORITY_LOW, te_connect_stonith, &dummy, NULL); - - crm_debug_3("Begining option processing"); - - while ((flag = getopt(argc, argv, OPTARGS)) != EOF) { - switch(flag) { - case 'V': - alter_debug(DEBUG_INC); - break; - case 'h': /* Help message */ - usage(crm_system_name, LSB_EXIT_OK); - break; - case 'c': - allow_cores = TRUE; - break; - - default: - ++argerr; - break; - } - } - - crm_debug_3("Option processing complete"); - - if (optind > argc) { - ++argerr; - } - - if (argerr) { - usage(crm_system_name,LSB_EXIT_GENERIC); - } - - /* read local config file */ - crm_debug_3("Starting..."); - rc = te_init(); - return rc; -} - -int -te_init(void) -{ - int init_ok = TRUE; - - init_client_ipc_comms( - CRM_SYSTEM_CRMD, subsystem_msg_dispatch, - (void*)process_te_message, &crm_ch); - - if(crm_ch != NULL) { - send_hello_message(crm_ch, "1234", CRM_SYSTEM_TENGINE, "0", "1"); - } else { - init_ok = FALSE; - crm_err("Could not connect to the CRMd"); - } - - if(init_ok) { - crm_debug_4("Creating CIB connection"); - te_cib_conn = cib_new(); - if(te_cib_conn == NULL) { - init_ok = FALSE; - } - } - - if(init_ok) { - crm_debug_4("Connecting to the CIB"); - if(cib_ok != te_cib_conn->cmds->signon( - te_cib_conn, crm_system_name, cib_command)) { - crm_err("Could not connect to the CIB"); - init_ok = FALSE; - } - } - - if(init_ok) { - crm_debug_4("Setting CIB notification callback"); - if(cib_ok != te_cib_conn->cmds->add_notify_callback( - te_cib_conn, T_CIB_DIFF_NOTIFY, te_update_diff)) { - crm_err("Could not set CIB notification callback"); - init_ok = FALSE; - } - } - - if(is_heartbeat_cluster() && init_ok) { - G_main_set_trigger(stonith_reconnect); - } - - if(init_ok) { - cl_uuid_t new_uuid; - char uuid_str[UU_UNPARSE_SIZEOF]; - - cl_uuid_generate(&new_uuid); - cl_uuid_unparse(&new_uuid, uuid_str); - te_uuid = crm_strdup(uuid_str); - crm_info("Registering TE UUID: %s", te_uuid); - set_graph_functions(&te_graph_fns); - - /* create a blank one */ - transition_graph = unpack_graph(NULL); - transition_graph->complete = TRUE; - transition_graph->abort_reason = "DC Takeover"; - transition_graph->completion_action = tg_restart; - - crm_malloc0(transition_timer, sizeof(crm_action_timer_t)); - transition_timer->source_id = 0; - transition_timer->reason = timeout_abort; - transition_timer->action = NULL; - } - - if(init_ok) { - /* Create the mainloop and run it... */ - crm_info("Starting %s", crm_system_name); - - mainloop = g_main_new(FALSE); - - g_main_run(mainloop); - return_to_orig_privs(); - - crm_info("Exiting %s", crm_system_name); - - } else { - crm_warn("Initialization errors, %s not starting.", - crm_system_name); - } - - destroy_graph(transition_graph); - crm_free(transition_timer); - - te_cib_conn->cmds->signoff(te_cib_conn); - cib_delete(te_cib_conn); - te_cib_conn = NULL; - -#if SUPPORT_HEARTBEAT - if(is_heartbeat_cluster()) { - stonithd_signoff(); - } -#endif - crm_free(te_uuid); - - if(init_ok) { - return 0; - } - return 1; -} - -void -usage(const char* cmd, int exit_status) -{ - FILE* stream; - - stream = exit_status ? stderr : stdout; - - fprintf(stream, "usage: %s [-srkh]" - "[-c configure file]\n", cmd); -/* fprintf(stream, "\t-d\tsets debug level\n"); */ -/* fprintf(stream, "\t-s\tgets daemon status\n"); */ -/* fprintf(stream, "\t-r\trestarts daemon\n"); */ -/* fprintf(stream, "\t-k\tstops daemon\n"); */ -/* fprintf(stream, "\t-h\thelp message\n"); */ - fflush(stream); - - exit(exit_status); -} - -gboolean shuttingdown; -gboolean -tengine_shutdown(int nsig, gpointer unused) -{ - shuttingdown = TRUE; - abort_transition(INFINITY, tg_shutdown, "Shutdown", NULL); - return TRUE; -} diff --git a/transitioner/te_fsa.h b/transitioner/te_fsa.h deleted file mode 100644 index 8962ace5a5..0000000000 --- a/transitioner/te_fsa.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2004 Andrew Beekhof - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include - -extern GListPtr input_queue; - -typedef struct te_input_s te_input_t; - -enum te_data_type -{ - te_data_cib, - te_data_complete, - te_data_command, - te_data_null -}; - -typedef struct te_data_operations_s -{ - enum te_data_type(*type)(void); - const char* (*name)(void); - void (*free)(te_input_t*); - void (*copy)(te_input_t*); -} te_data_op_t; - -struct te_input_s -{ - int id; - char *origin; - te_fsa_input_t input; - - te_data_op_t *ops; - void *data; -}; - -struct te_data_command_s { - xmlNode *msg; - xmlNode *xml; -}; - -struct te_data_cib_s { - xmlNode *msg; - xmlNode *xml; - int call_id; - int rc; - void *user_data; /* not copied or free'd */ -}; - -struct te_data_complete_s { - const char *text; - xmlNode *xml; - te_reason_t reason; -}; - -extern void te_input_free(te_input_t *fsa_data); -extern te_input_t* te_input_copy(te_input_t *fsa_data); -extern te_input_t* te_input_new(enum te_data_type type, void *data); - -extern te_input_t *new_input_command(xmlNode *msg, xmlNode *xml); - -extern te_input_t *new_input_complete(const char *text, xmlNode *xml, - te_reason_t reason, te_fsa_input_t input); - -extern te_input_t *new_input_cib(xmlNode *msg, xmlNode *xml, - int call_id, int rc, void *user_data); - -extern te_input_t *new_input_null(void); - -extern te_input_t *get_input(void); - diff --git a/transitioner/ttest.c b/transitioner/ttest.c deleted file mode 100644 index 5389594664..0000000000 --- a/transitioner/ttest.c +++ /dev/null @@ -1,174 +0,0 @@ - -/* - * Copyright (C) 2004 Andrew Beekhof - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#define OPTARGS "V?X:" - -#include -#include -#include - -GMainLoop* mainloop = NULL; -crm_graph_t *transition_graph = NULL; -cib_t *te_cib_conn = NULL; - -static gboolean -ttest_pseudo_command(crm_graph_t *graph, crm_action_t *pseudo) -{ - crm_debug("Event handler: action %d executed", pseudo->id); - pseudo->confirmed = TRUE; - update_graph(graph, pseudo); - trigger_graph(); - return TRUE; -} - -static gboolean -ttest_rsc_command(crm_graph_t *graph, crm_action_t *pseudo) -{ -/* send_rsc_command(action); */ - return TRUE; -} - -crm_graph_functions_t ttest_graph_fns = { - ttest_pseudo_command, - ttest_rsc_command, - ttest_pseudo_command, - ttest_pseudo_command, -}; - -int -main(int argc, char **argv) -{ - int flag; - int argerr = 0; - const char *xml_file = NULL; - xmlNode *xml_graph = NULL; - - set_crm_log_level(0); -/* crm_log_init("ttest"); */ - g_log_set_handler(NULL, - G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL - | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE - | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG - | G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL, - cl_glib_msg_handler, NULL); - - /* and for good measure... - this enum is a bit field (!) */ - g_log_set_always_fatal((GLogLevelFlags)0); /*value out of range*/ - set_crm_log_level(LOG_WARNING); - - transition_trigger = G_main_add_TriggerHandler( - G_PRIORITY_LOW, te_graph_trigger, NULL, NULL); - - set_graph_functions(&ttest_graph_fns); - - while (1) { - flag = getopt(argc, argv, OPTARGS); - if (flag == -1) - break; - - switch(flag) { - case 'X': - xml_file = crm_strdup(optarg); - break; - - case 'V': - cl_log_enable_stderr(TRUE); - alter_debug(DEBUG_INC); - break; - default: - printf("?? getopt returned character code 0%o ??\n", flag); - ++argerr; - break; - } - } - - if (optind < argc) { - printf("non-option ARGV-elements: "); - while (optind < argc) - printf("%s ", argv[optind++]); - printf("\n"); - } - - if (optind > argc) { - ++argerr; - } - - if (argerr) { - crm_err("%d errors in option parsing", argerr); - } - - crm_debug("=#=#=#=#= Getting XML =#=#=#=#="); - if(xml_file != NULL) { - FILE *xml_strm = fopen(xml_file, "r"); - if(xml_strm) { - xml_graph = file2xml(xml_strm, FALSE); - fclose(xml_strm); - - } else { - cl_perror("Could not open %s for reading", xml_file); - xml_file = NULL; - } - - } - if(xml_file == NULL) { - xml_graph = stdin2xml(); - } - -#ifdef MTRACE - mtrace(); -#endif - - transition_graph = unpack_graph(xml_graph); - trigger_graph(); - print_graph(LOG_DEBUG, transition_graph); - transition_graph->completion_action = tg_shutdown; - - mainloop = g_main_new(FALSE); - - g_main_run(mainloop); - - crm_info("Exiting ttest"); - -#ifdef MTRACE - muntrace(); -#endif - crm_debug_4("Transition complete..."); - - return 0; -} -