├── .gitattributes ├── .hgignore ├── ConfigureMe ├── Makefile.am ├── README.in ├── acinclude.m4 ├── bootstrap ├── cim ├── .cvsignore ├── Makefile.am ├── attrs_of_resource_provider.c ├── cluster_indication_provider.c ├── cluster_info.c ├── cluster_info.h ├── cluster_node_provider.c ├── cluster_provider.c ├── clustering_service_provider.c ├── cmpi_utils.c ├── cmpi_utils.h ├── colocation_constraint_provider.c ├── constraint_common.c ├── constraint_common.h ├── constraint_rule_provider.c ├── hosted_resource_provider.c ├── installed_software_provider.c ├── instance_attrs_provider.c ├── location_constraint_provider.c ├── masterslave_resource_provider.c ├── mgmt_client.c ├── mgmt_client.h ├── mof │ ├── .cvsignore │ ├── LinuxHA.fig │ ├── LinuxHA.mof │ ├── LinuxHA.reg │ ├── Makefile.am │ ├── do_register.sh │ ├── register_providers.sh.in │ └── unregister_providers.sh.in ├── mof_map.c ├── mof_map.h ├── operation_on_provider.c ├── operation_provider.c ├── order_constraint_provider.c ├── participating_node_provider.c ├── primitive_resource_provider.c ├── resource_clone_provider.c ├── resource_common.c ├── resource_common.h ├── resource_group_provider.c ├── rule_of_constraint_provider.c ├── simple_test.c ├── software_identity_provider.c ├── subresource_provider.c ├── tests │ ├── CreateFilter.xml │ ├── CreateHandler.xml │ ├── CreateSubscription.xml │ ├── DeleteFilter.xml │ ├── DeleteHandler.xml │ ├── DeleteSubscription.xml │ ├── ResourceTest.sh │ ├── runtest.sh │ └── subscription.sh ├── utils.c └── utils.h ├── configure.in ├── debian ├── Makefile.am ├── apply ├── changelog ├── compat ├── control ├── copyright ├── dpkg-checkbuild ├── pacemaker-mgmt-client.dirs ├── pacemaker-mgmt-client.install ├── pacemaker-mgmt-dev.dirs ├── pacemaker-mgmt-dev.install ├── pacemaker-mgmt.dirs ├── pacemaker-mgmt.files ├── pacemaker-mgmt.install ├── pycompat └── rules ├── doc ├── AUTHORS ├── COPYING ├── COPYING.LGPL └── Makefile.am ├── include ├── Makefile.am ├── mgmt │ ├── .cvsignore │ ├── Makefile.am │ ├── mgmt.h │ ├── mgmt_client.h │ ├── mgmt_common.h │ └── mgmt_tls.h ├── mgmt_config.h.in ├── portability.h └── pygui_internal.h ├── intltool-extract.in ├── intltool-merge.in ├── intltool-update.in ├── lib ├── Makefile.am └── mgmt │ ├── .cvsignore │ ├── Makefile.am │ ├── mgmt_client_lib.c │ ├── mgmt_common_lib.c │ ├── mgmt_tls_lib.c │ └── pymgmt.i ├── mgmt ├── .cvsignore ├── Makefile.am ├── client │ ├── .cvsignore │ ├── Makefile.am │ ├── active-node.png │ ├── add-resource.png │ ├── administration.png │ ├── cleanup-resource.png │ ├── crm_gui.desktop.in │ ├── default-resource.png │ ├── dirty-stopped.png │ ├── down-resource.png │ ├── exit.png │ ├── expert-mode.png │ ├── failed.png │ ├── ha.png │ ├── haclient.glade │ ├── haclient.py.in │ ├── login.png │ ├── logout.png │ ├── manage-resource.png │ ├── master-resource.png │ ├── mgmtcmd.py.in │ ├── mgmtdtest.c │ ├── node.png │ ├── nodes.png │ ├── record-pending.png │ ├── remove-resource.png │ ├── running.png │ ├── slave-resource.png │ ├── standby-node.png │ ├── start-resource.png │ ├── starting.png │ ├── stop-resource.png │ ├── stopped.png │ ├── stopping.png │ ├── unmanage-resource.png │ └── up-resource.png └── daemon │ ├── .cvsignore │ ├── Makefile.am │ ├── mgmt_crm.c │ ├── mgmt_hb.c │ ├── mgmt_internal.h │ ├── mgmt_lib.c │ ├── mgmt_lrm.c │ ├── mgmt_pacemaker_lrm.c │ ├── mgmtd.c │ ├── mgmtd.pam │ └── mgmtd.pam.common ├── po ├── LINGUAS ├── Makefile.in.in ├── POTFILES.in ├── haclient.pot ├── ja.po └── zh_CN.po ├── replace ├── .cvsignore ├── Makefile.am ├── NoSuchFunctionName.c ├── alphasort.c ├── daemon.c ├── inet_pton.c ├── scandir.c ├── setenv.c ├── strerror.c ├── strlcat.c ├── strlcpy.c ├── strndup.c ├── strnlen.c ├── unsetenv.c └── uuid_parse.c ├── snmp_subagent ├── .cvsignore ├── LHAClusterInfo.c ├── LHAClusterInfo.h ├── LHAHeartbeatConfigInfo.c ├── LHAHeartbeatConfigInfo.h ├── LHAIFStatusTable.c ├── LHAIFStatusTable.h ├── LHAIFStatusTable_columns.h ├── LHAIFStatusTable_enums.h ├── LHAMembershipTable.c ├── LHAMembershipTable.h ├── LHAMembershipTable_columns.h ├── LHAMembershipTable_enums.h ├── LHANodeTable.c ├── LHANodeTable.h ├── LHANodeTable_columns.h ├── LHANodeTable_enums.h ├── LHAResourceGroupTable.c ├── LHAResourceGroupTable.h ├── LHAResourceGroupTable_columns.h ├── LHAResourceGroupTable_enums.h ├── LHAResourceStatusUpdate.c ├── LHAResourceStatusUpdate.h ├── LHAResourceTable.c ├── LHAResourceTable.h ├── LHAResourceTable_columns.h ├── LHAResourceTable_enums.h ├── LINUX-HA-MIB.txt ├── Makefile.am ├── README.hbagent ├── README.hbagentv2 ├── SNMPAgentSanityCheck.in ├── hbagent.c ├── hbagent.h ├── hbagentv2.c ├── hbagentv2.h └── snmp-config-resolve.h └── tsa_plugin ├── .cvsignore ├── Makefile.am ├── README ├── dummy.c ├── ha_mgmt_client.c ├── ha_mgmt_client.h ├── ha_mgmt_client.i ├── ha_tsa_common.c ├── ha_tsa_common.h ├── linuxha-adapter.in ├── org └── linuxha │ └── sam │ └── plugin │ ├── LHACLIClient.java │ ├── LHAClient.java │ ├── LHAClusterManager.java │ ├── LHAColocationConstraint.java │ ├── LHAConstraint.java │ ├── LHAEventdClient.java │ ├── LHALocationConstraint.java │ ├── LHANativeClient.java │ ├── LHANativeResource.java │ ├── LHANodeResource.java │ ├── LHAOrderConstraint.java │ ├── LHAResource.java │ ├── LHAResourceGroup.java │ ├── LinuxHAFLA.java │ ├── LinuxHAPlugin.java │ └── Utilities.java ├── testrun.sh.in ├── tsa_eventd.c └── tsa_hacli.c /.gitattributes: -------------------------------------------------------------------------------- 1 | configure.in export-subst 2 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # linux-ha: Linux-HA code 3 | # 4 | # Copyright (C) 2002 Alan Robertson 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | # 20 | 21 | EXTRA_DIST = bootstrap ConfigureMe README.in libltdl.tar 22 | AUTOMAKE_OPTIONS = foreign 23 | 24 | MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure DRF/config-h.in \ 25 | DRF/stamp-h.in libtool.m4 ltdl.m4 libltdl.tar 26 | coredir = @HA_COREDIR@ 27 | hauser = @HA_CCMUSER@ 28 | 29 | TARFILE = pacemaker-mgmt.tar.gz 30 | LAST_RELEASE = pacemaker-mgmt-1.99.2 31 | 32 | if CIM_PROVIDER_BUILD 33 | CIM_PROVIDER_DIR = cim 34 | endif 35 | 36 | if TSA_PLUGIN_BUILD 37 | TSA_PLUGIN_DIR = tsa_plugin 38 | endif 39 | 40 | if SNMP_SUBAGENT_BUILD 41 | SNMP_SUBAGENT_DIR = snmp_subagent 42 | endif 43 | 44 | SUBDIRS = $(LIBLTDL_DIR) replace include lib mgmt $(CIM_PROVIDER_DIR) $(TSA_PLUGIN_DIR) $(SNMP_SUBAGENT_DIR) doc 45 | 46 | if MGMT_CLIENT_BUILD 47 | SUBDIRS += po 48 | endif 49 | 50 | tgz: 51 | rm -f $(TARFILE) 52 | hg archive -t tgz $(TARFILE) 53 | echo Rebuilt $(TARFILE) on `date` 54 | 55 | changes: 56 | printf "$(PACKAGE) ($(VERSION)-1) stable; urgency=medium\n" 57 | printf " * Update source tarball to revision: `hg id`\n" 58 | printf " * Statistics:\n" 59 | printf " Changesets: `hg log -M --template "{desc|firstline|strip}\n" -r $(LAST_RELEASE):tip | wc -l`\n" 60 | printf " Diff: " 61 | hg diff -r $(LAST_RELEASE):tip | diffstat | tail -n 1 62 | # printf "\n * Testing Notes:\n" 63 | # printf "\n + Test hardware:\n" 64 | # printf "\n + All testing was performed with STONITH enabled\n" 65 | # printf "\n + Pending bugs encountered during testing:\n" 66 | printf "\n * Changes since $(LAST_RELEASE)\n" 67 | # hg log -M --template " + {desc|firstline|strip}\n" -r $(LAST_RELEASE):tip | grep -v Low: | sort -uf 68 | hg log -M --template " + {desc|firstline|strip}\n" -r $(LAST_RELEASE):tip | sort -uf 69 | printf "\n -- Gao,Yan `date +"%a, %d %b %Y %T %z"`\n" 70 | 71 | OBS_PROJECT = pacemaker-mgmt 72 | OBS_SERVER = c001n16.suse.de 73 | OBS_PREFIX = Development/obs 74 | OBS_FILES = .changes $(TARFILE) 75 | 76 | stable: tgz 77 | make changes > .changes 78 | scp $(OBS_FILES) $(OBS_SERVER):$(OBS_PREFIX)/server:ha-clustering/$(OBS_PROJECT)/ 79 | 80 | unstable: tgz 81 | make changes > .changes 82 | scp $(OBS_FILES) $(OBS_SERVER):$(OBS_PREFIX)/server:ha-clustering:UNSTABLE/$(OBS_PROJECT)/ 83 | 84 | factory: tgz 85 | make changes > .changes 86 | ssh $(OBS_SERVER) -- 'cd $(OBS_PREFIX)/server:ha-clustering:Factory/$(OBS_PROJECT) ; /usr/bin/osc up' 87 | scp $(OBS_FILES) $(OBS_SERVER):$(OBS_PREFIX)/server:ha-clustering:Factory/$(OBS_PROJECT)/ 88 | ssh $(OBS_SERVER) -- "cd $(OBS_PREFIX)/server:ha-clustering:Factory/$(OBS_PROJECT); /usr/bin/osc commit -m \"New $(OBS_PROJECT) snapshot - $(shell $(HG) id)\"" 89 | 90 | install-exec-local: 91 | if MGMT_CLIENT_BUILD 92 | -mkdir -p $(DESTDIR)$(bindir) 93 | -cd $(DESTDIR)$(libdir)/heartbeat-gui && rm -f haclient.py && ln -s $(datadir)/heartbeat-gui/haclient.py . 94 | -cd $(DESTDIR)$(bindir) && rm -f crm_gui && ln -s $(datadir)/heartbeat-gui/haclient.py crm_gui 95 | -cd $(DESTDIR)$(bindir) && rm -f hb_gui && ln -s $(datadir)/heartbeat-gui/haclient.py hb_gui 96 | endif 97 | 98 | dist-clean-local: 99 | rm -f autoconf automake autoheader 100 | 101 | maintainer-clean-local: 102 | rm -f libltdl.tar 103 | 104 | -------------------------------------------------------------------------------- /README.in: -------------------------------------------------------------------------------- 1 | Hi, 2 | 3 | Welcome to the linux-ha project source tree. 4 | 5 | There is a little documentation on setting things up for a HA failover 6 | system in the doc directory. The following things are among the more 7 | interesting docs: 8 | GettingStarted.html HardwareGuide.html 9 | Requirements.html faqntips.html 10 | nice_failback.txt rsync.html 11 | 12 | For building the system: 13 | 14 | If you have no idea what to do, then you should probably use the ConfigureMe 15 | to configure (and make, install, package, etc.) the software. ConfigureMe 16 | makes some educated guesses on how linux-ha ought to be installed by 17 | default on the current system type. 18 | 19 | If you have played with autoconf/automake packages before, then you can use 20 | the bootstrap script, or configure, etc. like normal. 21 | 22 | Due to the way that init directories are handled by heartbeat, 23 | make distcheck can be problematic. The following should allow 24 | this to run successfully, noting that gmake is often available 25 | as make: 26 | 27 | gmake DESTDIR="$PWD/heartbeat-@VERSION@/=inst" distcheck 28 | 29 | For more information on the project, see the web site at linux-ha.org. 30 | Information on joining mailing lists can be found at 31 | http://linux-ha.org/contact/ 32 | 33 | 34 | Enjoy! 35 | 36 | 37 | -- The Linux-Ha development team 38 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl local autoconf/automake macros needed for heartbeat 3 | dnl Started by David Lee February 2006 4 | dnl 5 | dnl License: GNU General Public License (GPL) 6 | 7 | 8 | dnl AM_CHECK_PYTHON_HEADERS: Find location of python include files. 9 | dnl Taken from: 10 | dnl http://source.macgimp.org/ 11 | dnl which is GPL and is attributed to James Henstridge. 12 | dnl 13 | dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) 14 | dnl Imports: 15 | dnl $PYTHON 16 | dnl Exports: 17 | dnl PYTHON_INCLUDES 18 | 19 | AC_DEFUN([AM_CHECK_PYTHON_HEADERS], 20 | [AC_REQUIRE([AM_PATH_PYTHON]) 21 | AC_MSG_CHECKING(for headers required to compile python extensions) 22 | dnl deduce PYTHON_INCLUDES 23 | py_prefix=`$PYTHON -c "import sys; print sys.prefix"` 24 | py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` 25 | PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" 26 | if test "$py_prefix" != "$py_exec_prefix"; then 27 | PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" 28 | fi 29 | AC_SUBST(PYTHON_INCLUDES) 30 | dnl check if the headers exist: 31 | save_CPPFLAGS="$CPPFLAGS" 32 | CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" 33 | AC_TRY_CPP([#include ],dnl 34 | [AC_MSG_RESULT(found) 35 | $1],dnl 36 | [AC_MSG_RESULT(not found) 37 | $2]) 38 | CPPFLAGS="$save_CPPFLAGS" 39 | ]) 40 | -------------------------------------------------------------------------------- /cim/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | Makefile 3 | .deps 4 | .libs 5 | *.la 6 | *.lo 7 | .*.swp 8 | *.beam 9 | -------------------------------------------------------------------------------- /cim/constraint_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * constraint_common.h: common functions for constraint providers 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef _CONSTRAINT_COMMON_H 24 | #define _CONSTRAINT_COMMON_H 25 | 26 | int constraing_get_inst(CMPIBroker * broker, char * classname, 27 | CMPIContext * ctx, CMPIResult * rslt, CMPIObjectPath * cop, 28 | char ** properties, uint32_t type, CMPIStatus * rc); 29 | 30 | int constraint_enum_insts(CMPIBroker * broker, char * classname, 31 | CMPIContext * ctx, CMPIResult * rslt, CMPIObjectPath * cop, 32 | int need_inst, uint32_t type, CMPIStatus * rc); 33 | 34 | int delete_constraint(CMPIBroker * broker, char * classname, 35 | CMPIInstanceMI * mi, CMPIContext * ctx, CMPIResult * rslt, 36 | CMPIObjectPath * cop, uint32_t type, CMPIStatus * rc); 37 | 38 | int constraint_update_inst(CMPIBroker * broker, char * classname, 39 | CMPIInstanceMI * mi, CMPIContext * ctx, CMPIResult * rslt, 40 | CMPIObjectPath * cop, CMPIInstance * ci, char ** properties, 41 | uint32_t type, CMPIStatus * rc); 42 | 43 | int constraint_create_inst(CMPIBroker * broker, char * classname, 44 | CMPIInstanceMI * mi, CMPIContext * ctx, CMPIResult * rslt, 45 | CMPIObjectPath * cop, CMPIInstance * ci, uint32_t type, 46 | CMPIStatus * rc); 47 | 48 | int constraint_delete_inst(CMPIBroker * broker, char * classname, 49 | CMPIInstanceMI * mi, CMPIContext * ctx, CMPIResult * rslt, 50 | CMPIObjectPath * cop, uint32_t type, CMPIStatus * rc); 51 | #endif 52 | -------------------------------------------------------------------------------- /cim/location_constraint_provider.c: -------------------------------------------------------------------------------- 1 | /* 2 | * location_constraint_provider.c: HA_ResourceLocationConstraint provider 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include "cmpi_utils.h" 35 | #include "cluster_info.h" 36 | #include "constraint_common.h" 37 | 38 | static const char * PROVIDER_ID = "constraint"; 39 | static CMPIBroker * Broker = NULL; 40 | static char ClassName [] = "HA_LocationConstraint"; 41 | DeclareInstanceFunctions(LocationConstraint); 42 | 43 | /********************************************** 44 | * Instance provider functions 45 | **********************************************/ 46 | 47 | static CMPIStatus 48 | LocationConstraintCleanup(CMPIInstanceMI * mi, CMPIContext * ctx) 49 | { 50 | CMReturn(CMPI_RC_OK); 51 | } 52 | 53 | static CMPIStatus 54 | LocationConstraintEnumInstanceNames(CMPIInstanceMI * mi, CMPIContext * ctx, 55 | CMPIResult * rslt, CMPIObjectPath * ref) 56 | { 57 | CMPIStatus rc; 58 | PROVIDER_INIT_LOGGER(); 59 | constraint_enum_insts(Broker, ClassName, ctx, rslt, 60 | ref, FALSE, TID_CONS_LOCATION, &rc); 61 | return rc; 62 | } 63 | 64 | 65 | static CMPIStatus 66 | LocationConstraintEnumInstances(CMPIInstanceMI * mi, CMPIContext * ctx, 67 | CMPIResult * rslt, CMPIObjectPath * ref, 68 | char ** properties) 69 | { 70 | CMPIStatus rc; 71 | PROVIDER_INIT_LOGGER(); 72 | constraint_enum_insts(Broker, ClassName, ctx, rslt, 73 | ref, TRUE, TID_CONS_LOCATION, &rc); 74 | return rc; 75 | } 76 | 77 | static CMPIStatus 78 | LocationConstraintGetInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 79 | CMPIResult * rslt, CMPIObjectPath * cop, 80 | char ** properties) 81 | { 82 | CMPIStatus rc = {CMPI_RC_OK, NULL}; 83 | PROVIDER_INIT_LOGGER(); 84 | constraing_get_inst(Broker, ClassName, ctx, rslt, cop, 85 | properties, TID_CONS_LOCATION, &rc); 86 | 87 | return rc; 88 | } 89 | 90 | static CMPIStatus 91 | LocationConstraintCreateInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 92 | CMPIResult * rslt, CMPIObjectPath * cop, 93 | CMPIInstance * ci) 94 | { 95 | CMPIStatus rc = {CMPI_RC_OK, NULL}; 96 | 97 | PROVIDER_INIT_LOGGER(); 98 | constraint_create_inst(Broker, ClassName, mi, ctx, rslt, 99 | cop, ci, TID_CONS_LOCATION, &rc); 100 | return rc; 101 | } 102 | 103 | 104 | static CMPIStatus 105 | LocationConstraintSetInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 106 | CMPIResult * rslt, CMPIObjectPath * cop, 107 | CMPIInstance * ci, char ** properties) 108 | { 109 | CMPIStatus rc = {CMPI_RC_OK, NULL}; 110 | int ret; 111 | 112 | PROVIDER_INIT_LOGGER(); 113 | ret = constraint_update_inst(Broker, ClassName, mi, ctx, rslt, 114 | cop, ci, properties, TID_CONS_LOCATION, &rc); 115 | return rc; 116 | } 117 | 118 | 119 | static CMPIStatus 120 | LocationConstraintDeleteInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 121 | CMPIResult * rslt, CMPIObjectPath * cop) 122 | { 123 | CMPIStatus rc = {CMPI_RC_OK, NULL}; 124 | int ret; 125 | ret = constraint_delete_inst(Broker, ClassName, mi, ctx, 126 | rslt, cop, TID_CONS_LOCATION, &rc); 127 | return rc; 128 | } 129 | 130 | static CMPIStatus 131 | LocationConstraintExecQuery(CMPIInstanceMI * mi, CMPIContext * ctx, 132 | CMPIResult * rslt, CMPIObjectPath * ref, 133 | char * lang, char * query) 134 | { 135 | CMPIStatus rc = {CMPI_RC_OK, NULL}; 136 | CMSetStatusWithChars(Broker, &rc, CMPI_RC_ERR_NOT_SUPPORTED, 137 | "CIM_ERR_NOT_SUPPORTED"); 138 | return rc; 139 | } 140 | 141 | 142 | /***************************************************** 143 | * install provider 144 | ****************************************************/ 145 | DeclareInstanceMI(LocationConstraint, HA_LocationConstraintProvider, Broker); 146 | -------------------------------------------------------------------------------- /cim/mgmt_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mgmt_client.c: mgmt library client 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef _MGMT_CLIENT_H 24 | #define _MGMT_CLIENT_H 25 | 26 | #ifdef HAVE_STDINT_H 27 | #include 28 | #endif /* HAVE_STDINT_H */ 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include "utils.h" 36 | 37 | #define Arg1(a) a, NULL 38 | #define Arg2(a,b) a, b, NULL 39 | #define Arg3(a,b,c) a, b, c, NULL 40 | #define Arg4(a,b,c,d) a, b, c, d, NULL 41 | #define Arg5(a,b,c,d,e) a, b, c, d, e, NULL 42 | #define Arg6(a,b,c,d,e,f) a, b, c, d, e, f, NULL 43 | 44 | #define mclient_makeup_param(a,b) \ 45 | ({ char param[MAXLEN] = ""; \ 46 | strncat(param, a, \ 47 | sizeof(param)-strlen(param)-1); \ 48 | strncat(param, "\n", \ 49 | sizeof(param)-strlen(param)-1); \ 50 | strncat(param, b, \ 51 | sizeof(param)-strlen(param)-1); \ 52 | param; \ 53 | }) 54 | 55 | #define mclient_new_and_process(cmnd, arg...) \ 56 | ({ MClient * client = mclient_new_with_cmnd(cmnd, ##arg); \ 57 | if ( client ){ \ 58 | if ( mclient_process(client) != HA_OK \ 59 | || client->rlen == 0){ \ 60 | mclient_free(client); \ 61 | client = NULL; \ 62 | cl_log(LOG_ERR,"mclient_new_and_process"\ 63 | ":process error."); \ 64 | } \ 65 | } \ 66 | client; \ 67 | }) 68 | 69 | typedef struct mgmt_client { 70 | char * cmnd; /* cmnd */ 71 | char ** rdata; /* result */ 72 | int rlen; /* result length */ 73 | } MClient; 74 | 75 | 76 | #define MC_OK 0 77 | #define MC_FAIL -1 78 | #define MC_ERROR -2 79 | 80 | MClient * mclient_new(void); 81 | MClient * mclient_new_with_cmnd(const char * type, ...); 82 | int mclient_cmnd_new(MClient * client, const char * type, ...); 83 | int mclient_cmnd_append(MClient * client, const char * cmnd); 84 | int mclient_process(MClient * client); 85 | char * mclient_nth_value(MClient * client, uint32_t index); 86 | char * mclient_nth_key(MClient * client, uint32_t index); 87 | void mclient_free(void * client); 88 | 89 | int mgmt_lib_initialize(void); 90 | void mgmt_lib_finalize(void); 91 | #endif 92 | -------------------------------------------------------------------------------- /cim/mof/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | Makefile 3 | .deps 4 | .libs 5 | *.la 6 | *.lo 7 | .*.swp 8 | *.beam 9 | register_providers.sh 10 | unregister_providers.sh 11 | -------------------------------------------------------------------------------- /cim/mof/LinuxHA.reg: -------------------------------------------------------------------------------- 1 | # Classname Namespace ProviderName ProviderModule ProviderTypes ... 2 | # HA Cluster 3 | HA_Cluster root/cimv2 HA_ClusterProvider HA_ClusterProvider instance 4 | # HA Cluster Node 5 | HA_ClusterNode root/cimv2 HA_ClusterNodeProvider HA_ClusterNodeProvider instance 6 | #Primitve Resource 7 | HA_PrimitiveResource root/cimv2 HA_PrimitiveResourceProvider HA_PrimitiveResourceProvider instance 8 | #Resource Group 9 | HA_ResourceGroup root/cimv2 HA_ResourceGroupProvider HA_ResourceGroupProvider instance 10 | # Resource Clone 11 | HA_ResourceClone root/cimv2 HA_ResourceCloneProvider HA_ResourceCloneProvider instance 12 | # Master Slave Clone 13 | HA_MasterSlaveResource root/cimv2 HA_MasterSlaveResourceProvider HA_MasterSlaveResourceProvider instance 14 | # Resource instance 15 | #HA_InstanceAttributes root/cimv2 HA_InstanceAttributesProvider HA_InstanceAttributesProvider instance 16 | # Software 17 | HA_SoftwareIdentity root/cimv2 HA_SoftwareIdentityProvider HA_SoftwareIdentityProvider instance 18 | # LocationConstraint 19 | HA_LocationConstraint root/cimv2 HA_LocationConstraintProvider HA_LocationConstraintProvider instance 20 | # ColocationConstraint 21 | HA_ColocationConstraint root/cimv2 HA_ColocationConstraintProvider HA_ColocationConstraintProvider instance 22 | # OrderConstraint 23 | HA_OrderConstraint root/cimv2 HA_OrderConstraintProvider HA_OrderConstraintProvider instance 24 | # Operation 25 | HA_Operation root/cimv2 HA_OperationProvider HA_OperationProvider instance 26 | # Association, between Cluster and Node 27 | HA_ParticipatingNode root/cimv2 HA_ParticipatingNodeProvider HA_ParticipatingNodeProvider instance association 28 | # Association, between Resource and Hosting Node 29 | HA_HostedResource root/cimv2 HA_HostedResourceProvider HA_HostedResourceProvider instance association 30 | # Association, between Cluster and Software 31 | HA_InstalledSoftwareIdentity root/cimv2 HA_InstalledSoftwareIdentityProvider HA_InstalledSoftwareIdentityProvider instance association 32 | # Association, between Resource and its instance attribute 33 | #HA_ResourceInstance root/cimv2 HA_ResourceInstanceProvider HA_ResourceInstanceProvider instance association 34 | # Association, between Resource (Group/MasterSlave/Clone) and its sub resource 35 | HA_SubResource root/cimv2 HA_SubResourceProvider HA_SubResourceProvider instance association 36 | # Association, operation and resource 37 | HA_OperationOnResource root/cimv2 HA_OperationOnProvider HA_OperationOnProvider instance association 38 | #Indication 39 | HA_Indication root/cimv2 HA_IndicationProvider HA_IndicationProvider indication 40 | HA_ClusteringService root/cimv2 HA_ClusteringServiceProvider HA_ClusteringServiceProvider instance 41 | -------------------------------------------------------------------------------- /cim/mof/Makefile.am: -------------------------------------------------------------------------------- 1 | # Linux-HA: Makefile for register 2 | # 3 | # Author: Jia Ming Pan 4 | # Copyright (c) 2005 International Business Machines 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | # 20 | 21 | MAINTAINERCLEANFILES = Makefile.in 22 | 23 | mof_DATA = LinuxHA.mof LinuxHA.reg 24 | mof_SCRIPTS = register_providers.sh unregister_providers.sh do_register.sh 25 | mofdir = @HA_NOARCHDATAHBDIR@/cim 26 | 27 | DIST_LIST = $(mof_DATA) $(mof_SCRIPTS) 28 | EXTRA_DIST = $(DIST_LIST) 29 | -------------------------------------------------------------------------------- /cim/mof/register_providers.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Linux-HA: CIM Provider register tool 4 | # 5 | # Author: Jia Ming Pan 6 | # Copyright (c) 2005 International Business Machines 7 | # Licensed under the GNU GPL. 8 | # 9 | # 10 | 11 | sh @HA_NOARCHDATAHBDIR@/heartbeat/cim/do_register.sh -t @CIMOM@ \ 12 | -r @HA_NOARCHDATAHBDIR@/heartbeat/cim/LinuxHA.reg \ 13 | -m @HA_NOARCHDATAHBDIR@/heartbeat/cim/LinuxHA.mof 14 | 15 | -------------------------------------------------------------------------------- /cim/mof/unregister_providers.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Linux-HA: CIM Provider register tool 4 | # 5 | # Author: Jia Ming Pan 6 | # Copyright (c) 2005 International Business Machines 7 | # Licensed under the GNU GPL. 8 | # 9 | # 10 | 11 | sh @HA_NOARCHDATAHBDIR@/heartbeat/cim/do_register.sh -u -t @CIMOM@ \ 12 | -r @HA_NOARCHDATAHBDIR@/heartbeat/cim/LinuxHA.reg \ 13 | -m @HA_NOARCHDATAHBDIR@/heartbeat/cim/LinuxHA.mof 14 | 15 | -------------------------------------------------------------------------------- /cim/mof_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mof_map.h: map class properties to msg attributes 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | 24 | #ifndef _MOF_MAP_H 25 | #define _MOF_MAP_H 26 | 27 | typedef struct { 28 | const char * key; 29 | const char * name; 30 | int type; 31 | } map_entry_t; 32 | 33 | struct map_t{ 34 | int id; 35 | int len; 36 | const map_entry_t *entry; 37 | }; 38 | 39 | const struct map_t * cim_query_map(int mapid); 40 | 41 | #define HA_CLUSTER 1 42 | #define HA_CLUSTER_NODE 2 43 | #define HA_PRIMITIVE_RESOURCE 3 44 | #define HA_RESOURCE_CLONE 4 45 | #define HA_MASTERSLAVE_RESOURCE 5 46 | #define HA_OPERATION 6 47 | #define HA_ORDER_CONSTRAINT 7 48 | #define HA_COLOCATION_CONSTRAINT 8 49 | #define HA_LOCATION_CONSTRAINT 9 50 | #define HA_RESOURCE_GROUP 10 51 | #define HA_INSTANCE_ATTRIBUTES 11 52 | #define HA_LOCATION_CONSTRAINT_RULE 12 53 | 54 | #define METHOD_ADD_RESOURCE "AddResource" 55 | #define METHOD_ADD_PRIMITIVE_RESOURCE "AddPrimitiveResource" 56 | 57 | 58 | #define CLASS_HA_CLUSTER "HA_Cluster" 59 | #define CLASS_HA_CLUSTER_NODE "HA_ClusterNode" 60 | #define CLASS_HA_CLUSTER_RESOURCE "HA_ClusterResource" 61 | 62 | #define CLASS_HA_SOFTWARE_IDENTITY "HA_SoftwareIdentity" 63 | #define CLASS_HA_INSTALLED_SOFTWARE_IDENTITY "HA_InstalledSoftwareIdentity" 64 | #define CLASS_HA_PRIMITIVE_RESOURCE "HA_PrimitiveResource" 65 | #define CLASS_HA_RESOURCE_GROUP "HA_ResourceGroup" 66 | #define CLASS_HA_RESOURCE_CLONE "HA_ResourceClone" 67 | #define CLASS_HA_MSTERSLAVE_RESOURCE "HA_MasterSlaveResource" 68 | #define CLASS_HA_INSTANCE_ATTRIBUTES "HA_InstanceAttributes" 69 | #define CLASS_HA_ATTRIBUTES_OF_RESOURCE "HA_AttributesOfResource" 70 | #define CLASS_HA_OPERATION "HA_Operation" 71 | #define CLASS_HA_OPERATION_ON_RESOURCE "HA_OperationOnResource" 72 | #define CLASS_HA_RESOURCE_CONSTRAINT "HA_ResourceConstraint" 73 | #define CLASS_HA_ORDER_CONSTRAINT "HA_OrderConstraint" 74 | #define CLASS_HA_COLOCATION_CONSTRAINT "HA_ColocationConstraint" 75 | #define CLASS_HA_LOCATION_CONSTRAINT "HA_LocationConstraint" 76 | 77 | #define CLASS_HA_SUBRESOURCE "HA_SubResource" 78 | #define CLASS_HA_PARTICIPATING_NODE "HA_ParticipatingNode" 79 | #define CLASS_HA_HOSTED_RESOURCE "HA_HostedResource" 80 | #define CLASS_HA_INDICATION "HA_Indication" 81 | #define CLASS_HA_CLUSTERING_SERVICE "HA_ClusteringService" 82 | 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /cim/order_constraint_provider.c: -------------------------------------------------------------------------------- 1 | /* 2 | * order_constraint_provider.c: HA_ResourceOrderConstraint provider 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include "cmpi_utils.h" 35 | #include "cluster_info.h" 36 | #include "constraint_common.h" 37 | 38 | static const char * PROVIDER_ID = "cim-op"; 39 | static CMPIBroker * Broker = NULL; 40 | static char ClassName [] = "HA_OrderConstraint"; 41 | DeclareInstanceFunctions(OrderConstraint); 42 | 43 | static CMPIStatus 44 | OrderConstraintCleanup(CMPIInstanceMI * mi, CMPIContext * ctx) 45 | { 46 | CMReturn(CMPI_RC_OK); 47 | } 48 | 49 | static CMPIStatus 50 | OrderConstraintEnumInstanceNames(CMPIInstanceMI * mi, CMPIContext * ctx, 51 | CMPIResult * rslt, CMPIObjectPath * ref) 52 | { 53 | CMPIStatus rc; 54 | 55 | PROVIDER_INIT_LOGGER(); 56 | constraint_enum_insts(Broker, ClassName, ctx, rslt, ref, 57 | FALSE, TID_CONS_ORDER, &rc); 58 | return rc; 59 | } 60 | 61 | 62 | static CMPIStatus 63 | OrderConstraintEnumInstances(CMPIInstanceMI * mi, CMPIContext * ctx, 64 | CMPIResult * rslt, CMPIObjectPath * ref, 65 | char ** properties) 66 | { 67 | CMPIStatus rc; 68 | 69 | PROVIDER_INIT_LOGGER(); 70 | constraint_enum_insts(Broker, ClassName, ctx, rslt, ref, 71 | TRUE, TID_CONS_ORDER, &rc); 72 | return rc; 73 | } 74 | 75 | static CMPIStatus 76 | OrderConstraintGetInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 77 | CMPIResult * rslt, CMPIObjectPath * cop, 78 | char ** properties) 79 | { 80 | CMPIStatus rc; 81 | 82 | PROVIDER_INIT_LOGGER(); 83 | constraing_get_inst(Broker, ClassName, ctx, rslt, cop, 84 | properties, TID_CONS_ORDER, &rc); 85 | return rc; 86 | } 87 | 88 | static CMPIStatus 89 | OrderConstraintCreateInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 90 | CMPIResult * rslt, CMPIObjectPath * cop, 91 | CMPIInstance * ci) 92 | { 93 | CMPIStatus rc = {CMPI_RC_OK, NULL}; 94 | 95 | PROVIDER_INIT_LOGGER(); 96 | constraint_create_inst(Broker, ClassName, mi, ctx, rslt, 97 | cop, ci, TID_CONS_ORDER, &rc); 98 | return rc; 99 | } 100 | 101 | 102 | static CMPIStatus 103 | OrderConstraintSetInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 104 | CMPIResult * rslt, CMPIObjectPath * cop, 105 | CMPIInstance * ci, char ** properties) 106 | { 107 | CMPIStatus rc = {CMPI_RC_OK, NULL}; 108 | 109 | PROVIDER_INIT_LOGGER(); 110 | constraint_update_inst(Broker, ClassName, mi, ctx, rslt, 111 | cop, ci, properties, TID_CONS_ORDER, &rc); 112 | return rc; 113 | } 114 | 115 | 116 | static CMPIStatus 117 | OrderConstraintDeleteInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 118 | CMPIResult * rslt, CMPIObjectPath * cop) 119 | { 120 | CMPIStatus rc = {CMPI_RC_OK, NULL}; 121 | constraint_delete_inst(Broker, ClassName, mi, ctx, 122 | rslt, cop, TID_CONS_ORDER, &rc); 123 | return rc; 124 | } 125 | 126 | static CMPIStatus 127 | OrderConstraintExecQuery(CMPIInstanceMI * mi, CMPIContext * ctx, 128 | CMPIResult * rslt, CMPIObjectPath * ref, 129 | char * lang, char * query) 130 | { 131 | CMPIStatus rc = {CMPI_RC_OK, NULL}; 132 | CMSetStatusWithChars(Broker, &rc, CMPI_RC_ERR_NOT_SUPPORTED, 133 | "CIM_ERR_NOT_SUPPORTED"); 134 | return rc; 135 | } 136 | 137 | /***************************************************** 138 | * install provider 139 | ****************************************************/ 140 | 141 | DeclareInstanceMI(OrderConstraint, HA_OrderConstraintProvider, Broker); 142 | -------------------------------------------------------------------------------- /cim/resource_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * resource_common.h: common functions for resource providers 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef _RESROUCE_COMMON_H 24 | #define _RESOURCE_COMMON_H 25 | 26 | 27 | /* get a resource instance */ 28 | int resource_get_inst(CMPIBroker * broker, char * classname, CMPIContext * ctx, 29 | CMPIResult * rslt, CMPIObjectPath * ref, 30 | char ** properties, uint32_t type, CMPIStatus * rc); 31 | 32 | /* enumerate instances or instance names */ 33 | int resource_enum_insts(CMPIBroker* broker, char* classname, CMPIContext* ctx, 34 | CMPIResult * rslt, CMPIObjectPath * ref, int need_inst, 35 | uint32_t type, CMPIStatus * rc); 36 | 37 | /* cleanup provider */ 38 | int resource_cleanup(CMPIBroker* broker, char* classname, CMPIInstanceMI* mi, 39 | CMPIContext * ctx, uint32_t type, CMPIStatus * rc); 40 | 41 | /* delete resource */ 42 | int resource_del_inst(CMPIBroker* broker, char* classname, CMPIContext* ctx, 43 | CMPIResult * rslt, CMPIObjectPath * ref, CMPIStatus * rc); 44 | 45 | /* update resource */ 46 | int resource_update_inst(CMPIBroker* broker, char* classname, CMPIContext* ctx, 47 | CMPIResult * rslt, CMPIObjectPath * cop, CMPIInstance * ci, 48 | char ** properties, uint32_t type, CMPIStatus * rc); 49 | 50 | /* create a resource */ 51 | int resource_create_inst(CMPIBroker* broker, char* classname, CMPIContext* ctx, 52 | CMPIResult * rslt, CMPIObjectPath * cop, CMPIInstance * ci, 53 | uint32_t type, CMPIStatus * rc); 54 | 55 | #if 0 56 | /* add a operation to resource */ 57 | int resource_add_operation(CMPIBroker* broker, char*classname, CMPIContext* ctx, 58 | CMPIResult * rslt, CMPIObjectPath * ref, uint32_t type, 59 | CMPIArgs *in, CMPIArgs *out, CMPIStatus * rc); 60 | #endif 61 | 62 | /* add sub resource to group/clone/master-slave */ 63 | int resource_add_subrsc(CMPIBroker* broker, char* classname, CMPIContext* ctx, 64 | CMPIResult * rslt, CMPIObjectPath * ref, uint32_t type, 65 | CMPIArgs *in, CMPIArgs *out, CMPIStatus * rc); 66 | #endif 67 | -------------------------------------------------------------------------------- /cim/simple_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tests 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "cluster_info.h" 31 | #include 32 | #include 33 | #include 34 | #include "utils.h" 35 | #include "cluster_info.h" 36 | #include "mgmt_client.h" 37 | 38 | int main(int argc, char * argv[]) 39 | { 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /cim/tests/CreateFilter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | CIM_UnitaryComputerSystem 14 | 15 | 16 | hadev4 17 | 18 | 19 | CIM_IndicationFilter 20 | 21 | 22 | Filter01 23 | 24 | 25 | SELECT * FROM LinuxHA_Indication 26 | 27 | 28 | WQL 29 | 30 | 31 | root/cimv2 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /cim/tests/CreateHandler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | CIM_UnitaryComputerSystem 14 | 15 | 16 | hadev4 17 | 18 | 19 | CIM_ListenerDestinationCIMXML 20 | 21 | 22 | Handler01 23 | 24 | 25 | file://linuxha_indication.log 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /cim/tests/CreateSubscription.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | CIM_UnitaryComputerSystem 19 | 20 | 21 | 22 | 23 | hadev4 24 | 25 | 26 | 27 | 28 | CIM_IndicationFilter 29 | 30 | 31 | 32 | 33 | Filter01 34 | 35 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 45 | CIM_UnitaryComputerSystem 46 | 47 | 48 | 49 | 50 | hadev4 51 | 52 | 53 | 54 | 55 | CIM_ListenerDestinationCIMXML 56 | 57 | 58 | 59 | 60 | Handler01 61 | 62 | 63 | 64 | 65 | 66 | 67 | 2 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /cim/tests/DeleteFilter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | CIM_UnitaryComputerSystem 15 | 16 | 17 | 18 | 19 | hadev4 20 | 21 | 22 | 23 | 24 | CIM_IndicationFilter 25 | 26 | 27 | 28 | 29 | Filter01 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /cim/tests/DeleteHandler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | CIM_UnitaryComputerSystem 15 | 16 | 17 | 18 | 19 | hadev4 20 | 21 | 22 | 23 | 24 | CIM_ListenerDestinationCIMXML 25 | 26 | 27 | 28 | 29 | Handler01 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /cim/tests/DeleteSubscription.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CIM_IndicationFilter 18 | 19 | 20 | 21 | 22 | Filter01 23 | 24 | 25 | 26 | 27 | CIM_UnitaryComputerSystem 28 | 29 | 30 | 31 | 32 | hadev4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | CIM_ListenerDestinationCIMXML 44 | 45 | 46 | 47 | 48 | Handler01 49 | 50 | 51 | 52 | 53 | CIM_UnitaryComputerSystem 54 | 55 | 56 | 57 | 58 | hadev4 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /cim/tests/subscription.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TMP=`mktemp` 4 | 5 | WBEMCAT=`which wbemcat` 6 | 7 | if test $? != 0; then 8 | echo wbemcat not found! 9 | exit 10 | fi 11 | 12 | wbemcat CreateFilter.xml > $TMP 13 | wbemcat CreateHandler.xml > $TMP 14 | wbemcat CreateSubscription.xml > $TMP 15 | echo 16 | echo Create subscription, 17 | echo Press any key to terminate ... 18 | read 19 | wbemcat DeleteFilter.xml > $TMP 20 | wbemcat DeleteSubscription.xml > $TMP 21 | wbemcat DeleteHandler.xml > $TMP 22 | 23 | rm -rf $TMP 24 | -------------------------------------------------------------------------------- /cim/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utils.h: utilities header 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | 24 | #ifndef _UTILS_H 25 | #define _UTILS_H 26 | #ifdef HAVE_STDINT_H 27 | #include 28 | #endif /* HAVE_STDINT_H */ 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #define MAXLEN 1024 35 | 36 | /* memory routines */ 37 | #define cim_malloc malloc 38 | #define cim_free free 39 | #define cim_strdup strdup 40 | #define cim_realloc realloc 41 | 42 | typedef void (* cim_free_t)(void *); 43 | 44 | /* for debuging */ 45 | #define DEBUG_ENTER() cl_log(LOG_INFO, "%s: --- ENTER ---", __FUNCTION__) 46 | #define DEBUG_LEAVE() cl_log(LOG_INFO, "%s: --- LEAVE ---", __FUNCTION__) 47 | 48 | #ifndef ASSERT 49 | #ifdef HAVE_STRINGIZE 50 | # define ASSERT(X) {if(!(X)) cim_assert(#X, __LINE__, __FILE__);} 51 | #else 52 | # define ASSERT(X) {if(!(X)) cim_assert("X", __LINE__, __FILE__);} 53 | #endif 54 | #endif 55 | 56 | extern int debug_level; 57 | #define cim_debug2(prio, fmt...) \ 58 | do { \ 59 | if(debug_level > 2){ \ 60 | cl_log(prio, ##fmt); \ 61 | } \ 62 | }while(0) 63 | 64 | #define PROVIDER_INIT_LOGGER() cim_init_logger(PROVIDER_ID) 65 | #define cim_debug_msg(msg, fmt...) \ 66 | do { \ 67 | cl_log(LOG_INFO, ##fmt); \ 68 | cl_log(LOG_INFO, "%s", msg2string(msg));\ 69 | }while (0) 70 | 71 | 72 | int cim_init_logger(const char* entity); 73 | void cim_assert(const char* assertion, int line, const char* file); 74 | int run_shell_cmnd(const char* cmnd,int* ret,char*** out,char***); 75 | char** regex_search(const char * reg, const char * str, int * len); 76 | void free_2d_array(void *array, int len, cim_free_t free); 77 | void free_2d_zarray(void *zarray, cim_free_t free); 78 | char* uuid_to_str(const cl_uuid_t * uuid); 79 | char** split_string(const char *string, int *len, const char *delim); 80 | 81 | 82 | #define cim_dbget_msg(pathname, key) ({ \ 83 | struct ha_msg *msg = NULL; \ 84 | char *value = cim_dbget(pathname, key); \ 85 | if (value) { \ 86 | msg = string2msg(value, strlen(value)); \ 87 | cim_free(value); \ 88 | } \ 89 | msg; \ 90 | }) 91 | 92 | #define cim_dbput_msg(pathname,key,msg) \ 93 | cim_dbput(pathname, key, msg?msg2string(msg):NULL) 94 | 95 | struct ha_msg* cim_disk2msg(const char *objpathname); 96 | int cim_msg2disk(const char *objpathname, struct ha_msg *); 97 | int cim_disk_msg_del(const char *objpathname); 98 | 99 | char* cim_dbget(const char *pathname, const char*key); 100 | int cim_dbput(const char *pathname, const char*key, const char*value); 101 | int cim_dbdel(const char *pathname, const char*key); 102 | struct ha_msg* cim_dbkeys(const char *pathname); 103 | 104 | 105 | int cim_list_find(struct ha_msg *list, const char *value); 106 | #define cim_list_length(msg) cl_msg_list_length(msg, CIM_MSG_LIST) 107 | #define cim_list_index(msg,index) \ 108 | ((char *)cl_msg_list_nth_data(msg, CIM_MSG_LIST, index)) 109 | 110 | #define cim_list_add(msg, value) \ 111 | cl_msg_list_add_string(msg, CIM_MSG_LIST, value) 112 | 113 | #define cim_msg_add_child(parent,id, child) \ 114 | ha_msg_addstruct(parent, id, child) 115 | #define cim_msg_find_child(parent, id) cl_get_struct(parent,id) 116 | #define cim_msg_remove_child(parent, id) cl_msg_remove(parent,id) 117 | 118 | int cim_msg_children_count(struct ha_msg *parent); 119 | const char * cim_msg_child_name(struct ha_msg * parent, int index); 120 | struct ha_msg * cim_msg_child_index(struct ha_msg *parent, int index); 121 | 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /debian/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # linux-ha: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2001 Michael Moerz 5 | # This instance created by Horms 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | # 21 | MAINTAINERCLEANFILES = Makefile.in 22 | 23 | EXTRA_DIST = apply changelog compat control copyright \ 24 | dpkg-checkbuild rules \ 25 | pacemaker-mgmt.install pacemaker-mgmt.dirs \ 26 | pacemaker-mgmt-client.install pacemaker-mgmt-client.dirs \ 27 | pacemaker-mgmt-dev.install pacemaker-mgmt-dev.dirs 28 | 29 | clean-local: 30 | rm -f *.substvars *.debhelper files 31 | rm -r -f pacemaker-mgmt pacemaker-mgmt-client pacemaker-mgmt-dev tmp 32 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: pacemaker-mgmt 2 | Section: admin 3 | Priority: optional 4 | Maintainer: Gao,Yan 5 | Build-Depends: debhelper (>= 5.0.37.2), libsnmp10-dev | libsnmp-dev, libglib2.0-dev, net-tools, python, libtool, libcurl4-openssl-dev | libcurl3-openssl-dev, libxml2-dev, bison, flex, uuid-dev, lynx, libbz2-dev, zlib1g-dev, uuid-dev, libltdl3-dev, swig, openssh-client, libgnutls-dev, python-central (>= 0.5), python-dev, libpam0g-dev, libncurses5-dev, pacemaker-dev, heartbeat-dev, intltool 6 | Standards-Version: 3.7.3 7 | XS-Python-Version: current 8 | 9 | Package: pacemaker-mgmt 10 | Section: admin 11 | Priority: optional 12 | Architecture: any 13 | Conflicts: pacemaker-pygui 14 | Replaces: pacemaker-pygui 15 | Depends: pacemaker, heartbeat (>= 2.99), snmpd, libxml2-utils, libpam-runtime (>= 0.76-14), findutils 16 | XB-Python-Version: ${python:Versions} 17 | Description: Pacemaker Management Tools 18 | A client/server GUI and a SNMP subagent for configuring, managing and monitoring 19 | the Pacemaker High-Availability cluster resource manager 20 | 21 | Package: pacemaker-mgmt-client 22 | Section: admin 23 | Priority: optional 24 | Architecture: any 25 | Conflicts: pacemaker-pygui 26 | Replaces: pacemaker-pygui 27 | Depends: ${python:Depends}, python-xml, python-gtk2, python-lxml, libgv-python 28 | XB-Python-Version: ${python:Versions} 29 | Description: Pacemaker Management Tools 30 | A client/server GUI and a SNMP subagent for configuring, managing and monitoring 31 | the Pacemaker High-Availability cluster resource manager 32 | . 33 | This package contains the front-end of GUI 34 | 35 | Package: pacemaker-mgmt-dev 36 | Section: devel 37 | Priority: optional 38 | Architecture: any 39 | Conflicts: pacemaker-pygui-dev 40 | Replaces: pacemaker-pygui-dev 41 | Depends: pacemaker-mgmt (= ${binary:Version}) 42 | XB-Python-Version: ${python:Versions} 43 | Description: Pacemaker Management Tools 44 | A client/server GUI and a SNMP subagent for configuring, managing and monitoring 45 | the Pacemaker High-Availability cluster resource manager 46 | . 47 | This package contains development files 48 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/debian/copyright -------------------------------------------------------------------------------- /debian/pacemaker-mgmt-client.dirs: -------------------------------------------------------------------------------- 1 | usr/bin 2 | usr/lib/heartbeat-gui 3 | usr/share/heartbeat-gui 4 | usr/share/applications 5 | usr/share/locale 6 | -------------------------------------------------------------------------------- /debian/pacemaker-mgmt-client.install: -------------------------------------------------------------------------------- 1 | usr/bin/crm_gui 2 | usr/bin/hb_gui 3 | usr/lib/heartbeat-gui 4 | usr/lib/heartbeat-gui/_pymgmt.so* 5 | usr/lib/heartbeat-gui/haclient.py 6 | usr/lib/heartbeat-gui/pymgmt.py 7 | usr/share/applications/crm_gui.desktop 8 | usr/share/heartbeat-gui 9 | usr/share/heartbeat-gui/*.png 10 | usr/share/heartbeat-gui/haclient.py 11 | usr/share/heartbeat-gui/mgmtcmd.py 12 | usr/share/locale/zh_CN/LC_MESSAGES/haclient.mo 13 | usr/share/locale/ja/LC_MESSAGES/haclient.mo 14 | -------------------------------------------------------------------------------- /debian/pacemaker-mgmt-dev.dirs: -------------------------------------------------------------------------------- 1 | usr/include/heartbeat 2 | usr/include/heartbeat/mgmt 3 | usr/lib 4 | -------------------------------------------------------------------------------- /debian/pacemaker-mgmt-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/heartbeat/mgmt 2 | usr/include/heartbeat/mgmt/mgmt_client.h 3 | usr/include/heartbeat/mgmt/mgmt_common.h 4 | usr/include/heartbeat/mgmt/mgmt.h 5 | usr/include/heartbeat/mgmt/mgmt_tls.h 6 | usr/include/heartbeat/mgmt_config.h 7 | usr/lib/libhbmgmt.so 8 | usr/lib/libhbmgmttls.so 9 | usr/lib/libhbmgmtcommon.so 10 | usr/lib/libhbmgmtclient.so 11 | -------------------------------------------------------------------------------- /debian/pacemaker-mgmt.dirs: -------------------------------------------------------------------------------- 1 | etc/pam.d 2 | usr/lib 3 | usr/lib/heartbeat 4 | usr/share/heartbeat 5 | usr/share/snmp/mibs 6 | usr/share/doc/pacemaker-mgmt 7 | -------------------------------------------------------------------------------- /debian/pacemaker-mgmt.files: -------------------------------------------------------------------------------- 1 | /etc/pam.d/hbmgmtd 2 | usr/lib/libhbmgmtclient.so.0.0.0 3 | usr/lib/libhbmgmt.so.0 4 | usr/lib/libhbmgmt.so.0.0.0 5 | usr/lib/libhbmgmtcommon.so.0.0.0 6 | usr/lib/libhbmgmttls.so.0.0.0 7 | usr/lib/libhbmgmttls.so.0 8 | usr/lib/libhbmgmtcommon.so.0 9 | usr/lib/libhbmgmtclient.so.0 10 | usr/lib/heartbeat/mgmtd 11 | usr/lib/heartbeat/mgmtdtest 12 | usr/lib/heartbeat/hbagent 13 | usr/lib/heartbeat/SNMPAgentSanityCheck 14 | usr/share/snmp/mibs/LINUX-HA-MIB.txt 15 | usr/share/doc/pacemaker-mgmt/README.hbagent 16 | usr/share/doc/pacemaker-mgmt/README.hbagentv2 17 | usr/bin/crm_gui 18 | usr/bin/hb_gui 19 | usr/lib/heartbeat-gui/_pymgmt.so.0 20 | usr/lib/heartbeat-gui/_pymgmt.so.0.0.0 21 | usr/lib/heartbeat-gui/haclient.py 22 | usr/lib/heartbeat-gui/pymgmt.py 23 | usr/share/heartbeat-gui/active-node.png 24 | usr/share/heartbeat-gui/add-resource.png 25 | usr/share/heartbeat-gui/cleanup-resource.png 26 | usr/share/heartbeat-gui/default-resource.png 27 | usr/share/heartbeat-gui/down-resource.png 28 | usr/share/heartbeat-gui/exit.png 29 | usr/share/heartbeat-gui/ha.png 30 | usr/share/heartbeat-gui/haclient.py 31 | usr/share/heartbeat-gui/login.png 32 | usr/share/heartbeat-gui/logout.png 33 | usr/share/heartbeat-gui/master-resource.png 34 | usr/share/heartbeat-gui/mgmtcmd.py 35 | usr/share/heartbeat-gui/remove-resource.png 36 | usr/share/heartbeat-gui/slave-resource.png 37 | usr/share/heartbeat-gui/standby-node.png 38 | usr/share/heartbeat-gui/start-resource.png 39 | usr/share/heartbeat-gui/stop-resource.png 40 | usr/share/heartbeat-gui/up-resource.png 41 | usr/share/heartbeat-gui/manage-resource.png 42 | usr/share/heartbeat-gui/unmanage-resource.png 43 | usr/share/heartbeat-gui/dirty-stopped.png 44 | usr/share/heartbeat-gui/failed.png 45 | usr/share/heartbeat-gui/running.png 46 | usr/share/heartbeat-gui/stopped.png 47 | usr/share/heartbeat-gui/starting.png 48 | usr/share/heartbeat-gui/stopping.png 49 | usr/share/heartbeat-gui/nodes.png 50 | usr/share/heartbeat-gui/node.png 51 | usr/share/heartbeat-gui/administration.png 52 | usr/share/heartbeat-gui/record-pending.png 53 | usr/share/locale/zh_CN/LC_MESSAGES/haclient.mo 54 | usr/include/heartbeat/mgmt/mgmt_client.h 55 | usr/include/heartbeat/mgmt/mgmt_common.h 56 | usr/include/heartbeat/mgmt/mgmt.h 57 | usr/include/heartbeat/mgmt/mgmt_tls.h 58 | usr/include/heartbeat/mgmt_config.h 59 | usr/lib/libhbmgmt.so 60 | usr/lib/libhbmgmttls.so 61 | usr/lib/libhbmgmtcommon.so 62 | usr/lib/libhbmgmtclient.so 63 | usr/lib/heartbeat-gui/_pymgmt.so 64 | -------------------------------------------------------------------------------- /debian/pacemaker-mgmt.install: -------------------------------------------------------------------------------- 1 | etc/pam.d/hbmgmtd 2 | usr/lib/libhbmgmt.so.* 3 | usr/lib/libhbmgmtclient.so.* 4 | usr/lib/libhbmgmtcommon.so.* 5 | usr/lib/libhbmgmttls.so.* 6 | usr/lib/heartbeat/mgmtd 7 | usr/lib/heartbeat/mgmtdtest 8 | usr/lib/heartbeat/hbagent 9 | usr/lib/heartbeat/SNMPAgentSanityCheck 10 | usr/share/snmp/mibs/LINUX-HA-MIB.txt 11 | usr/share/doc/pacemaker-mgmt 12 | usr/share/doc/pacemaker-mgmt/README.hbagent 13 | usr/share/doc/pacemaker-mgmt/README.hbagentv2 14 | -------------------------------------------------------------------------------- /debian/pycompat: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # Sample debian/rules that uses debhelper. 3 | # Copyright 1997 to 1999 by Joey Hess. 4 | # License: GNU General Public License (GPL) 5 | 6 | #Thanks to Paolo Molaro and heartbeat_0.4.6-2.diff 7 | 8 | # Uncomment this to turn on verbose mode. 9 | #export DH_VERBOSE=1 10 | 11 | cfg:=--prefix=/usr --libdir=/usr/lib --sysconfdir=/etc --localstatedir=/var \ 12 | --enable-snmp-subagent --with-mibsdir=/usr/share/snmp/mibs \ 13 | --disable-fatal-warnings --enable-glib-malloc \ 14 | --mandir=/usr/share/man 15 | 16 | # These are used for cross-compiling and for saving the configure script 17 | # from having to guess our platform (since we know it already) 18 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) 19 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) 20 | 21 | CFLAGS = -Wall -g 22 | ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) 23 | CFLAGS += -O0 24 | else 25 | CFLAGS += -O2 26 | endif 27 | ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) 28 | INSTALL_PROGRAM += -s 29 | endif 30 | 31 | DTMP:=`pwd`/debian/tmp 32 | RELEASE := $(shell dpkg-parsechangelog | awk '/^Version: / { print $$2 }') 33 | UPSTREAM := $(shell echo "$(RELEASE)" | sed 's/:\?\([0-9\.]\+\)-[0-9].*/\1/') 34 | 35 | patch: 36 | override_version=$(RELEASE) sh debian/apply 37 | 38 | unpatch: 39 | override_version=$(RELEASE) sh debian/apply $(UPSTREAM) 40 | 41 | 42 | build: checkbuild build-stamp 43 | build-stamp: 44 | dh_testdir 45 | # Allow debian packages to also be built directly from Hg archives 46 | # Official debian packages are built from dist tarballs 47 | test ! -e ./configure || ./configure $(cfg) 48 | test -e ./configure || ./bootstrap $(cfg) 49 | $(MAKE) 50 | touch build-stamp 51 | 52 | clean: 53 | dh_testdir 54 | dh_testroot 55 | # Add here commands to clean up after the build process. 56 | -$(MAKE) clean MAKE=make 57 | -$(MAKE) distclean MAKE=make 58 | rm -f tools/ccdv 59 | -find . -name '*.py[co]' | xargs rm -f 60 | dh_clean build-stamp install-stamp 61 | rm -f debian/init debian/*.debhelper debian/*.substvars config.log 62 | rm -r -f debian/pacemaker-mgmt debian/pacemaker-mgmt-client \ 63 | debian/pacemaker-mgmt-dev debian/tmp 64 | 65 | # Zero autoconf foo 66 | rm -f config.status libltdl/config.log libltdl/config.status 67 | 68 | 69 | install: build install-stamp 70 | install-stamp: 71 | dh_testdir 72 | dh_testroot 73 | dh_clean -k 74 | 75 | $(MAKE) install DESTDIR=$(DTMP) \ 76 | MAKE=make \ 77 | docdir=/usr/share/doc/pacemaker-mgmt 78 | 79 | dh_installdirs 80 | dh_install --source=$(DTMP) --list-missing 81 | #dh_movefiles --source=debian/tmp 82 | 83 | binary-indep: build install 84 | 85 | binary-arch: build install 86 | dh_testdir -a 87 | dh_testroot -a 88 | dh_installdebconf -a 89 | dh_installdocs -a 90 | dh_installexamples -a 91 | # dh_installmenu -a 92 | # dh_installemacsen -a 93 | # dh_installpam -a 94 | dh_installinit -a -n -u 'defaults 20 32' 95 | # dh_installcron -a 96 | dh_installman -a 97 | # dh_installinfo -a 98 | # dh_undocumented -a 99 | dh_installchangelogs 100 | dh_link -a 101 | dh_strip -a 102 | dh_compress -a 103 | dh_fixperms -a --exclude usr/bin/cl_status 104 | # dh_suidregister -a 105 | dh_makeshlibs -a -V 106 | dh_installdeb -a 107 | dh_perl -a 108 | dh_pycentral -a 109 | dh_shlibdeps -a 110 | dh_gencontrol -a 111 | dh_md5sums -a 112 | dh_builddeb -a 113 | 114 | binary: binary-indep binary-arch 115 | @echo "All unpackaged files follow:" 116 | -cd $(DTMP) && find . \! -type d | egrep -v \\\.l?a 117 | 118 | checkbuild: 119 | chmod u+x ./debian/dpkg-checkbuild 120 | ./debian/dpkg-checkbuild debian/control 121 | 122 | .PHONY: build clean binary binary-indep binary-arch install checkbuild \ 123 | patch unpatch 124 | -------------------------------------------------------------------------------- /doc/AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/doc/AUTHORS -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # doc: Pacemaker-mgmt code 3 | # 4 | # Copyright (C) 2009 Gao,Yan 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | # 20 | MAINTAINERCLEANFILES = Makefile.in 21 | 22 | docdir = $(datadir)/doc/packages/@PACKAGE@ 23 | 24 | doc_DATA = AUTHORS COPYING COPYING.LGPL 25 | 26 | EXTRA_DIST = $(doc_DATA) 27 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # linux-ha: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2001 Michael Moerz 5 | # This instance created by Horms 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | # 21 | 22 | MAINTAINERCLEANFILES = Makefile.in ha_version.h config.h.in 23 | 24 | EXTRA_DIST = ha_version.h 25 | 26 | topdir=$(includedir)/heartbeat 27 | 28 | noinst_HEADERS = config.h pygui_internal.h ha_version.h portability.h 29 | top_HEADERS = mgmt_config.h 30 | 31 | SUBDIRS = mgmt 32 | 33 | ## The backtick commands are not executed here, 34 | ## but rather as macro-expansions at use within the rules. 35 | HG_LIVE_VERSION=`$(HG) -R "$(top_srcdir)" id` 36 | ARCHIVE_VERSION="$(top_srcdir)/.hg_archival.txt" 37 | HG_TAR_VERSION=`$(EGREP) node: "$(ARCHIVE_VERSION)"` 38 | 39 | ha_version.h: $(ARCHIVE_VERSION) 40 | if [ -r ha_version.h -a ! -w ha_version.h ]; then \ 41 | hgv=""; \ 42 | echo "Saved Version"; \ 43 | elif [ -f $(ARCHIVE_VERSION) ]; then \ 44 | hgv="$(HG_TAR_VERSION)"; \ 45 | echo "Hg Archived Version: $${hgv}"; \ 46 | elif [ -x $(HG) -a -d $(top_srcdir)/.hg ]; then \ 47 | hgv="$(HG_LIVE_VERSION)"; \ 48 | echo "Hg Live Version: $${hgv}"; \ 49 | elif [ -r ha_version.h ]; then \ 50 | hgv=""; \ 51 | echo "Hg Saved Live Version"; \ 52 | cat ha_version.h; \ 53 | else \ 54 | hgv="Unknown"; \ 55 | echo "Unknown Hg Version"; \ 56 | fi ; \ 57 | if [ X"$${hgv}" != "X" ]; then \ 58 | echo "/* $${hgv} */" > ha_version.h; \ 59 | echo "#define HA_HG_VERSION \"$${hgv}\"" >> ha_version.h; \ 60 | fi 61 | 62 | .PHONY: $(ARCHIVE_VERSION) 63 | -------------------------------------------------------------------------------- /include/mgmt/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | -------------------------------------------------------------------------------- /include/mgmt/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2004 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in 20 | 21 | mgmtdir=$(includedir)/heartbeat/mgmt 22 | 23 | mgmt_HEADERS = \ 24 | mgmt_client.h \ 25 | mgmt_common.h \ 26 | mgmt.h \ 27 | mgmt_tls.h 28 | -------------------------------------------------------------------------------- /include/mgmt/mgmt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * API of management library. 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (C) 2005 International Business Machines 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | #ifndef __MGMT_H 24 | #define __MGMT_H 1 25 | 26 | #include 27 | 28 | #define ENABLE_HB 1 29 | #define ENABLE_LRM 2 30 | #define ENABLE_CRM 4 31 | #define CACHE_CIB 8 32 | 33 | extern int init_mgmt_lib(const char* client_name, int enable_components); 34 | extern int final_mgmt_lib(void); 35 | typedef int (*event_handler)(const char* event); 36 | extern char* process_msg(const char* msg); 37 | extern int reg_event(const char* type, event_handler func); 38 | 39 | #endif /* __MGMT_H */ 40 | -------------------------------------------------------------------------------- /include/mgmt/mgmt_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Client-side Linux HA manager API. 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (C) 2005 International Business Machines 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | #ifndef __MGMT_CLIENT_H 24 | #define __MGMT_CLIENT_H 1 25 | #include 26 | /*************************USER GUIDE*****************************************/ 27 | 28 | /* 29 | * daemon = management daemon 30 | 1. using mgmt_connect() to connect to the server running the daemon 31 | after connect, we should send MSG_LOGIN to daemon first. 32 | 2. using mgmt_sendmsg() to send message to daemon, the result will 33 | be returned by the same function 34 | 3. if we register some event by MSG_REGEVT message, we need watch the fd 35 | returned by mgmt_inputfd(), when event comes, call mgmt_recvmsg() to get 36 | the event message. 37 | 4. call mgmt_disconnect() to disconnect from daemon 38 | 5. the format of the message: an ASCII string using "\n" as separator 39 | 6. the message sent to daemon: 40 | MSG_XXXXX\nPARAMETER1\nPARAMETER2\n....\nPARAMETERN 41 | 7. the result message after you send a message to daemon: 42 | ok\nPARAMETER1\nPARAMETER2\n....\nPARAMETERN or 43 | fail\nPARAMETER1\nPARAMETER2\n....\nPARAMETERN 44 | 8. the event message from daemon: 45 | EVT_XXXXX\nPARAMETER1\nPARAMETER2\n....\nPARAMETERN 46 | 9. mgmt_new_msg(),mgmt_msg_append(),mgmt_msg_args(),mgmt_del_msg() and 47 | mgmt_del_args() are used for manipulating the message string 48 | */ 49 | 50 | 51 | /* 52 | mgmt_connect: 53 | connect to server running of daemon. We need send MSG_LOGIN 54 | message for login after we connected. 55 | parameters: 56 | server: ip address of server, like "192.168.30.12" 57 | user and passwd: the authorized user/password on the server. 58 | return: 59 | 0: success 60 | -1: fail 61 | */ 62 | extern int mgmt_connect(const char* server, const char* user 63 | , const char* passwd, const char* port); 64 | 65 | /* 66 | mgmt_sendmsg: 67 | send message to daemon. 68 | parameters: 69 | msg: see the comment above 70 | return: the result from daemon for success, see the comment above 71 | NULL for fail 72 | 73 | */ 74 | extern char* mgmt_sendmsg(const char* msg); 75 | 76 | /* 77 | mgmt_recvmsg: 78 | receive message from daemon when client get an event, 79 | see the comment above 80 | parameters: 81 | return: 82 | the message recieved 83 | */ 84 | extern char* mgmt_recvmsg(void); 85 | 86 | /* 87 | mgmt_inputfd: 88 | return the socket for select, pull, or g_main_loop 89 | parameters: 90 | return: 91 | >0: success 92 | -1: fail 93 | */ 94 | extern int mgmt_inputfd(void); 95 | 96 | /* 97 | mgmt_disconnect: 98 | disconnect from server 99 | parameters: 100 | return: 101 | 0: success 102 | -1: fail 103 | */ 104 | extern int mgmt_disconnect(void); 105 | 106 | /*FIXME: We haven't apply the port 5560 yet*/ 107 | #define PORT 5560 108 | extern int mgmt_session_sendmsg(void* session, const char* msg); 109 | extern char* mgmt_session_recvmsg(void* session); 110 | 111 | #endif /* __MGMT_CLIENT_H */ 112 | -------------------------------------------------------------------------------- /include/mgmt/mgmt_tls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GnuTls wrapper 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (C) 2005 International Business Machines 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | #ifndef __MGMT_TLS_H 23 | #define __MGMT_TLS_H 1 24 | 25 | extern int tls_init_client(void); 26 | extern void* tls_attach_client(int sock); 27 | extern int tls_close_client(void); 28 | 29 | extern int tls_init_server(void); 30 | extern void* tls_attach_server(int sock); 31 | extern int tls_close_server(void); 32 | 33 | extern ssize_t tls_send(void* s, const void *buf, size_t len); 34 | extern ssize_t tls_recv(void* s, void* buf, size_t len); 35 | extern int tls_detach(void* s); 36 | 37 | #endif /* __MGMT_TLS_H */ 38 | -------------------------------------------------------------------------------- /include/mgmt_config.h.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/include/mgmt_config.h.in -------------------------------------------------------------------------------- /include/portability.h: -------------------------------------------------------------------------------- 1 | #ifndef PORTABILITY_H 2 | # define PORTABILITY_H 3 | 4 | /* 5 | * Copyright (C) 2001 Alan Robertson 6 | * This software licensed under the GNU LGPL. 7 | * 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 22 | */ 23 | 24 | #define EOS '\0' 25 | #define DIMOF(a) ((int) (sizeof(a)/sizeof(a[0])) ) 26 | #define STRLEN_CONST(conststr) ((size_t)((sizeof(conststr)/sizeof(char))-1)) 27 | #define STRNCMP_CONST(varstr, conststr) strncmp((varstr), conststr, STRLEN_CONST(conststr)+1) 28 | #define STRLEN(c) STRLEN_CONST(c) 29 | 30 | /* Needs to be defined before any other includes, otherwise some system 31 | * headers do not behave as expected! Major black magic... */ 32 | #undef _GNU_SOURCE /* in case it was defined on the command line */ 33 | #define _GNU_SOURCE 34 | 35 | /* Please leave this as the first #include - Solaris needs it there */ 36 | #ifdef HAVE_CONFIG_H 37 | #include 38 | #endif 39 | 40 | #include 41 | #ifdef BSD 42 | # define SCANSEL_CAST (void *) 43 | #else 44 | # define SCANSEL_CAST /* Nothing */ 45 | #endif 46 | 47 | #if defined(ANSI_ONLY) && !defined(inline) 48 | # define inline /* nothing */ 49 | # undef NETSNMP_ENABLE_INLINE 50 | # define NETSNMP_NO_INLINE 1 51 | #endif 52 | 53 | #ifndef HAVE_DAEMON 54 | /* We supply a replacement function, but need a prototype */ 55 | int daemon(int nochdir, int noclose); 56 | #endif /* HAVE_DAEMON */ 57 | 58 | #ifndef HAVE_SETENV 59 | /* We supply a replacement function, but need a prototype */ 60 | int setenv(const char *name, const char * value, int why); 61 | #endif /* HAVE_SETENV */ 62 | 63 | #ifndef HAVE_STRERROR 64 | /* We supply a replacement function, but need a prototype */ 65 | char * strerror(int errnum); 66 | #endif /* HAVE_STRERROR */ 67 | 68 | #ifndef HAVE_ALPHASORT 69 | # include 70 | int 71 | alphasort(const void *dirent1, const void *dirent2); 72 | #endif /* HAVE_ALPHASORT */ 73 | 74 | #ifndef HAVE_INET_PTON 75 | /* We supply a replacement function, but need a prototype */ 76 | int 77 | inet_pton(int af, const char *src, void *dst); 78 | 79 | #endif /* HAVE_INET_PTON */ 80 | 81 | #ifndef HAVE_STRNLEN 82 | size_t strnlen(const char *s, size_t maxlen); 83 | #else 84 | # define USE_GNU 85 | #endif 86 | 87 | #ifndef HAVE_STRNDUP 88 | char *strndup(const char *str, size_t len); 89 | #else 90 | # define USE_GNU 91 | #endif 92 | 93 | #ifdef HAVE_STRUCT_UCRED_DARWIN 94 | # include 95 | # ifndef SYS_NMLN 96 | # define SYS_NMLN _SYS_NAMELEN 97 | # endif /* SYS_NMLN */ 98 | #endif 99 | 100 | #define POINTER_TO_SIZE_T(p) ((size_t)(p)) /*pointer cast as size_t*/ 101 | #define POINTER_TO_SSIZE_T(p) ((ssize_t)(p)) /*pointer cast as ssize_t*/ 102 | #define POINTER_TO_ULONG(p) ((unsigned long)(p)) /*pointer cast as unsigned long*/ 103 | 104 | #define HAURL(url) HA_URLBASE url 105 | 106 | #endif /* PORTABILITY_H */ 107 | -------------------------------------------------------------------------------- /include/pygui_internal.h: -------------------------------------------------------------------------------- 1 | #if HAVE_HB_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #if HAVE_GLUE_CONFIG_H 6 | #include 7 | #endif 8 | 9 | #include 10 | #include 11 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # heartbeat library directory: Linux-HA code 3 | # 4 | # Copyright (C) 2001 Alan Robertson 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | # 20 | MAINTAINERCLEANFILES = Makefile.in 21 | 22 | ## Subdirectories... 23 | SUBDIRS = mgmt 24 | 25 | -------------------------------------------------------------------------------- /lib/mgmt/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | Makefile 3 | *.beam 4 | .deps 5 | .libs 6 | *.la 7 | *.lo 8 | pymgmt.py 9 | pymgmt_wrap.c 10 | pymgmt_wrap.doc 11 | -------------------------------------------------------------------------------- /lib/mgmt/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2005 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in 20 | 21 | INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ 22 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 23 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ 24 | -I$(top_builddir) -I$(top_srcdir) 25 | 26 | halibdir = $(libdir)/@HB_PKG@ 27 | if MGMT_CLIENT_BUILD 28 | guilibdir = $(libdir)/heartbeat-gui 29 | endif 30 | havarlibdir = $(localstatedir)/lib/@HB_PKG@ 31 | COMMONLIBS = $(GLIBLIB) 32 | #MGMT_DIR = mgmt 33 | #mgmtdir = $(HA_VARLIBHBDIR)/$(MGMT_DIR) 34 | apigid = @HA_APIGROUP@ 35 | 36 | EXTRA_DIST = pymgmt.i 37 | 38 | lib_LTLIBRARIES = libhbmgmttls.la libhbmgmtclient.la libhbmgmtcommon.la 39 | libhbmgmttls_la_SOURCES = mgmt_tls_lib.c 40 | libhbmgmttls_la_LIBADD = $(COMMONLIBS) $(GNUTLSLIBS) 41 | libhbmgmttls_la_CFLAGS = $(INCLUDES) $(GNUTLSHEAD) 42 | 43 | libhbmgmtclient_la_SOURCES = mgmt_client_lib.c 44 | libhbmgmtclient_la_LIBADD = $(COMMONLIBS) libhbmgmttls.la $(top_builddir)/replace/libreplace.la 45 | libhbmgmtclient_la_CFLAGS = $(INCLUDES) 46 | 47 | libhbmgmtcommon_la_SOURCES = mgmt_common_lib.c 48 | libhbmgmtcommon_la_LIBADD = $(COMMONLIBS) $(top_builddir)/replace/libreplace.la 49 | libhbmgmtcommon_la_CFLAGS = $(INCLUDES) 50 | 51 | if MGMT_CLIENT_BUILD 52 | guilib_LTLIBRARIES = _pymgmt.la 53 | _pymgmt_la_SOURCES = pymgmt_wrap.c mgmt_client_lib.c mgmt_tls_lib.c mgmt_common_lib.c 54 | _pymgmt_la_CFLAGS = @PYTHON_INCLUDES@ -I$(top_builddir)/include -w 55 | _pymgmt_la_LDFLAGS = -module 56 | _pymgmt_la_LIBADD = $(GNUTLSLIBS) $(top_builddir)/replace/libreplace.la 57 | 58 | guilib_DATA = pymgmt.py 59 | 60 | pymgmt_wrap.c pymgmt.py: pymgmt.i 61 | $(SWIG) -python $^ 62 | endif 63 | 64 | #install-exec-local: 65 | # $(mkinstalldirs) $(DESTDIR)$(mgmtdir) 66 | # -chgrp $(apigid) $(DESTDIR)/$(mgmtdir) 67 | # chmod 770 $(DESTDIR)/$(mgmtdir) 68 | -------------------------------------------------------------------------------- /lib/mgmt/mgmt_common_lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux HA management common macros and functions 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (C) 2005 International Business Machines 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | malloc_t malloc_f = NULL; 37 | realloc_t realloc_f = NULL; 38 | free_t free_f = NULL; 39 | 40 | char* 41 | mgmt_new_msg(const char* type, ...) 42 | { 43 | va_list ap; 44 | int len; 45 | char* buf; 46 | 47 | /* count the total len of fields */ 48 | len = strnlen(type, MAX_STRLEN)+1; 49 | va_start(ap,type); 50 | while(1) { 51 | char* arg = va_arg(ap, char*); 52 | if (arg == NULL) { 53 | break; 54 | } 55 | len += strnlen(arg, MAX_STRLEN)+1; 56 | } 57 | va_end(ap); 58 | 59 | /* alloc memory */ 60 | buf = (char*)mgmt_malloc(len+1); 61 | if (buf == NULL) { 62 | return NULL; 63 | } 64 | 65 | /* assign the first field */ 66 | snprintf(buf, len, "%s", type); 67 | 68 | /* then the others */ 69 | va_start(ap, type); 70 | while(1) { 71 | char* arg = va_arg(ap, char*); 72 | if (arg == NULL) { 73 | break; 74 | } 75 | strncat(buf, "\n", len-strlen(buf)-1); 76 | strncat(buf, arg, len-strlen(buf)-1); 77 | } 78 | va_end(ap); 79 | 80 | return buf; 81 | } 82 | char* 83 | mgmt_msg_append(char* msg, const char* append) 84 | { 85 | int msg_len; 86 | int append_len; 87 | int len; 88 | 89 | /*msg_len = strnlen(msg, MAX_MSGLEN);*/ 90 | msg_len = strlen(msg); 91 | if (append != NULL) { 92 | /*append_len = strnlen(append, MAX_STRLEN);*/ 93 | append_len = strlen(append); 94 | /* +2: one is the '\n', other is the end 0*/ 95 | len = msg_len+append_len+2; 96 | msg = (char*)mgmt_realloc(msg, len); 97 | strncat(msg, "\n", len-strlen(msg)-1); 98 | strncat(msg, append, len-strlen(msg)-1); 99 | } 100 | else { 101 | /* +2: one is the '\n', other is the end 0*/ 102 | len = msg_len+2; 103 | msg = (char*)mgmt_realloc(msg, len); 104 | strncat(msg, "\n", len-strlen(msg)-1); 105 | } 106 | return msg; 107 | } 108 | int 109 | mgmt_result_ok(char* msg) 110 | { 111 | int ret, num; 112 | char** args = mgmt_msg_args(msg, &num); 113 | if (args == NULL || num ==0) { 114 | ret = 0; 115 | } 116 | else if (STRNCMP_CONST(args[0], MSG_OK)!=0) { 117 | ret = 0; 118 | } 119 | else { 120 | ret = 1; 121 | } 122 | mgmt_del_args(args); 123 | return ret; 124 | } 125 | 126 | char** 127 | mgmt_msg_args(const char* msg, int* num) 128 | { 129 | char* p; 130 | char* buf; 131 | char** ret = NULL; 132 | int i,n; 133 | int len; 134 | 135 | if (msg == NULL) { 136 | return NULL; 137 | } 138 | 139 | /* alloc memory */ 140 | len = strnlen(msg, MAX_MSGLEN); 141 | buf = (char*)mgmt_malloc(len+1); 142 | if (buf == NULL) { 143 | return NULL; 144 | } 145 | 146 | strncpy(buf, msg, len); 147 | buf[len] = 0; 148 | 149 | /* find out how many fields first */ 150 | p = buf; 151 | n = 1; 152 | while(1) { 153 | p=strchr(p,'\n'); 154 | if (p != NULL) { 155 | p++; 156 | n++; 157 | } 158 | else { 159 | break; 160 | } 161 | } 162 | 163 | /* malloc the array for args */ 164 | ret = (char**)mgmt_malloc(sizeof(char*)*n); 165 | if (ret == NULL) { 166 | mgmt_free(buf); 167 | return NULL; 168 | } 169 | 170 | /* splite the string to fields */ 171 | ret[0] = buf; 172 | for (i = 1; i < n; i++) { 173 | ret[i] = strchr(ret[i-1],'\n'); 174 | *ret[i] = 0; 175 | ret[i]++; 176 | } 177 | if (num != NULL) { 178 | *num = n; 179 | } 180 | return ret; 181 | } 182 | 183 | void 184 | mgmt_del_msg(char* msg) 185 | { 186 | if (msg != NULL) { 187 | mgmt_free(msg); 188 | } 189 | } 190 | void 191 | mgmt_del_args(char** args) 192 | { 193 | if (args != NULL) { 194 | if (args[0] != NULL) { 195 | mgmt_free(args[0]); 196 | } 197 | mgmt_free(args); 198 | } 199 | } 200 | 201 | void 202 | mgmt_set_mem_funcs(malloc_t m, realloc_t r, free_t f) 203 | { 204 | malloc_f = m; 205 | realloc_f = r; 206 | free_f = f; 207 | } 208 | 209 | void* 210 | mgmt_malloc(size_t size) 211 | { 212 | if (malloc_f == NULL) { 213 | return malloc(size); 214 | } 215 | return (*malloc_f)(size); 216 | } 217 | 218 | void* 219 | mgmt_realloc(void* oldval, size_t newsize) 220 | { 221 | if (realloc_f == NULL) { 222 | return realloc(oldval, newsize); 223 | } 224 | return (*realloc_f)(oldval, newsize); 225 | } 226 | 227 | void 228 | mgmt_free(void *ptr) 229 | { 230 | if (free_f == NULL) { 231 | free(ptr); 232 | return; 233 | } 234 | (*free_f)(ptr); 235 | } 236 | -------------------------------------------------------------------------------- /lib/mgmt/mgmt_tls_lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux HA management gnutls wrapper library 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (C) 2005 International Business Machines 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | #define DH_BITS 1024 38 | 39 | static gnutls_dh_params_t dh_params; 40 | gnutls_anon_server_credentials_t anoncred_server; 41 | gnutls_anon_client_credentials_t anoncred_client; 42 | 43 | const int kx_prio[] = 44 | { 45 | GNUTLS_KX_ANON_DH, 46 | 0 47 | }; 48 | 49 | int 50 | tls_init_client(void) 51 | { 52 | gnutls_global_init(); 53 | gnutls_anon_allocate_client_credentials(&anoncred_client); 54 | return 0; 55 | } 56 | 57 | void* 58 | tls_attach_client(int sock) 59 | { 60 | int ret; 61 | gnutls_session_t *session = (gnutls_session_t *)gnutls_malloc(sizeof(gnutls_session_t)); 62 | gnutls_init(session, GNUTLS_CLIENT); 63 | #ifdef HAVE_GNUTLS_PRIORITY_SET_DIRECT 64 | /* http://www.manpagez.com/info/gnutls/gnutls-2.10.4/gnutls_81.php#Echo-Server-with-anonymous-authentication */ 65 | gnutls_priority_set_direct(*session, "NORMAL:+ANON-DH", NULL); 66 | #else 67 | gnutls_set_default_priority(*session); 68 | gnutls_kx_set_priority (*session, kx_prio); 69 | #endif 70 | gnutls_credentials_set(*session, GNUTLS_CRD_ANON, anoncred_client); 71 | gnutls_transport_set_ptr(*session, (gnutls_transport_ptr_t) GINT_TO_POINTER(sock)); 72 | ret = gnutls_handshake(*session); 73 | if (ret < 0) { 74 | fprintf(stderr, "*** Handshake failed\n"); 75 | gnutls_perror(ret); 76 | gnutls_deinit(*session); 77 | gnutls_free(session); 78 | return NULL; 79 | } 80 | return session; 81 | } 82 | 83 | ssize_t 84 | tls_send(void* s, const void *buf, size_t len) 85 | { 86 | gnutls_session_t *session = (gnutls_session_t *)s; 87 | while (1) { 88 | int ret = gnutls_record_send(*session, buf, len); 89 | if (ret != GNUTLS_E_INTERRUPTED && ret != GNUTLS_E_AGAIN) { 90 | return ret; 91 | } 92 | } 93 | } 94 | ssize_t 95 | tls_recv(void* s, void* buf, size_t len) 96 | { 97 | gnutls_session_t *session = (gnutls_session_t *)s; 98 | while (1) { 99 | int ret = gnutls_record_recv(*session, buf, len); 100 | if (ret != GNUTLS_E_INTERRUPTED && ret != GNUTLS_E_AGAIN) { 101 | return ret; 102 | } 103 | } 104 | } 105 | int 106 | tls_detach(void* s) 107 | { 108 | 109 | gnutls_session_t *session = (gnutls_session_t *)s; 110 | gnutls_bye(*session, GNUTLS_SHUT_RDWR); 111 | gnutls_deinit(*session); 112 | gnutls_free(session); 113 | return 0; 114 | } 115 | 116 | int 117 | tls_close_client(void) 118 | { 119 | gnutls_anon_free_client_credentials (anoncred_client); 120 | gnutls_global_deinit(); 121 | return 0; 122 | } 123 | 124 | int 125 | tls_init_server(void) 126 | { 127 | gnutls_global_init(); 128 | gnutls_anon_allocate_server_credentials (&anoncred_server); 129 | gnutls_dh_params_init(&dh_params); 130 | gnutls_dh_params_generate2(dh_params, DH_BITS); 131 | gnutls_anon_set_server_dh_params (anoncred_server, dh_params); 132 | return 0; 133 | } 134 | 135 | void* 136 | tls_attach_server(int sock) 137 | { 138 | int ret; 139 | gnutls_session_t *session = (gnutls_session_t *)gnutls_malloc(sizeof(gnutls_session_t)); 140 | gnutls_init(session, GNUTLS_SERVER); 141 | #ifdef HAVE_GNUTLS_PRIORITY_SET_DIRECT 142 | /* http://www.manpagez.com/info/gnutls/gnutls-2.10.4/gnutls_81.php#Echo-Server-with-anonymous-authentication */ 143 | gnutls_priority_set_direct(*session, "NORMAL:+ANON-DH", NULL); 144 | #else 145 | gnutls_set_default_priority(*session); 146 | gnutls_kx_set_priority (*session, kx_prio); 147 | #endif 148 | gnutls_credentials_set(*session, GNUTLS_CRD_ANON, anoncred_server); 149 | gnutls_dh_set_prime_bits(*session, DH_BITS); 150 | gnutls_transport_set_ptr(*session, (gnutls_transport_ptr_t) GINT_TO_POINTER(sock)); 151 | ret = gnutls_handshake(*session); 152 | if (ret < 0) { 153 | fprintf(stderr, "*** Handshake has failed (%s)\n\n", 154 | gnutls_strerror(ret)); 155 | gnutls_deinit(*session); 156 | gnutls_free(session); 157 | return NULL; 158 | } 159 | return session; 160 | } 161 | 162 | int 163 | tls_close_server(void) 164 | { 165 | gnutls_anon_free_server_credentials (anoncred_server); 166 | gnutls_global_deinit(); 167 | return 0; 168 | } 169 | 170 | -------------------------------------------------------------------------------- /lib/mgmt/pymgmt.i: -------------------------------------------------------------------------------- 1 | %module pymgmt 2 | %newobject mgmt_recvmsg; 3 | %newobject mgmt_sendmsg; 4 | %newobject mgmt_thread_sendmsg; 5 | 6 | %{ 7 | #include "../../include/mgmt/mgmt_client.h" 8 | 9 | char* mgmt_thread_sendmsg(const char* msg) 10 | { 11 | char* ret_msg; 12 | Py_BEGIN_ALLOW_THREADS 13 | ret_msg = mgmt_sendmsg(msg); 14 | Py_END_ALLOW_THREADS 15 | return ret_msg; 16 | } 17 | %} 18 | 19 | int mgmt_connect(const char* server, const char* user, const char* passwd, const char* port); 20 | char* mgmt_sendmsg(const char* msg); 21 | char* mgmt_recvmsg(void); 22 | char* mgmt_thread_sendmsg(const char* msg); 23 | int mgmt_inputfd(void); 24 | int mgmt_disconnect(void); 25 | -------------------------------------------------------------------------------- /mgmt/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | Makefile 3 | .deps 4 | .libs 5 | *.la 6 | *.lo 7 | *.beam 8 | 9 | -------------------------------------------------------------------------------- /mgmt/Makefile.am: -------------------------------------------------------------------------------- 1 | # Author: Sun Jiang Dong 2 | # Copyright (c) 2004 International Business Machines 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | # 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | SUBDIRS = daemon 21 | 22 | if MGMT_CLIENT_BUILD 23 | SUBDIRS += client 24 | endif 25 | -------------------------------------------------------------------------------- /mgmt/client/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | Makefile 3 | .deps 4 | .libs 5 | *.la 6 | *.lo 7 | *.mo 8 | *.py 9 | *.beam 10 | mgmtdtest 11 | -------------------------------------------------------------------------------- /mgmt/client/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # heartbeat: Linux-HA heartbeat code 3 | # 4 | # Copyright (C) 2001 Michael Moerz 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | # 20 | MAINTAINERCLEANFILES = Makefile.in 21 | 22 | 23 | halibdir = $(libdir)/@HB_PKG@ 24 | guilibdir = @HA_DATADIR@/heartbeat-gui 25 | guilib_SCRIPTS = haclient.py mgmtcmd.py 26 | guilib_DATA = ha.png login.png logout.png exit.png \ 27 | standby-node.png active-node.png add-resource.png remove-resource.png \ 28 | start-resource.png stop-resource.png master-resource.png slave-resource.png \ 29 | default-resource.png up-resource.png down-resource.png cleanup-resource.png \ 30 | dirty-stopped.png failed.png running.png stopped.png starting.png stopping.png \ 31 | nodes.png node.png administration.png record-pending.png \ 32 | manage-resource.png unmanage-resource.png 33 | 34 | desktopdir = $(datadir)/applications 35 | desktop_DATA = crm_gui.desktop 36 | 37 | INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ 38 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 39 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl 40 | 41 | MGMT_DIR = mgmt 42 | 43 | halib_PROGRAMS = mgmtdtest 44 | mgmtdtest_SOURCES = mgmtdtest.c 45 | mgmtdtest_LDADD = $(top_builddir)/lib/$(MGMT_DIR)/libhbmgmtclient.la \ 46 | $(top_builddir)/lib/$(MGMT_DIR)/libhbmgmttls.la \ 47 | $(top_builddir)/lib/$(MGMT_DIR)/libhbmgmtcommon.la 48 | mgmtdtest_LDFLAGS = $(GNUTLSLIBS) 49 | 50 | EXTRA_DIST = $(guilib_DATA) 51 | 52 | -------------------------------------------------------------------------------- /mgmt/client/active-node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/active-node.png -------------------------------------------------------------------------------- /mgmt/client/add-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/add-resource.png -------------------------------------------------------------------------------- /mgmt/client/administration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/administration.png -------------------------------------------------------------------------------- /mgmt/client/cleanup-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/cleanup-resource.png -------------------------------------------------------------------------------- /mgmt/client/crm_gui.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Categories=GNOME;GTK;Settings;System;SystemSetup;X-SuSE-YaST;X-SuSE-YaST-High_Availability; 4 | 5 | X-KDE-ModuleType=Library 6 | X-KDE-RootOnly=false 7 | X-KDE-HasReadOnlyMode=true 8 | X-KDE-Library=yast2 9 | X-KDE-SubstituteUID=false 10 | 11 | X-SuSE-YaST-Call=/usr/bin/crm_gui 12 | X-SuSE-YaST-Group=High_Availability 13 | X-SuSE-YaST-Argument= 14 | X-SuSE-YaST-RootOnly=false 15 | X-SuSE-YaST-Geometry= 16 | X-SuSE-YaST-SortKey= 17 | 18 | Icon=@HA_DATADIR@/heartbeat-gui/ha.png 19 | Exec=/usr/bin/crm_gui 20 | 21 | Name=Pacemaker GUI 22 | GenericName=Pacemaker GUI 23 | Comment=Pacemaker CRM GUI 24 | Encoding=UTF-8 25 | -------------------------------------------------------------------------------- /mgmt/client/default-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/default-resource.png -------------------------------------------------------------------------------- /mgmt/client/dirty-stopped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/dirty-stopped.png -------------------------------------------------------------------------------- /mgmt/client/down-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/down-resource.png -------------------------------------------------------------------------------- /mgmt/client/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/exit.png -------------------------------------------------------------------------------- /mgmt/client/expert-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/expert-mode.png -------------------------------------------------------------------------------- /mgmt/client/failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/failed.png -------------------------------------------------------------------------------- /mgmt/client/ha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/ha.png -------------------------------------------------------------------------------- /mgmt/client/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/login.png -------------------------------------------------------------------------------- /mgmt/client/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/logout.png -------------------------------------------------------------------------------- /mgmt/client/manage-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/manage-resource.png -------------------------------------------------------------------------------- /mgmt/client/master-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/master-resource.png -------------------------------------------------------------------------------- /mgmt/client/mgmtcmd.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ 2 | 3 | ''' sample.py 4 | ''' 5 | 6 | __copyright__=''' 7 | Author: Huang Zhen 8 | Copyright (C) 2005 International Business Machines 9 | ''' 10 | 11 | # 12 | # This program is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU General Public License 14 | # as published by the Free Software Foundation; either version 2 15 | # of the License, or (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with this program; if not, write to the Free Software 24 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 25 | 26 | import sys 27 | sys.path.append("@LIBDIR@/heartbeat-gui") 28 | sys.path.append("@HA_DATADIR@/heartbeat-gui") 29 | 30 | from pymgmt import * 31 | from select import * 32 | import sys 33 | 34 | if __name__=="__main__" : 35 | server = "127.0.0.1" 36 | port = "5560" 37 | username = "hacluster" 38 | password = "hacluster" 39 | messages = [] 40 | 41 | skipthis=False 42 | args=sys.argv[1:] 43 | for i in range(0, len(args)) : 44 | if skipthis : 45 | skipthis=False 46 | continue 47 | elif args[i] == "-s" : 48 | skipthis=True 49 | server = args[i+1] 50 | elif args[i] == "-u" : 51 | skipthis=True 52 | username = args[i+1] 53 | elif args[i] == "-p" : 54 | skipthis=True 55 | password = args[i+1] 56 | elif args[i] == "-P" : 57 | skipthis=True 58 | port = args[i+1] 59 | elif args[i] == "-h" : 60 | print "usage : %s [-s server] [-u username] [-p password] [-P port] msg_type field1 ..." 61 | sys.exit() 62 | else : 63 | messages = args[i:] 64 | break 65 | 66 | if mgmt_connect(server,username,password,port) == -1: 67 | print "login failed" 68 | sys.exit() 69 | 70 | print "---------------------------" 71 | command = "" 72 | for i in messages: 73 | command = command + i +"\n" 74 | command = command[:-1] 75 | 76 | print mgmt_sendmsg(command) 77 | print "---------------------------" 78 | 79 | mgmt_disconnect() 80 | 81 | -------------------------------------------------------------------------------- /mgmt/client/mgmtdtest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test client for Linux HA management daemon 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This software is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | int main (int argc, char* argv[]) 28 | { 29 | char* ret; 30 | int num; 31 | char** args; 32 | if(mgmt_connect("127.0.0.1", "hacluster","hacluster",NULL) != 0) { 33 | printf("can't conenct to mgmtd\n"); 34 | return 1; 35 | } 36 | ret = mgmt_sendmsg(MSG_ECHO"\nhello"); 37 | if (ret == NULL) { 38 | printf("can't process message\n"); 39 | return 1; 40 | } 41 | args = mgmt_msg_args(ret, &num); 42 | if (ret == NULL) { 43 | printf("can't parse the return message\n"); 44 | return 1; 45 | } 46 | if (num != 2) { 47 | printf("the return message has wrong field number\n"); 48 | return 1; 49 | } 50 | if (strncmp(args[0],"ok",strlen("ok")) != 0) { 51 | printf("the return message is not \"ok\"\n"); 52 | return 1; 53 | } 54 | if (strncmp(args[1],"hello",strlen("hello")) != 0) { 55 | printf("the echo string is not same as we sent\"ok\"\n"); 56 | return 1; 57 | } 58 | mgmt_del_args(args); 59 | mgmt_del_msg(ret); 60 | mgmt_disconnect(); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /mgmt/client/node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/node.png -------------------------------------------------------------------------------- /mgmt/client/nodes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/nodes.png -------------------------------------------------------------------------------- /mgmt/client/record-pending.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/record-pending.png -------------------------------------------------------------------------------- /mgmt/client/remove-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/remove-resource.png -------------------------------------------------------------------------------- /mgmt/client/running.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/running.png -------------------------------------------------------------------------------- /mgmt/client/slave-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/slave-resource.png -------------------------------------------------------------------------------- /mgmt/client/standby-node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/standby-node.png -------------------------------------------------------------------------------- /mgmt/client/start-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/start-resource.png -------------------------------------------------------------------------------- /mgmt/client/starting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/starting.png -------------------------------------------------------------------------------- /mgmt/client/stop-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/stop-resource.png -------------------------------------------------------------------------------- /mgmt/client/stopped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/stopped.png -------------------------------------------------------------------------------- /mgmt/client/stopping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/stopping.png -------------------------------------------------------------------------------- /mgmt/client/unmanage-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/unmanage-resource.png -------------------------------------------------------------------------------- /mgmt/client/up-resource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/mgmt/client/up-resource.png -------------------------------------------------------------------------------- /mgmt/daemon/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | Makefile 3 | .deps 4 | .libs 5 | *.la 6 | *.lo 7 | *.beam 8 | mgmtd 9 | -------------------------------------------------------------------------------- /mgmt/daemon/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Sun Jiang Dong 3 | # Copyright (c) 2005 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | # 19 | MAINTAINERCLEANFILES = Makefile.in 20 | 21 | INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ 22 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ 23 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 24 | -I$(top_builddir) -I$(top_srcdir) 25 | 26 | halibdir = $(libdir)/@HB_PKG@ 27 | 28 | COMMONLIBS = -lplumb $(GLIBLIB) 29 | noinst_HEADERS = mgmt_internal.h 30 | EXTRA_DIST = mgmtd.pam mgmtd.pam.common 31 | LRM_DIR = lrm 32 | 33 | pamdir = $(sysconfdir)/pam.d 34 | if USE_PAM_COMMON 35 | pam_DATA = mgmtd.pam.common 36 | else 37 | pam_DATA = mgmtd.pam 38 | endif 39 | 40 | install-data-hook: 41 | mv $(DESTDIR)$(pamdir)/$(pam_DATA) $(DESTDIR)$(pamdir)/hbmgmtd 42 | 43 | 44 | halib_PROGRAMS = mgmtd 45 | mgmtd_SOURCES = mgmtd.c 46 | mgmtd_LDFLAGS = -lpam 47 | mgmtd_LDADD = $(top_builddir)/lib/mgmt/libhbmgmtclient.la \ 48 | $(top_builddir)/lib/mgmt/libhbmgmttls.la \ 49 | libhbmgmt.la \ 50 | $(top_builddir)/lib/mgmt/libhbmgmtcommon.la \ 51 | $(COMMONLIBS) 52 | 53 | if HAVE_PACEMAKER_LRMD 54 | mgmtd_LDADD += -llrmd 55 | else 56 | mgmtd_LDADD += -llrm 57 | endif 58 | 59 | lib_LTLIBRARIES = libhbmgmt.la 60 | libhbmgmt_la_SOURCES = mgmt_lib.c mgmt_crm.c 61 | if HAVE_PACEMAKER_LRMD 62 | libhbmgmt_la_SOURCES += mgmt_pacemaker_lrm.c 63 | else 64 | libhbmgmt_la_SOURCES += mgmt_lrm.c 65 | endif 66 | 67 | 68 | if BUILD_HEARTBEAT_SUPPORT 69 | libhbmgmt_la_SOURCES += mgmt_hb.c 70 | endif 71 | libhbmgmt_la_CFLAGS = $(INCLUDES) 72 | libhbmgmt_la_LDFLAGS = $(GNUTLSLIBS) 73 | libhbmgmt_la_LIBADD = $(top_builddir)/lib/mgmt/libhbmgmttls.la \ 74 | -lcib -lcrmcommon -lpe_status -lcrmcluster \ 75 | $(COMMONLIBS) $(CLUSTERLIBS) $(CURSESLIBS) 76 | -------------------------------------------------------------------------------- /mgmt/daemon/mgmt_hb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux HA management library 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This software is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | #include "mgmt_internal.h" 36 | 37 | int init_heartbeat(void); 38 | void final_heartbeat(void); 39 | 40 | static ll_cluster_t * hb = NULL; 41 | static char* on_get_allnodes(char* argv[], int argc); 42 | static char* on_get_hb_config(char* argv[], int argc); 43 | static char* on_get_nodetype(char* argv[], int argc); 44 | static gboolean on_hb_input(ll_cluster_t* hb, gpointer data); 45 | static char* on_echo(char* argv[], int argc); 46 | static void on_hb_quit(gpointer); 47 | char* hb_config = NULL; 48 | 49 | const char* param_name[] = { 50 | "quorum_server", 51 | "use_logd", 52 | "autojoin", 53 | "apiauth", 54 | "auto_failback", 55 | "baud", 56 | "debug", 57 | "debugfile", 58 | "deadping", 59 | "deadtime", 60 | "hbversion", 61 | "hopfudge", 62 | "initdead", 63 | "keepalive", 64 | "logfacility", 65 | "logfile", 66 | "msgfmt", 67 | "nice_failback", 68 | "node", 69 | "normalpoll", 70 | "stonith", 71 | "udpport", 72 | "warntime", 73 | "watchdog", 74 | "cluster" 75 | }; 76 | 77 | char* 78 | on_get_allnodes(char* argv[], int argc) 79 | { 80 | const char* name = NULL; 81 | char* ret = strdup(MSG_OK); 82 | if (hb->llc_ops->init_nodewalk(hb) != HA_OK) { 83 | mgmt_log(LOG_ERR, "Cannot start node walk"); 84 | mgmt_log(LOG_ERR, "REASON: %s", hb->llc_ops->errmsg(hb)); 85 | free(ret); 86 | return strdup(MSG_FAIL); 87 | } 88 | while((name = hb->llc_ops->nextnode(hb))!= NULL) { 89 | ret = mgmt_msg_append(ret, name); 90 | } 91 | if (hb->llc_ops->end_nodewalk(hb) != HA_OK) { 92 | mgmt_log(LOG_ERR, "Cannot end node walk"); 93 | mgmt_log(LOG_ERR, "REASON: %s", hb->llc_ops->errmsg(hb)); 94 | free(ret); 95 | return strdup(MSG_FAIL); 96 | } 97 | 98 | return ret; 99 | } 100 | 101 | char* 102 | on_get_hb_config(char* argv[], int argc) 103 | { 104 | int i; 105 | char* value = NULL; 106 | if (hb_config == NULL) { 107 | hb_config = strdup(MSG_OK); 108 | for (i = 0; i < sizeof(param_name)/sizeof(param_name[0]); i++) { 109 | value = hb->llc_ops->get_parameter(hb, param_name[i]); 110 | hb_config = mgmt_msg_append(hb_config, param_name[i]); 111 | hb_config = mgmt_msg_append(hb_config, value!=NULL?value:""); 112 | if (value != NULL) { 113 | free(value); 114 | } 115 | } 116 | } 117 | return strdup(hb_config); 118 | } 119 | 120 | char* 121 | on_get_nodetype(char* argv[], int argc) 122 | { 123 | const char* type; 124 | char* ret; 125 | type = hb->llc_ops->node_type(hb,argv[1]); 126 | if (type != NULL) { 127 | ret = strdup(MSG_OK); 128 | ret = mgmt_msg_append(ret, type); 129 | } 130 | else { 131 | ret = strdup(MSG_FAIL); 132 | } 133 | return ret; 134 | } 135 | 136 | int 137 | init_heartbeat(void) 138 | { 139 | hb = ll_cluster_new("heartbeat"); 140 | if (hb->llc_ops->signon(hb, client_name)!= HA_OK) { 141 | mgmt_log(LOG_ERR, "Cannot sign on with heartbeat"); 142 | mgmt_log(LOG_ERR, "REASON: %s", hb->llc_ops->errmsg(hb)); 143 | hb->llc_ops->delete(hb); 144 | hb = NULL; 145 | return -1; 146 | } 147 | G_main_add_ll_cluster(G_PRIORITY_LOW, hb, 148 | FALSE, on_hb_input, NULL, on_hb_quit); 149 | 150 | reg_msg(MSG_ALLNODES, on_get_allnodes); 151 | reg_msg(MSG_HB_CONFIG, on_get_hb_config); 152 | reg_msg(MSG_NODE_TYPE, on_get_nodetype); 153 | reg_msg(MSG_ECHO, on_echo); 154 | 155 | return 0; 156 | } 157 | 158 | void 159 | final_heartbeat(void) 160 | { 161 | if (hb != NULL) { 162 | hb->llc_ops->delete(hb); 163 | hb = NULL; 164 | } 165 | fire_event(EVT_DISCONNECTED); 166 | } 167 | 168 | gboolean 169 | on_hb_input(ll_cluster_t *hb, gpointer data) 170 | { 171 | struct ha_msg* msg; 172 | IPC_Channel *chan = NULL; 173 | 174 | if(hb != NULL) { 175 | chan = hb->llc_ops->ipcchan(hb); 176 | } 177 | if (chan == NULL || !IPC_ISRCONN(chan)) { 178 | fire_event(EVT_DISCONNECTED); 179 | mgmt_log(LOG_ERR, "Lost connection to heartbeat service."); 180 | hb = NULL; 181 | return FALSE; 182 | } 183 | msg = hb->llc_ops->readmsg(hb, 0); 184 | if (msg != NULL) { 185 | ha_msg_del(msg); 186 | } 187 | return TRUE; 188 | } 189 | void 190 | on_hb_quit(gpointer user_data) 191 | { 192 | return; 193 | } 194 | 195 | char* 196 | on_echo(char* argv[], int argc) 197 | { 198 | char* ret = strdup(MSG_OK); 199 | ret = mgmt_msg_append(ret, argv[1]); 200 | 201 | return ret; 202 | } 203 | 204 | -------------------------------------------------------------------------------- /mgmt/daemon/mgmt_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * internal header file of management libray 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (C) 2005 International Business Machines 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | #ifndef __MGMT_INTERNAL_H 24 | #define __HAM__MGMT_INTERNAL_H 1 25 | 26 | #include 27 | 28 | #ifndef ENV_PREFIX 29 | #define ENV_PREFIX "HA_" 30 | #endif 31 | 32 | #ifndef KEY_LOGDAEMON 33 | #define KEY_LOGDAEMON "use_logd" 34 | #endif 35 | 36 | #ifndef HADEBUGVAL 37 | #define HADEBUGVAL "HA_debug" 38 | #endif 39 | 40 | #define mgmt_log(priority, fmt...) \ 41 | cl_log(priority, fmt); \ 42 | 43 | #define mgmt_debug(priority, fmt...) \ 44 | if ( debug_level > 0 ) { \ 45 | cl_log(priority, fmt); \ 46 | } 47 | #define STRNCPY(dest,src,n) \ 48 | strncpy(dest,src,n); dest[n-1]='\0'; 49 | 50 | #define ARGC_CHECK(n) \ 51 | if (argc != (n)) { \ 52 | mgmt_log(LOG_DEBUG, "%s msg should have %d params, but %d given",argv[0],n,argc); \ 53 | return strdup(MSG_FAIL"\nwrong parameter number"); \ 54 | } 55 | extern const char* client_name; 56 | extern int debug_level; 57 | typedef char* (*msg_handler)(char* argv[], int argc); 58 | extern int reg_msg(const char* type, msg_handler fun); 59 | extern int fire_event(const char* event); 60 | 61 | #endif /* __MGMT_INTERNAL_H */ 62 | -------------------------------------------------------------------------------- /mgmt/daemon/mgmt_lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux HA management library 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This software is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #if HAVE_SECURITY_PAM_APPL_H 29 | # include 30 | #else 31 | # if HAVE_PAM_PAM_APPL_H 32 | # include 33 | # endif 34 | #endif 35 | #include 36 | 37 | #if HAVE_HB_CONFIG_H 38 | #include 39 | #endif 40 | 41 | #if HAVE_GLUE_CONFIG_H 42 | #include 43 | #endif 44 | 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | #include 54 | 55 | /* 56 | #ifdef SUPPORT_COROSYNC 57 | #undef SUPPORT_COROSYNC 58 | #endif 59 | */ 60 | 61 | #ifdef SUPPORT_HEARTBEAT 62 | #undef SUPPORT_HEARTBEAT 63 | #endif 64 | 65 | #include 66 | 67 | #if HAVE_PACEMAKER_CRM_COMMON_CLUSTER_H 68 | # include 69 | #endif 70 | #if HAVE_PACEMAKER_CRM_CLUSTER_H 71 | # include 72 | #endif 73 | 74 | #include 75 | #include "mgmt_internal.h" 76 | 77 | 78 | /* common daemon and debug functions */ 79 | 80 | /* the initial func for modules */ 81 | extern int init_general(void); 82 | extern void final_general(void); 83 | #if SUPPORT_HEARTBEAT 84 | extern int init_heartbeat(void); 85 | #endif 86 | extern void final_heartbeat(void); 87 | extern int init_lrm(void); 88 | extern void final_lrm(void); 89 | 90 | static GHashTable* msg_map = NULL; 91 | static GHashTable* event_map = NULL; 92 | const char* client_name = NULL; 93 | static int components = 0; 94 | int 95 | init_mgmt_lib(const char* client, int enable_components) 96 | { 97 | /* create the internal data structures */ 98 | msg_map = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL); 99 | event_map = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL); 100 | client_name = client?client:"unknown"; 101 | components = enable_components; 102 | mgmt_set_mem_funcs(malloc, realloc, free); 103 | 104 | if (components & ENABLE_CRM) { 105 | #if HAVE_DECL_CRM_XML_INIT 106 | crm_xml_init(); 107 | #endif 108 | } 109 | 110 | /* init modules */ 111 | #if SUPPORT_HEARTBEAT 112 | if(is_heartbeat_cluster()) { 113 | if (components & ENABLE_HB) { 114 | if (init_heartbeat() != 0) { 115 | return -1; 116 | } 117 | } 118 | } 119 | #endif 120 | if (components & ENABLE_LRM) { 121 | if (init_lrm() != 0) { 122 | return -1; 123 | } 124 | } 125 | return 0; 126 | } 127 | 128 | int 129 | final_mgmt_lib() 130 | { 131 | if (components & ENABLE_LRM) { 132 | final_lrm(); 133 | } 134 | #if SUPPORT_HEARTBEAT 135 | if(is_heartbeat_cluster()) { 136 | if (components & ENABLE_HB) { 137 | final_heartbeat(); 138 | } 139 | } 140 | #endif 141 | 142 | if (components & ENABLE_CRM) { 143 | #if HAVE_DECL_CRM_XML_INIT 144 | crm_xml_cleanup(); 145 | #endif 146 | } 147 | 148 | g_hash_table_destroy(msg_map); 149 | g_hash_table_destroy(event_map); 150 | return 0; 151 | } 152 | 153 | int 154 | reg_msg(const char* type, msg_handler fun) 155 | { 156 | if (g_hash_table_lookup(msg_map, type) != NULL) { 157 | return -1; 158 | } 159 | g_hash_table_insert(msg_map, strdup(type),(gpointer)fun); 160 | return 0; 161 | } 162 | 163 | int 164 | fire_event(const char* event) 165 | { 166 | event_handler func = NULL; 167 | 168 | char** args = mgmt_msg_args(event, NULL); 169 | if (args == NULL) { 170 | return -1; 171 | } 172 | 173 | func = (event_handler)g_hash_table_lookup(event_map, args[0]); 174 | if (func != NULL) { 175 | func(event); 176 | } 177 | mgmt_del_args(args); 178 | return 0; 179 | } 180 | 181 | char* 182 | process_msg(const char* msg) 183 | { 184 | msg_handler handler; 185 | char* ret; 186 | int num; 187 | char** args = mgmt_msg_args(msg, &num); 188 | if (args == NULL) { 189 | return NULL; 190 | } 191 | handler = (msg_handler)g_hash_table_lookup(msg_map, args[0]); 192 | if ( handler == NULL) { 193 | mgmt_del_args(args); 194 | return NULL; 195 | } 196 | ret = (*handler)(args, num); 197 | mgmt_del_args(args); 198 | return ret; 199 | } 200 | int 201 | reg_event(const char* type, event_handler func) 202 | { 203 | g_hash_table_replace(event_map, strdup(type), (gpointer)func); 204 | return 0; 205 | } 206 | -------------------------------------------------------------------------------- /mgmt/daemon/mgmt_lrm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux HA management library 3 | * 4 | * Author: Huang Zhen 5 | * Copyright (c) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This software is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #if HAVE_HB_CONFIG_H 30 | #include 31 | #endif 32 | 33 | #if HAVE_GLUE_CONFIG_H 34 | #include 35 | #endif 36 | 37 | #include 38 | #include 39 | 40 | #include "mgmt_internal.h" 41 | #include 42 | 43 | 44 | 45 | static char* on_rsc_class(char* argv[], int argc); 46 | static char* on_rsc_type(char* argv[], int argc); 47 | static char* on_rsc_provider(char* argv[], int argc); 48 | static char* on_rsc_metadata(char* argv[], int argc); 49 | static char* on_lrm_op_rc2str(char* argv[], int argc); 50 | 51 | 52 | ll_lrm_t* lrm = NULL; 53 | int init_lrm(void); 54 | void final_lrm(void); 55 | 56 | int 57 | init_lrm(void) 58 | { 59 | int ret; 60 | int i, max_try = 5; 61 | 62 | lrm = ll_lrm_new("lrm"); 63 | for (i = 0; i < max_try ; i++) { 64 | ret = lrm->lrm_ops->signon(lrm,"mgmtd"); 65 | if (ret == HA_OK) { 66 | break; 67 | } 68 | mgmt_log(LOG_INFO,"login to lrm: %d, ret:%d",i,ret); 69 | sleep(1); 70 | } 71 | if (ret != HA_OK) { 72 | mgmt_log(LOG_INFO,"login to lrm failed"); 73 | lrm->lrm_ops->delete(lrm); 74 | lrm = NULL; 75 | return -1; 76 | } 77 | 78 | reg_msg(MSG_RSC_CLASSES, on_rsc_class); 79 | reg_msg(MSG_RSC_TYPES, on_rsc_type); 80 | reg_msg(MSG_RSC_PROVIDERS, on_rsc_provider); 81 | reg_msg(MSG_RSC_METADATA, on_rsc_metadata); 82 | reg_msg(MSG_LRM_OP_RC2STR, on_lrm_op_rc2str); 83 | return 0; 84 | } 85 | 86 | 87 | void 88 | final_lrm(void) 89 | { 90 | if (lrm != NULL) { 91 | lrm->lrm_ops->signoff(lrm); 92 | lrm->lrm_ops->delete(lrm); 93 | lrm = NULL; 94 | } 95 | } 96 | 97 | char* 98 | on_rsc_class(char* argv[], int argc) 99 | { 100 | GList* classes; 101 | GList* cur; 102 | char* ret = strdup(MSG_OK); 103 | classes = lrm->lrm_ops->get_rsc_class_supported(lrm); 104 | cur = classes; 105 | while (cur != NULL) { 106 | ret = mgmt_msg_append(ret, (char*)cur->data); 107 | cur = g_list_next(cur); 108 | } 109 | lrm_free_str_list(classes); 110 | return ret; 111 | } 112 | 113 | char* 114 | on_rsc_type(char* argv[], int argc) 115 | { 116 | 117 | GList* types; 118 | GList* cur; 119 | char* ret; 120 | 121 | ARGC_CHECK(2) 122 | 123 | ret = strdup(MSG_OK); 124 | types = lrm->lrm_ops->get_rsc_type_supported(lrm, argv[1]); 125 | cur = types; 126 | while (cur != NULL) { 127 | ret = mgmt_msg_append(ret, (char*)cur->data); 128 | cur = g_list_next(cur); 129 | } 130 | lrm_free_str_list(types); 131 | return ret; 132 | } 133 | 134 | char* 135 | on_rsc_provider(char* argv[], int argc) 136 | { 137 | GList* providers; 138 | GList* cur; 139 | char* ret = strdup(MSG_OK); 140 | providers = lrm->lrm_ops->get_rsc_provider_supported(lrm, argv[1], argv[2]); 141 | cur = providers; 142 | while (cur != NULL) { 143 | ret = mgmt_msg_append(ret, (char*)cur->data); 144 | cur = g_list_next(cur); 145 | } 146 | lrm_free_str_list(providers); 147 | return ret; 148 | } 149 | char* 150 | on_rsc_metadata(char* argv[], int argc) 151 | { 152 | char* ret; 153 | char* metadata = lrm->lrm_ops->get_rsc_type_metadata(lrm, argv[1], argv[2], argv[3]); 154 | if (metadata != NULL) { 155 | ret = strdup(MSG_OK); 156 | ret = mgmt_msg_append(ret, metadata); 157 | g_free(metadata); 158 | return ret; 159 | } 160 | return strdup(MSG_FAIL); 161 | } 162 | 163 | char* 164 | on_lrm_op_rc2str(char* argv[], int argc) 165 | { 166 | int rc; 167 | char* ret = strdup(MSG_OK); 168 | 169 | rc = atoi(argv[1]); 170 | ret = mgmt_msg_append(ret, execra_code2string(rc)); 171 | return ret; 172 | } 173 | -------------------------------------------------------------------------------- /mgmt/daemon/mgmt_pacemaker_lrm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Gao,Yan 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This software is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include "mgmt_internal.h" 31 | #include 32 | 33 | static char* on_rsc_class(char* argv[], int argc); 34 | static char* on_rsc_type(char* argv[], int argc); 35 | static char* on_rsc_provider(char* argv[], int argc); 36 | static char* on_rsc_metadata(char* argv[], int argc); 37 | static char* on_lrm_op_rc2str(char* argv[], int argc); 38 | 39 | 40 | lrmd_t *lrmd_conn = NULL; 41 | int init_lrm(void); 42 | void final_lrm(void); 43 | 44 | int 45 | init_lrm(void) 46 | { 47 | int rc = 0; 48 | int i = 0; 49 | int max_try = 5; 50 | 51 | lrmd_conn = lrmd_api_new(); 52 | for (i = 0; i < max_try; i++) { 53 | rc = lrmd_conn->cmds->connect(lrmd_conn, "mgmtd", NULL); 54 | if (rc == 0) { 55 | break; 56 | } 57 | mgmt_log(LOG_NOTICE,"connect to lrmd: %d, rc=%d", i, rc); 58 | sleep(1); 59 | } 60 | if (rc != 0) { 61 | mgmt_log(LOG_WARNING,"connect to lrmd failed"); 62 | lrmd_api_delete(lrmd_conn); 63 | lrmd_conn = NULL; 64 | return -1; 65 | } 66 | 67 | reg_msg(MSG_RSC_CLASSES, on_rsc_class); 68 | reg_msg(MSG_RSC_TYPES, on_rsc_type); 69 | reg_msg(MSG_RSC_PROVIDERS, on_rsc_provider); 70 | reg_msg(MSG_RSC_METADATA, on_rsc_metadata); 71 | reg_msg(MSG_LRM_OP_RC2STR, on_lrm_op_rc2str); 72 | return 0; 73 | } 74 | 75 | 76 | void 77 | final_lrm(void) 78 | { 79 | if (lrmd_conn != NULL) { 80 | lrmd_conn->cmds->disconnect(lrmd_conn); 81 | lrmd_api_delete(lrmd_conn); 82 | lrmd_conn = NULL; 83 | } 84 | } 85 | 86 | char* 87 | on_rsc_class(char* argv[], int argc) 88 | { 89 | int rc = 0; 90 | lrmd_list_t *list = NULL; 91 | lrmd_list_t *iter = NULL; 92 | char* ret = strdup(MSG_OK); 93 | 94 | rc = lrmd_conn->cmds->list_standards(lrmd_conn, &list); 95 | 96 | if (rc > 0) { 97 | for (iter = list; iter != NULL; iter = iter->next) { 98 | ret = mgmt_msg_append(ret, iter->val); 99 | } 100 | lrmd_list_freeall(list); 101 | 102 | } else { 103 | mgmt_log(LOG_ERR, "No resource classes found"); 104 | } 105 | 106 | return ret; 107 | } 108 | 109 | char* 110 | on_rsc_type(char* argv[], int argc) 111 | { 112 | int rc = 0; 113 | lrmd_list_t *list = NULL; 114 | lrmd_list_t *iter = NULL; 115 | 116 | char* ret = NULL; 117 | 118 | ARGC_CHECK(2) 119 | 120 | ret = strdup(MSG_OK); 121 | 122 | rc = lrmd_conn->cmds->list_agents(lrmd_conn, &list, argv[1], NULL); 123 | 124 | if (rc > 0) { 125 | for (iter = list; iter != NULL; iter = iter->next) { 126 | ret = mgmt_msg_append(ret, iter->val); 127 | } 128 | lrmd_list_freeall(list); 129 | 130 | } else { 131 | mgmt_log(LOG_NOTICE, "No %s resource types found", argv[1]); 132 | } 133 | 134 | return ret; 135 | } 136 | 137 | char* 138 | on_rsc_provider(char* argv[], int argc) 139 | { 140 | int rc = 0; 141 | lrmd_list_t *list = NULL; 142 | lrmd_list_t *iter = NULL; 143 | 144 | char* ret = strdup(MSG_OK); 145 | 146 | rc = lrmd_conn->cmds->list_ocf_providers(lrmd_conn, argv[2], &list); 147 | 148 | if (rc > 0) { 149 | for (iter = list; iter != NULL; iter = iter->next) { 150 | ret = mgmt_msg_append(ret, iter->val); 151 | } 152 | lrmd_list_freeall(list); 153 | 154 | } else { 155 | mgmt_log(LOG_ERR, "No %s providers found for %s", argv[1], argv[2]); 156 | } 157 | 158 | return ret; 159 | } 160 | char* 161 | on_rsc_metadata(char* argv[], int argc) 162 | { 163 | int rc = 0; 164 | char *output = NULL; 165 | char* ret = NULL; 166 | 167 | rc = lrmd_conn->cmds->get_metadata(lrmd_conn, argv[1], argv[3], argv[2], &output, 0); 168 | if (rc == 0) { 169 | ret = strdup(MSG_OK); 170 | ret = mgmt_msg_append(ret, output); 171 | free(output); 172 | return ret; 173 | } 174 | 175 | return strdup(MSG_FAIL); 176 | } 177 | 178 | char* 179 | on_lrm_op_rc2str(char* argv[], int argc) 180 | { 181 | int rc = 0; 182 | char* ret = strdup(MSG_OK); 183 | 184 | rc = atoi(argv[1]); 185 | #if !HAVE_DECL_SERVICES_OCF_EXITCODE_STR 186 | ret = mgmt_msg_append(ret, lrmd_event_rc2str(rc)); 187 | #else 188 | ret = mgmt_msg_append(ret, services_ocf_exitcode_str(rc)); 189 | #endif 190 | return ret; 191 | } 192 | -------------------------------------------------------------------------------- /mgmt/daemon/mgmtd.pam: -------------------------------------------------------------------------------- 1 | auth required pam_unix.so 2 | account required pam_unix.so 3 | 4 | -------------------------------------------------------------------------------- /mgmt/daemon/mgmtd.pam.common: -------------------------------------------------------------------------------- 1 | #%PAM-1.0 2 | 3 | auth include common-auth 4 | account include common-account 5 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | ja zh_CN 2 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | mgmt/client/haclient.py.in 2 | -------------------------------------------------------------------------------- /replace/.cvsignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .libs 3 | Makefile.in 4 | Makefile 5 | *.la 6 | *.lo 7 | .*.swp 8 | *.beam 9 | parser-messages 10 | MISC_ERRORS 11 | -------------------------------------------------------------------------------- /replace/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | # 17 | 18 | MAINTAINERCLEANFILES = Makefile.in 19 | 20 | INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \ 21 | -I$(top_srcdir)/linux-ha -I$(top_builddir)/linux-ha 22 | 23 | QUIET_LIBTOOL_OPTS = @QUIET_LIBTOOL_OPTS@ 24 | LIBTOOL = @LIBTOOL@ @QUIET_LIBTOOL_OPTS@ 25 | 26 | 27 | noinst_LTLIBRARIES = libreplace.la 28 | libreplace_la_SOURCES = 29 | libreplace_la_LIBADD = @LTLIBOBJS@ 30 | -------------------------------------------------------------------------------- /replace/NoSuchFunctionName.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | */ 21 | void nosuchfunctionname(void); 22 | 23 | /* 24 | * This is a completely useless function put here only to make OpenBSD make 25 | * procedures happy. I hope no one ever makes such a function ;-) 26 | */ 27 | void 28 | nosuchfunctionname(void) 29 | { 30 | return; 31 | } 32 | -------------------------------------------------------------------------------- /replace/alphasort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * alphasort - replacement for alphasort functions. 4 | * 5 | * Matt Soffen 6 | 7 | * Copyright (C) 2001 Matt Soffen 8 | * 9 | * Taken from the FreeBSD file (with copyright notice) 10 | * /usr/src/gnu/lib/libdialog/dir.c 11 | *************************************************************************** 12 | * Program: dir.c 13 | * Author: Marc van Kempen 14 | * desc: Directory routines, sorting and reading 15 | * 16 | * Copyright (c) 1995, Marc van Kempen 17 | * 18 | * All rights reserved. 19 | * 20 | * This software may be used, modified, copied, distributed, and 21 | * sold, in both source and binary form provided that the above 22 | * copyright and these terms are retained, verbatim, as the first 23 | * lines of this file. Under no circumstances is the author 24 | * responsible for the proper functioning of this software, nor does 25 | * the author assume any responsibility for damages incurred with 26 | * its use. 27 | * 28 | *************************************************************************** 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include /* XXX for _POSIX_VERSION ifdefs */ 36 | 37 | #if HAVE_STRINGS_H 38 | #include 39 | #endif 40 | 41 | #if !defined sgi && !defined _POSIX_VERSION 42 | #include 43 | #endif 44 | 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | int alphasort(const void *dirent1, const void *dirent2) { 51 | return(strcmp((*(const struct dirent **)dirent1)->d_name, 52 | (*(const struct dirent **)dirent2)->d_name)); 53 | } 54 | -------------------------------------------------------------------------------- /replace/daemon.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * 3 | * daemon - replacement for daemon function. 4 | * 5 | * Matt Soffen 6 | * Copyright (C) 2004 Matt Soffen 7 | * 8 | * Taken from the FreeBSD file (with copyright notice) 9 | * ------------------------------------------------------------ 10 | * Copyright (c) 1990, 1993 11 | * The Regents of the University of California. All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in the 20 | * documentation and/or other materials provided with the distribution. 21 | * 3. All advertising materials mentioning features or use of this software 22 | * must display the following acknowledgement: 23 | * This product includes software developed by the University of 24 | * California, Berkeley and its contributors. 25 | * 4. Neither the name of the University nor the names of its contributors 26 | * may be used to endorse or promote products derived from this software 27 | * without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 30 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 | * SUCH DAMAGE. 40 | * 41 | * $FreeBSD: src/lib/libc/gen/daemon.c,v 1.3 2000/01/27 23:06:14 jasone Exp $ 42 | * 43 | */ 44 | 45 | #if defined(LIBC_SCCS) && !defined(lint) 46 | static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93"; 47 | #endif /* LIBC_SCCS and not lint */ 48 | 49 | #include 50 | 51 | #include 52 | #include 53 | 54 | int 55 | daemon(nochdir, noclose) 56 | int nochdir, noclose; 57 | { 58 | int fd; 59 | 60 | switch (fork()) { 61 | case -1: 62 | return (-1); 63 | case 0: 64 | break; 65 | default: 66 | _exit(0); 67 | } 68 | 69 | if (setsid() == -1) 70 | return (-1); 71 | 72 | if (!nochdir) 73 | (void)chdir("/"); 74 | 75 | if (!noclose && (fd = _open("/dev/null", O_RDWR, 0)) != -1) { 76 | (void)dup2(fd, STDIN_FILENO); 77 | (void)dup2(fd, STDOUT_FILENO); 78 | (void)dup2(fd, STDERR_FILENO); 79 | if (fd > 2) 80 | (void)_close(fd); 81 | } 82 | return (0); 83 | } 84 | -------------------------------------------------------------------------------- /replace/scandir.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterLabs/pacemaker-mgmt/236fee1215849cb010a0dbac62c9d64cac80fc6b/replace/scandir.c -------------------------------------------------------------------------------- /replace/setenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2001 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | */ 21 | #include 22 | #include 23 | #include 24 | 25 | /* 26 | * Small replacement function for setenv() 27 | */ 28 | int 29 | setenv(const char *name, const char * value, int why) 30 | { 31 | int rc = -1; 32 | 33 | if ( name && value ) { 34 | char * envp = NULL; 35 | envp = malloc(strlen(name)+strlen(value)+2); 36 | if (envp) { 37 | /* 38 | * Unfortunately, the putenv API guarantees memory leaks when 39 | * changing environment variables repeatedly... :-( 40 | */ 41 | 42 | sprintf(envp, "%s=%s", name, value); 43 | 44 | /* Cannot free envp (!) */ 45 | rc = putenv(envp); 46 | } 47 | 48 | } 49 | return(rc); 50 | } 51 | -------------------------------------------------------------------------------- /replace/strerror.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of version 2.1 of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | */ 19 | #include 20 | #include 21 | #include 22 | extern const char * sys_err[]; 23 | extern int sys_nerr; 24 | char * 25 | strerror(int errnum) 26 | { 27 | static char whaterr[32]; 28 | 29 | if (errnum < 0) { 30 | return "negative errno"; 31 | } 32 | if (errnum >= sys_nerr) { 33 | snprintf(whaterr, sizeof(whaterr),"error %d", errnum); 34 | return whaterr; 35 | } 36 | return sys_err[sys_nerr]; 37 | } 38 | -------------------------------------------------------------------------------- /replace/strlcat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /* 4 | * Copyright (C) 2007 Alan Robertson 5 | * This software licensed under the GNU LGPL. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | size_t 24 | strlcat(char *dest, const char * src, size_t maxlen) 25 | { 26 | size_t curlen = strlen(dest); 27 | size_t addlen = strlen(src); 28 | size_t appendlen = (maxlen-1) - curlen; 29 | if (appendlen > 0) { 30 | strlcpy(dest+curlen, src, maxlen-curlen); 31 | } 32 | return curlen + addlen; 33 | } 34 | -------------------------------------------------------------------------------- /replace/strlcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /* 4 | * Copyright (C) 2007 Alan Robertson 5 | * This software licensed under the GNU LGPL. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | size_t 24 | strlcpy(char *dest, const char * src, size_t maxlen) 25 | { 26 | size_t srclen = strlen(src); 27 | if (maxlen > 0) { 28 | strncpy(dest, src, maxlen); 29 | dest[maxlen-1]=EOS; 30 | } 31 | return srclen; 32 | } 33 | -------------------------------------------------------------------------------- /replace/strndup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | /* 5 | * Copyright (C) 2004 Matt Soffen 6 | * This software licensed under the GNU LGPL. 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | */ 23 | 24 | /* Taken from the GlibC implementation of strndup */ 25 | 26 | char *strndup(const char *str, size_t len) 27 | { 28 | size_t n = strnlen(str,len); 29 | char *new = (char *) malloc (len+1); 30 | 31 | if (NULL == new) { 32 | return NULL; 33 | } 34 | 35 | new[n] = '\0'; 36 | return (char *)memcpy (new, str, len); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /replace/strnlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /* 4 | * Copyright (C) 2003 Alan Robertson 5 | * This software licensed under the GNU LGPL. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | size_t 24 | strnlen(const char *s, size_t maxlen) 25 | { 26 | const char * eospos; 27 | 28 | eospos = memchr(s, (int)'\0', maxlen); 29 | 30 | return (eospos == NULL ? maxlen : (size_t)(eospos-s)); 31 | } 32 | -------------------------------------------------------------------------------- /replace/unsetenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2001 Alan Robertson 3 | * This software licensed under the GNU LGPL. 4 | * 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #define __environ environ 29 | #ifndef HAVE_ENVIRON_DECL 30 | extern char **environ; 31 | #endif 32 | 33 | int 34 | unsetenv (const char *name) 35 | { 36 | const size_t len = strlen (name); 37 | char **ep; 38 | 39 | for (ep = __environ; *ep; ++ep) { 40 | if (!strncmp (*ep, name, len) && (*ep)[len] == '=') { 41 | /* Found it. */ 42 | /* Remove this pointer by moving later ones back. */ 43 | char **dp = ep; 44 | do 45 | dp[0] = dp[1]; 46 | while (*dp++); 47 | /* Continue the loop in case NAME appears again. */ 48 | } 49 | } 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /snmp_subagent/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile.in 2 | Makefile 3 | .deps 4 | .libs 5 | *.la 6 | *.lo 7 | .*.swp 8 | hbagent 9 | *.beam 10 | MISC_ERRORS 11 | parser-messages 12 | SNMPAgentSanityCheck 13 | *.beam 14 | parser-messages 15 | MISC_ERRORS 16 | -------------------------------------------------------------------------------- /snmp_subagent/LHAClusterInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.scalar.conf,v 1.7 2003/04/08 14:57:04 dts12 Exp $ 4 | */ 5 | #ifndef LHACLUSTERINFO_H 6 | #define LHACLUSTERINFO_H 7 | 8 | /* function declarations */ 9 | void init_LHAClusterInfo(void); 10 | Netsnmp_Node_Handler handle_LHAResourceGroupCount; 11 | Netsnmp_Node_Handler handle_LHACurrentNodeID; 12 | Netsnmp_Node_Handler handle_LHALiveNodeCount; 13 | Netsnmp_Node_Handler handle_LHATotalNodeCount; 14 | 15 | #endif /* LHACLUSTERINFO_H */ 16 | -------------------------------------------------------------------------------- /snmp_subagent/LHAHeartbeatConfigInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.scalar.conf,v 1.7 2003/04/08 14:57:04 dts12 Exp $ 4 | */ 5 | #ifndef LHAHEARTBEATCONFIGINFO_H 6 | #define LHAHEARTBEATCONFIGINFO_H 7 | 8 | /* function declarations */ 9 | void init_LHAHeartbeatConfigInfo(void); 10 | Netsnmp_Node_Handler handle_LHAHBVersion; 11 | Netsnmp_Node_Handler handle_LHAAPIAuth; 12 | Netsnmp_Node_Handler handle_LHADebugFile; 13 | Netsnmp_Node_Handler handle_LHADebug; 14 | Netsnmp_Node_Handler handle_LHAHOPFudge; 15 | Netsnmp_Node_Handler handle_LHARespawn; 16 | Netsnmp_Node_Handler handle_LHADeadTime; 17 | Netsnmp_Node_Handler handle_LHAInitDead; 18 | Netsnmp_Node_Handler handle_LHAUDPPort; 19 | Netsnmp_Node_Handler handle_LHALogFile; 20 | Netsnmp_Node_Handler handle_LHAStonith; 21 | Netsnmp_Node_Handler handle_LHABaudRate; 22 | Netsnmp_Node_Handler handle_LHNiceFailBack; 23 | Netsnmp_Node_Handler handle_LHARTPriority; 24 | Netsnmp_Node_Handler handle_LHAMsgFmt; 25 | Netsnmp_Node_Handler handle_LHARealTime; 26 | Netsnmp_Node_Handler handle_LHAStonithHost; 27 | Netsnmp_Node_Handler handle_LHANormalPoll; 28 | Netsnmp_Node_Handler handle_LHAGenMethod; 29 | Netsnmp_Node_Handler handle_LHAWarnTime; 30 | Netsnmp_Node_Handler handle_LHADeadPing; 31 | Netsnmp_Node_Handler handle_LHAKeepAlive; 32 | Netsnmp_Node_Handler handle_LHAWatchdogTimer; 33 | Netsnmp_Node_Handler handle_LHALogFacility; 34 | Netsnmp_Node_Handler handle_LHAutoFailBack; 35 | 36 | #endif /* LHAHEARTBEATCONFIGINFO_H */ 37 | -------------------------------------------------------------------------------- /snmp_subagent/LHAIFStatusTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.iterate.conf,v 5.9 2003/06/04 00:14:41 hardaker Exp $ 4 | */ 5 | #ifndef LHAIFSTATUSTABLE_H 6 | #define LHAIFSTATUSTABLE_H 7 | 8 | /* function declarations */ 9 | void init_LHAIFStatusTable(void); 10 | void initialize_table_LHAIFStatusTable(void); 11 | Netsnmp_Node_Handler LHAIFStatusTable_handler; 12 | 13 | Netsnmp_First_Data_Point LHAIFStatusTable_get_first_data_point; 14 | Netsnmp_Next_Data_Point LHAIFStatusTable_get_next_data_point; 15 | 16 | /* column number definitions for table LHAIFStatusTable */ 17 | #include "LHAIFStatusTable_columns.h" 18 | 19 | /* enum definions */ 20 | #include "LHAIFStatusTable_enums.h" 21 | 22 | #endif /* LHAIFSTATUSTABLE_H */ 23 | -------------------------------------------------------------------------------- /snmp_subagent/LHAIFStatusTable_columns.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_defines.conf,v 5.1 2002/05/08 05:42:47 hardaker Exp $ 4 | */ 5 | #ifndef LHAIFSTATUSTABLE_COLUMNS_H 6 | #define LHAIFSTATUSTABLE_COLUMNS_H 7 | 8 | /* column number definitions for table LHAIFStatusTable */ 9 | #define COLUMN_LHAIFINDEX 1 10 | #define COLUMN_LHAIFNAME 2 11 | #define COLUMN_LHAIFSTATUS 3 12 | #endif /* LHAIFSTATUSTABLE_COLUMNS_H */ 13 | -------------------------------------------------------------------------------- /snmp_subagent/LHAIFStatusTable_enums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_enums.conf,v 5.2 2003/02/22 04:09:25 hardaker Exp $ 4 | */ 5 | #ifndef LHAIFSTATUSTABLE_ENUMS_H 6 | #define LHAIFSTATUSTABLE_ENUMS_H 7 | 8 | /* enums for column LHAIFStatus */ 9 | #define LHAIFSTATUS_UNKNOWN 0 10 | #define LHAIFSTATUS_UP 1 11 | #define LHAIFSTATUS_DOWN 2 12 | 13 | #endif /* LHAIFSTATUSTABLE_ENUMS_H */ 14 | -------------------------------------------------------------------------------- /snmp_subagent/LHAMembershipTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.iterate.conf,v 5.9 2003/06/04 00:14:41 hardaker Exp $ 4 | */ 5 | #ifndef LHAMEMBERSHIPTABLE_H 6 | #define LHAMEMBERSHIPTABLE_H 7 | 8 | /* function declarations */ 9 | void init_LHAMembershipTable(void); 10 | void initialize_table_LHAMembershipTable(void); 11 | Netsnmp_Node_Handler LHAMembershipTable_handler; 12 | 13 | Netsnmp_First_Data_Point LHAMembershipTable_get_first_data_point; 14 | Netsnmp_Next_Data_Point LHAMembershipTable_get_next_data_point; 15 | 16 | /* column number definitions for table LHAMembershipTable */ 17 | #include "LHAMembershipTable_columns.h" 18 | 19 | /* enum definions */ 20 | #include "LHAMembershipTable_enums.h" 21 | 22 | #endif /* LHAMEMBERSHIPTABLE_H */ 23 | -------------------------------------------------------------------------------- /snmp_subagent/LHAMembershipTable_columns.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_defines.conf,v 5.1 2002/05/08 05:42:47 hardaker Exp $ 4 | */ 5 | #ifndef LHAMEMBERSHIPTABLE_COLUMNS_H 6 | #define LHAMEMBERSHIPTABLE_COLUMNS_H 7 | 8 | /* column number definitions for table LHAMembershipTable */ 9 | #define COLUMN_LHAMEMBERINDEX 1 10 | #define COLUMN_LHAMEMBERNAME 2 11 | #define COLUMN_LHAMEMBERADDRESS 3 12 | #define COLUMN_LHAMEMBERCLUSTERNAME 4 13 | #define COLUMN_LHAMEMBERISMEMBER 5 14 | #define COLUMN_LHAMEMBERLASTCHANGE 6 15 | #define COLUMN_LHAMEMBERBOOTTIME 7 16 | #endif /* LHAMEMBERSHIPTABLE_COLUMNS_H */ 17 | -------------------------------------------------------------------------------- /snmp_subagent/LHAMembershipTable_enums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_enums.conf,v 5.2 2003/02/22 04:09:25 hardaker Exp $ 4 | */ 5 | #ifndef LHAMEMBERSHIPTABLE_ENUMS_H 6 | #define LHAMEMBERSHIPTABLE_ENUMS_H 7 | 8 | /* enums for column LHAMemberIsMember */ 9 | #define LHAMEMBERISMEMBER_TRUE 1 10 | #define LHAMEMBERISMEMBER_FALSE 2 11 | 12 | /* enums for column LHAMemberLastChange */ 13 | #define LHAMEMBERLASTCHANGE_UNDEFINED 0 14 | #define LHAMEMBERLASTCHANGE_NOCHANGE 1 15 | #define LHAMEMBERLASTCHANGE_JOINED 2 16 | #define LHAMEMBERLASTCHANGE_LEFT 3 17 | 18 | #endif /* LHAMEMBERSHIPTABLE_ENUMS_H */ 19 | -------------------------------------------------------------------------------- /snmp_subagent/LHANodeTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.iterate.conf,v 5.9 2003/06/04 00:14:41 hardaker Exp $ 4 | */ 5 | #ifndef LHANODETABLE_H 6 | #define LHANODETABLE_H 7 | 8 | /* function declarations */ 9 | void init_LHANodeTable(void); 10 | void initialize_table_LHANodeTable(void); 11 | Netsnmp_Node_Handler LHANodeTable_handler; 12 | 13 | Netsnmp_First_Data_Point LHANodeTable_get_first_data_point; 14 | Netsnmp_Next_Data_Point LHANodeTable_get_next_data_point; 15 | 16 | /* column number definitions for table LHANodeTable */ 17 | #include "LHANodeTable_columns.h" 18 | 19 | /* enum definions */ 20 | #include "LHANodeTable_enums.h" 21 | 22 | #endif /* LHANODETABLE_H */ 23 | -------------------------------------------------------------------------------- /snmp_subagent/LHANodeTable_columns.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_defines.conf,v 5.1 2002/05/08 05:42:47 hardaker Exp $ 4 | */ 5 | #ifndef LHANODETABLE_COLUMNS_H 6 | #define LHANODETABLE_COLUMNS_H 7 | 8 | /* column number definitions for table LHANodeTable */ 9 | #define COLUMN_LHANODEINDEX 1 10 | #define COLUMN_LHANODENAME 2 11 | #define COLUMN_LHANODETYPE 3 12 | #define COLUMN_LHANODESTATUS 4 13 | #define COLUMN_LHANODEUUID 5 14 | #define COLUMN_LHANODEIFCOUNT 6 15 | #endif /* LHANODETABLE_COLUMNS_H */ 16 | -------------------------------------------------------------------------------- /snmp_subagent/LHANodeTable_enums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_enums.conf,v 5.2 2003/02/22 04:09:25 hardaker Exp $ 4 | */ 5 | #ifndef LHANODETABLE_ENUMS_H 6 | #define LHANODETABLE_ENUMS_H 7 | 8 | /* enums for column LHANodeType */ 9 | #define LHANODETYPE_UNKNOWN 0 10 | #define LHANODETYPE_NORMAL 1 11 | #define LHANODETYPE_PING 2 12 | 13 | /* enums for column LHANodeStatus */ 14 | #define LHANODESTATUS_UNKNOWN 0 15 | #define LHANODESTATUS_INIT 1 16 | #define LHANODESTATUS_UP 2 17 | #define LHANODESTATUS_ACTIVE 3 18 | #define LHANODESTATUS_DEAD 4 19 | 20 | #endif /* LHANODETABLE_ENUMS_H */ 21 | -------------------------------------------------------------------------------- /snmp_subagent/LHAResourceGroupTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.iterate.conf,v 5.9 2003/06/04 00:14:41 hardaker Exp $ 4 | */ 5 | #ifndef LHARESOURCEGROUPTABLE_H 6 | #define LHARESOURCEGROUPTABLE_H 7 | 8 | /* function declarations */ 9 | void init_LHAResourceGroupTable(void); 10 | void initialize_table_LHAResourceGroupTable(void); 11 | Netsnmp_Node_Handler LHAResourceGroupTable_handler; 12 | 13 | Netsnmp_First_Data_Point LHAResourceGroupTable_get_first_data_point; 14 | Netsnmp_Next_Data_Point LHAResourceGroupTable_get_next_data_point; 15 | 16 | /* column number definitions for table LHAResourceGroupTable */ 17 | #include "LHAResourceGroupTable_columns.h" 18 | 19 | /* enum definions */ 20 | #include "LHAResourceGroupTable_enums.h" 21 | 22 | #endif /* LHARESOURCEGROUPTABLE_H */ 23 | -------------------------------------------------------------------------------- /snmp_subagent/LHAResourceGroupTable_columns.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_defines.conf,v 5.1 2002/05/08 05:42:47 hardaker Exp $ 4 | */ 5 | #ifndef LHARESOURCEGROUPTABLE_COLUMNS_H 6 | #define LHARESOURCEGROUPTABLE_COLUMNS_H 7 | 8 | /* column number definitions for table LHAResourceGroupTable */ 9 | #define COLUMN_LHARESOURCEGROUPINDEX 1 10 | #define COLUMN_LHARESOURCEGROUPMASTER 2 11 | #define COLUMN_LHARESOURCEGROUPRESOURCES 3 12 | #define COLUMN_LHARESOURCEGROUPSTATUS 4 13 | #endif /* LHARESOURCEGROUPTABLE_COLUMNS_H */ 14 | -------------------------------------------------------------------------------- /snmp_subagent/LHAResourceGroupTable_enums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_enums.conf,v 5.2 2003/02/22 04:09:25 hardaker Exp $ 4 | */ 5 | #ifndef LHARESOURCEGROUPTABLE_ENUMS_H 6 | #define LHARESOURCEGROUPTABLE_ENUMS_H 7 | 8 | #endif /* LHARESOURCEGROUPTABLE_ENUMS_H */ 9 | -------------------------------------------------------------------------------- /snmp_subagent/LHAResourceStatusUpdate.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.notify.conf,v 5.2.2.1 2004/04/15 12:29:06 dts12 Exp $ 4 | */ 5 | #include 6 | 7 | #include "hbagent.h" 8 | #include "hbagentv2.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include "LHAResourceStatusUpdate.h" 14 | 15 | 16 | 17 | static oid snmptrap_oid[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }; 18 | 19 | int 20 | send_LHAResourceStatusUpdate_trap(struct hb_rsinfov2 *resource) 21 | { 22 | netsnmp_variable_list *var_list = NULL; 23 | oid LHAResourceStatusUpdate_oid[] = 24 | { 1, 3, 6, 1, 4, 1, 4682, 900, 11 }; 25 | oid LHAResourceName_oid[] = 26 | { 1, 3, 6, 1, 4, 1, 4682, 8, 1, 2, /* insert index here */ }; 27 | oid LHAResourceNode_oid[] = 28 | { 1, 3, 6, 1, 4, 1, 4682, 8, 1, 4, /* insert index here */ }; 29 | oid LHAResourceStatus_oid[] = 30 | { 1, 3, 6, 1, 4, 1, 4682, 8, 1, 5, /* insert index here */ }; 31 | 32 | 33 | /* 34 | * Set the snmpTrapOid.0 value 35 | */ 36 | snmp_varlist_add_variable(&var_list, 37 | snmptrap_oid, OID_LENGTH(snmptrap_oid), 38 | ASN_OBJECT_ID, 39 | (u_char *)LHAResourceStatusUpdate_oid, 40 | sizeof(LHAResourceStatusUpdate_oid)); 41 | 42 | /* 43 | * Add any objects from the trap definition 44 | */ 45 | snmp_varlist_add_variable(&var_list, 46 | LHAResourceName_oid, 47 | OID_LENGTH(LHAResourceName_oid), 48 | ASN_OCTET_STR, 49 | /* 50 | * Set an appropriate value for LHAResourceName 51 | */ 52 | (u_char *)resource->resourceid, 53 | strlen(resource->resourceid)); 54 | snmp_varlist_add_variable(&var_list, 55 | LHAResourceNode_oid, 56 | OID_LENGTH(LHAResourceNode_oid), 57 | ASN_OCTET_STR, 58 | /* 59 | * Set an appropriate value for LHAResourceNode 60 | */ 61 | (u_char *)resource->node, 62 | strlen(resource->node)); 63 | snmp_varlist_add_variable(&var_list, 64 | LHAResourceStatus_oid, 65 | OID_LENGTH(LHAResourceStatus_oid), 66 | ASN_INTEGER, 67 | /* 68 | * Set an appropriate value for LHAResourceStatus 69 | */ 70 | (u_char *)&(resource->status), 71 | sizeof(resource->status)); 72 | 73 | /* 74 | * Add any extra (optional) objects here 75 | */ 76 | 77 | /* 78 | * Send the trap to the list of configured destinations 79 | * and clean up 80 | */ 81 | send_v2trap(var_list); 82 | snmp_free_varbind(var_list); 83 | 84 | return SNMP_ERR_NOERROR; 85 | } 86 | -------------------------------------------------------------------------------- /snmp_subagent/LHAResourceStatusUpdate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.notify.conf,v 5.2.2.1 2004/04/15 12:29:06 dts12 Exp $ 4 | */ 5 | #ifndef LHARESOURCESTATUSUPDATE_H 6 | #define LHARESOURCESTATUSUPDATE_H 7 | 8 | 9 | /* 10 | * function declarations 11 | */ 12 | int send_LHAResourceStatusUpdate_trap(struct hb_rsinfov2 *resource); 13 | 14 | #endif /* LHARESOURCESTATUSUPDATE_H */ 15 | -------------------------------------------------------------------------------- /snmp_subagent/LHAResourceTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.iterate.conf,v 5.9 2003/06/04 00:14:41 hardaker Exp $ 4 | */ 5 | #ifndef LHARESOURCETABLE_H 6 | #define LHARESOURCETABLE_H 7 | 8 | /* 9 | * function declarations 10 | */ 11 | void init_LHAResourceTable(void); 12 | void initialize_table_LHAResourceTable(void); 13 | Netsnmp_Node_Handler LHAResourceTable_handler; 14 | 15 | Netsnmp_First_Data_Point LHAResourceTable_get_first_data_point; 16 | Netsnmp_Next_Data_Point LHAResourceTable_get_next_data_point; 17 | 18 | /* 19 | * column number definitions for table LHAResourceTable 20 | */ 21 | #include "LHAResourceTable_columns.h" 22 | 23 | /* 24 | * enum definions 25 | */ 26 | #include "LHAResourceTable_enums.h" 27 | 28 | #endif /* LHARESOURCETABLE_H */ 29 | -------------------------------------------------------------------------------- /snmp_subagent/LHAResourceTable_columns.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_defines.conf,v 5.1 2002/05/08 05:42:47 hardaker Exp $ 4 | */ 5 | #ifndef LHARESOURCETABLE_COLUMNS_H 6 | #define LHARESOURCETABLE_COLUMNS_H 7 | 8 | /* 9 | * column number definitions for table LHAResourceTable 10 | */ 11 | #define COLUMN_LHARESOURCEINDEX 1 12 | #define COLUMN_LHARESOURCENAME 2 13 | #define COLUMN_LHARESOURCETYPE 3 14 | #define COLUMN_LHARESOURCENODE 4 15 | #define COLUMN_LHARESOURCESTATUS 5 16 | #define COLUMN_LHARESOURCEISMANAGED 6 17 | #define COLUMN_LHARESOURCEFAILCOUNT 7 18 | #define COLUMN_LHARESOURCEPARENT 8 19 | #endif /* LHARESOURCETABLE_COLUMNS_H */ 20 | -------------------------------------------------------------------------------- /snmp_subagent/LHAResourceTable_enums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this file originally auto-generated by mib2c using 3 | * : mib2c.column_enums.conf,v 5.2 2003/02/22 04:09:25 hardaker Exp $ 4 | */ 5 | #ifndef LHARESOURCETABLE_ENUMS_H 6 | #define LHARESOURCETABLE_ENUMS_H 7 | 8 | /* 9 | * enums for column LHAResourceType 10 | */ 11 | #define LHARESOURCETYPE_UNKNOWN 0 12 | #define LHARESOURCETYPE_PRIMITIVE 1 13 | #define LHARESOURCETYPE_GROUP 2 14 | #define LHARESOURCETYPE_CLONE 3 15 | #define LHARESOURCETYPE_MASTERSLAVE 4 16 | 17 | /* 18 | * enums for column LHAResourceStatus 19 | */ 20 | #define LHARESOURCESTATUS_UNKNOWN 0 21 | #define LHARESOURCESTATUS_STOPPED 1 22 | #define LHARESOURCESTATUS_STARTED 2 23 | #define LHARESOURCESTATUS_SLAVE 3 24 | #define LHARESOURCESTATUS_MASTER 4 25 | 26 | /* 27 | * enums for column LHAResourceIsManaged 28 | */ 29 | #define LHARESOURCEISMANAGED_UNMANAGED 0 30 | #define LHARESOURCEISMANAGED_MANAGED 1 31 | 32 | #endif /* LHARESOURCETABLE_ENUMS_H */ 33 | -------------------------------------------------------------------------------- /snmp_subagent/Makefile.am: -------------------------------------------------------------------------------- 1 | # Linux-HA: SNMP Subagent 2 | # 3 | # Copyright (C) 2002 Yixiong Zou (yixiong.zou@intel.com) 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | # 19 | 20 | MAINTAINERCLEANFILES = Makefile.in 21 | 22 | hbagent_srces = snmp-config-resolve.h \ 23 | hbagent.h \ 24 | hbagent.c \ 25 | hbagentv2.h \ 26 | hbagentv2.c \ 27 | LHANodeTable.h \ 28 | LHANodeTable_columns.h \ 29 | LHANodeTable_enums.h \ 30 | LHANodeTable.c \ 31 | LHAClusterInfo.h \ 32 | LHAClusterInfo.c \ 33 | LHAIFStatusTable.h \ 34 | LHAIFStatusTable_enums.h \ 35 | LHAIFStatusTable_columns.h \ 36 | LHAIFStatusTable.c \ 37 | LHAMembershipTable_columns.h \ 38 | LHAMembershipTable_enums.h \ 39 | LHAMembershipTable.h \ 40 | LHAMembershipTable.c \ 41 | LHAHeartbeatConfigInfo.c \ 42 | LHAHeartbeatConfigInfo.h \ 43 | LHAResourceGroupTable_columns.h \ 44 | LHAResourceGroupTable_enums.h \ 45 | LHAResourceGroupTable.h \ 46 | LHAResourceGroupTable.c \ 47 | LHAResourceTable_columns.h \ 48 | LHAResourceTable_enums.h \ 49 | LHAResourceTable.h \ 50 | LHAResourceTable.c \ 51 | LHAResourceStatusUpdate.h \ 52 | LHAResourceStatusUpdate.c 53 | 54 | test_scrs = SNMPAgentSanityCheck 55 | 56 | 57 | mibsdir = @MIBS_DIR@ 58 | mibs_DATA = LINUX-HA-MIB.txt 59 | DIST_LIST = SNMPAgentSanityCheck.in $(mibs_DATA) 60 | 61 | EXTRA_DIST = $(DIST_LIST) 62 | 63 | docdir = $(datadir)/doc/packages/@PKG_NAME@ 64 | doc_DATA = README.hbagent README.hbagentv2 65 | 66 | INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ 67 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl 68 | 69 | halibdir = $(libdir)/@HB_PKG@ 70 | 71 | # binary programs 72 | halib_PROGRAMS = hbagent 73 | 74 | hbagent_SOURCES = $(hbagent_srces) 75 | 76 | hbagent_LDADD = \ 77 | -lplumb -lcrmcommon -lcib -lpe_status \ 78 | $(CLUSTERLIBS) $(CURSESLIBS) $(GLIBLIB) 79 | 80 | if !BUILD_HEARTBEAT_SUPPORT 81 | hbagent_LDADD += -lcrmcluster 82 | endif 83 | hbagent_LDFLAGS = @SNMPAGENTLIB@ 84 | 85 | # test cases 86 | testdir = $(HA_LIBHBDIR) 87 | test_SCRIPTS = $(test_scrs) 88 | 89 | hadir = $(sysconfdir)/ha.d 90 | 91 | AM_CFLAGS = @CFLAGS@ 92 | -------------------------------------------------------------------------------- /snmp_subagent/hbagent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hbagent.h: heartbeat snmp subagnet header file. 3 | * 4 | * Copyright (c) 2004 Intel Corp. 5 | * 6 | * Author: Zou Yixiong (yixiong.zou@intel.com) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | * 22 | */ 23 | 24 | #ifndef __hasubagent_h__ 25 | #define __hasubagent_h__ 26 | 27 | #include 28 | #ifdef HAVE_STDINT_H 29 | #include 30 | #endif 31 | 32 | #include 33 | 34 | #if SUPPORT_HEARTBEAT 35 | #include "saf/ais.h" 36 | #endif 37 | 38 | #include "snmp-config-resolve.h" 39 | #include 40 | 41 | #define CACHE_TIME_OUT 5 42 | #define LHAAGENTID "lha-snmpagent" 43 | #define DEFAULT_TIME_OUT 5 /* default timeout value for snmp in sec. */ 44 | 45 | typedef enum lha_group { 46 | LHA_CLUSTERINFO, 47 | LHA_NODEINFO, 48 | LHA_IFSTATUSINFO, 49 | LHA_RESOURCEINFO, 50 | LHA_MEMBERSHIPINFO, 51 | LHA_HBCONFIGINFO, 52 | } lha_group_t; 53 | 54 | typedef enum lha_attribute { 55 | /* LHA_CLUSTERINFO stats */ 56 | TOTAL_NODE_COUNT, 57 | LIVE_NODE_COUNT, 58 | RESOURCE_GROUP_COUNT, 59 | CURRENT_NODE_ID, 60 | 61 | /* LHA_RESOURCEINFO stats */ 62 | RESOURCE_STATUS, 63 | } lha_attribute_t; 64 | 65 | 66 | int get_int_value(lha_group_t group, lha_attribute_t attr, size_t index, uint32_t * value); 67 | 68 | int get_str_value(lha_group_t group, lha_attribute_t attr, size_t index, char * * value); 69 | 70 | int clusterinfo_get_int_value(lha_attribute_t attr, size_t index, uint32_t * value); 71 | 72 | int rsinfo_get_int_value(lha_attribute_t attr, size_t index, uint32_t * value); 73 | 74 | 75 | /* LHAHeartbeatConfigInfo partial-mode */ 76 | typedef enum lha_hbconfig { 77 | LHA_CONF_HBVERSION, 78 | LHA_CONF_KEEPALIVE, 79 | LHA_CONF_DEADTIME, 80 | LHA_CONF_DEADPING, 81 | LHA_CONF_WARNTIME, 82 | LHA_CONF_INITDEAD, 83 | LHA_CONF_BAUDRATE, 84 | LHA_CONF_AUTOFAIL, 85 | LHA_CONF_STONITH, 86 | LHA_CONF_STONITHHOST, 87 | LHA_CONF_RESPAWN, 88 | LHA_CONF_END 89 | } lha_hbconfig_t; 90 | 91 | int hbconfig_get_str(lha_hbconfig_t attr_no, char * * value); 92 | 93 | 94 | GPtrArray * get_hb_info(lha_group_t group); 95 | 96 | struct hb_nodeinfo { 97 | size_t id; 98 | char * name; 99 | uint32_t type; 100 | uint32_t status; 101 | size_t ifcount; 102 | cl_uuid_t uuid; 103 | }; 104 | 105 | struct hb_ifinfo { 106 | size_t id; 107 | size_t nodeid; 108 | char * name; 109 | char * node; 110 | uint32_t status; 111 | }; 112 | 113 | struct hb_rsinfo { 114 | size_t id; 115 | size_t masternodeid; 116 | char * resource; 117 | uint32_t status; 118 | }; 119 | 120 | #endif /* __hasubagent_h__ */ 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /snmp_subagent/hbagentv2.h: -------------------------------------------------------------------------------- 1 | #ifndef _HBAGENTV2_H 2 | #define _HBAGENTV2_H 3 | 4 | 5 | 6 | struct hb_rsinfov2 { 7 | size_t index; 8 | char * resourceid; 9 | uint32_t type; 10 | uint32_t status; 11 | char * node; 12 | uint32_t is_managed; 13 | uint32_t failcount; 14 | char * parent; 15 | }; 16 | 17 | int init_hbagentv2(int *cib_fd); 18 | void free_hbagentv2(void); 19 | 20 | int get_cib_fd(void); 21 | int handle_cib_msg(void); 22 | 23 | int init_resource_table_v2(void); 24 | int update_resource_table_v2(void); 25 | GPtrArray *get_resource_table_v2(void); 26 | void free_resource_table_v2(void); 27 | 28 | #endif /* _HBAGENTV2_H */ 29 | -------------------------------------------------------------------------------- /snmp_subagent/snmp-config-resolve.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Intel Corp. 3 | * 4 | * Author: Zou Yixiong (yixiong.zou@intel.com) 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | */ 21 | 22 | 23 | #ifndef __SNMP_CONFIG_RESOLVE_H 24 | #define __SNMP_CONFIG_RESOLVE_H 25 | 26 | /* the following undef is needed because these values 27 | are defined in both the config.h for linux-ha and 28 | net-snmp. So they created a conflict. To resolve 29 | this, we include the net-snmp-config.h first, and 30 | include this file before we include other heartbeat 31 | header files. */ 32 | 33 | #ifdef PACKAGE_BUGREPORT 34 | #undef PACKAGE_BUGREPORT 35 | #endif 36 | 37 | #ifdef PACKAGE_NAME 38 | #undef PACKAGE_NAME 39 | #endif 40 | 41 | #ifdef PACKAGE_STRING 42 | #undef PACKAGE_STRING 43 | #endif 44 | 45 | #ifdef PACKAGE_TARNAME 46 | #undef PACKAGE_TARNAME 47 | #endif 48 | 49 | #ifdef PACKAGE_VERSION 50 | #undef PACKAGE_VERSION 51 | #endif 52 | 53 | #endif /* __SNMP_CONFIG_RESOLVE_H */ 54 | -------------------------------------------------------------------------------- /tsa_plugin/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | linuxha-adapter 4 | testrun.sh 5 | -------------------------------------------------------------------------------- /tsa_plugin/Makefile.am: -------------------------------------------------------------------------------- 1 | # Linux-HA: TSA plugin 2 | # 3 | # Author: Jia Ming Pan 4 | # Copyright (c) 2006 International Business Machines 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | # 20 | 21 | 22 | TSA_LIBDIR=$(TSA_DIR)/sam/lib 23 | CLASSPATH=.:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar:${TSA_LIBDIR}/eezadapter.jar:${TSA_LIBDIR}/jlanclient.jar:${TSA_LIBDIR}/eezcfghelp.jar:${TSA_LIBDIR}/jlog.jar:${TSA_LIBDIR}/eezmsgs.jar:${TSA_LIBDIR}/log.jar:${TSA_LIBDIR}/eezmsgs_lang.jar:${TSA_LIBDIR}/remoteaccess.jar:${TSA_LIBDIR}/eezpolldr.jar:${TSA_LIBDIR}/samfla.jar:${TSA_LIBDIR}/eezsdk.jar:${TSA_LIBDIR}/sammsgs.jar:${TSA_LIBDIR}/eezutils.jar:${TSA_LIBDIR}/sampolicy.jar:${TSA_LIBDIR}/evd.jar:${TSA_LIBDIR}/samrmc.jar:${TSA_LIBDIR}/jffdc.jar:${TSA_LIBDIR}/ssh.jar:${TSA_LIBDIR}/jhall.jar:${TSA_LIBDIR}/tivolicommondir.jar 24 | 25 | INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ 26 | -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ 27 | -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ 28 | -I$(CMPI_HEADER_PATH) 29 | 30 | 31 | COMMONLIBS = $(top_builddir)/lib/clplumbing/libplumb.la \ 32 | $(top_builddir)/lib/hbclient/libhbclient.la \ 33 | $(top_builddir)/membership/ccm/libccmclient.la \ 34 | $(top_builddir)/membership/ccm/libclm.la \ 35 | $(GLIBLIB) 36 | 37 | LRM_DIR = lrm 38 | MGMTLIBS = $(top_builddir)/mgmt/daemon/libhbmgmt.la \ 39 | $(top_builddir)/lib/mgmt/libhbmgmtcommon.la \ 40 | $(top_builddir)/lib/$(LRM_DIR)/liblrm.la 41 | 42 | hamgmtlibdir = /usr/lib 43 | hamgmtlib_LTLIBRARIES = liblhamgmt.la 44 | 45 | jardir = $(TSA_LIBDIR) 46 | jar_DATA = linuxhafla.jar 47 | 48 | swig_gen_files = ${JAVA_PACKAGE_DIR}/LHAMgmtLibJNI.java \ 49 | ${JAVA_PACKAGE_DIR}/LHAMgmtLib.java \ 50 | ha_mgmt_client_wrap.c 51 | 52 | JAVA_PACKAGE_DIR = $(top_srcdir)/tsa_plugin/org/linuxha/sam/plugin 53 | java_sources = ${JAVA_PACKAGE_DIR}/LHAMgmtLibJNI.java \ 54 | ${JAVA_PACKAGE_DIR}/LHANativeResource.java \ 55 | ${JAVA_PACKAGE_DIR}/LHANodeResource.java \ 56 | ${JAVA_PACKAGE_DIR}/LHAClusterManager.java \ 57 | ${JAVA_PACKAGE_DIR}/LHAOrderConstraint.java \ 58 | ${JAVA_PACKAGE_DIR}/LHAColocationConstraint.java\ 59 | ${JAVA_PACKAGE_DIR}/LHAResource.java \ 60 | ${JAVA_PACKAGE_DIR}/LHAConstraint.java \ 61 | ${JAVA_PACKAGE_DIR}/LHAResourceGroup.java \ 62 | ${JAVA_PACKAGE_DIR}/LHALocationConstraint.java\ 63 | ${JAVA_PACKAGE_DIR}/LinuxHAFLA.java \ 64 | ${JAVA_PACKAGE_DIR}/LHANativeClient.java \ 65 | ${JAVA_PACKAGE_DIR}/LHACLIClient.java \ 66 | ${JAVA_PACKAGE_DIR}/LHAEventdClient.java \ 67 | ${JAVA_PACKAGE_DIR}/LinuxHAPlugin.java \ 68 | ${JAVA_PACKAGE_DIR}/LHAMgmtLib.java \ 69 | ${JAVA_PACKAGE_DIR}/Utilities.java 70 | 71 | EXTRA_DIST = ha_mgmt_client.i 72 | 73 | ${swig_gen_files}: ha_mgmt_client.i 74 | $(SWIG) -java -package org.linuxha.sam.plugin -outdir org/linuxha/sam/plugin/ $^ 75 | 76 | linuxhafla.jar:${java_sources} 77 | ${JAVA_HOME}/bin/javac -classpath ${CLASSPATH} ${JAVA_PACKAGE_DIR}/*.java 78 | ${JAVA_HOME}/bin/jar cf linuxhafla.jar ${JAVA_PACKAGE_DIR}/*.class 79 | 80 | liblhamgmt_la_SOURCES = ha_mgmt_client_wrap.c ha_mgmt_client.c ha_mgmt_client.h \ 81 | ha_tsa_common.h ha_tsa_common.c 82 | liblhamgmt_la_CFLAGS = $(INCLUDES) -I$(top_builddir)/include -w 83 | liblhamgmt_la_LIBADD = $(COMMONLIBS) $(MGMTLIBS) 84 | 85 | tsadir = $(libdir)/@HB_PKG@ 86 | tsa_PROGRAMS = tsa_eventd 87 | tsa_eventd_SOURCES = tsa_eventd.c ha_tsa_common.c 88 | tsa_eventd_LDADD = $(COMMONLIBS) $(MGMTLIBS) 89 | 90 | cleancore: 91 | rm -rf core.* javacore* 92 | 93 | CLEANFILES=org/linuxha/sam/plugin/*.class *.jar ${swig_gen_files} 94 | 95 | clidir = $(libdir)/@HB_PKG@ 96 | cli_PROGRAMS = tsa_hacli 97 | tsa_hacli_SOURCES = tsa_hacli.c ha_tsa_common.c 98 | tsa_hacli_LDADD = $(COMMONLIBS) $(MGMTLIBS) 99 | 100 | adapterdir = $(libdir)/@HB_PKG@ 101 | adapter_SCRIPTS = linuxha-adapter 102 | 103 | noinst_PROGRAMS = dummy 104 | dummy_SOURCES = dummy.c 105 | dummy_LDADD = liblhamgmt.la 106 | 107 | -------------------------------------------------------------------------------- /tsa_plugin/README: -------------------------------------------------------------------------------- 1 | linux-ha plugin for TSA README 2 | 3 | 4 | 1. REQUIREMENTS 5 | Compiling the TSA plugin requires various software packages. 6 | First of all you need to install the Java SDK software. You also 7 | need the TSA software including the rsct, sam and sam.adapter. 8 | Although in theory the plugin only depends on the sam.adapter, 9 | not installing the sam package will prevent you from installing 10 | the sam.adapter package due to the dependency between the 11 | sam.adater RPM and the sam RPM. Therefor you might have to 12 | install all of them. 13 | The SWIG is also used to generate the interface files at the 14 | compling time. 15 | Running the TSA plugin requires the Java runtime environment 16 | and the sam.adapater package. 17 | 18 | 2. COMPILING THE PLUGIN 19 | To build the TSA plugin, apply the --enable-tsa-plugin option: 20 | ./ConfigureMe bootstrap --enable-tsa-plugin=yes 21 | Options --with-java-home and --with-tsa-dir and optional. The 22 | --with-java-home option specifies the Java sdk directory and the 23 | --with-tsa-dir option specifies the TSA directory. If they are not 24 | presented, the configuration will try to find the Java sdk directory 25 | and set the TSA directory to /opt/IBM/tsamp. By default, the TSA 26 | software is installed to /opt/IBM/tsamp. So usually you don't need 27 | the --with-tsa-dir option but you often need to present the 28 | --with-java-home option. 29 | For example: 30 | ./ConfigureMe bootstrap --enable-tsa-plugin=yes \ 31 | --with-java-home=/opt/IBMJava2-141 32 | 33 | 3. CONFIGURATION 34 | First, you need to add the apiauth directives as follows to 35 | the ha.cf to allow the plugin to sign on to heartbeat: 36 | apiauth tsa uid=root gid=root 37 | apiauth tsad uid=root gid=root 38 | 39 | Besides, you need to edit the plugin config file: 40 | /etc/opt/IBM/tsamp/sam/cfg/sam.adapter.plugin.properties 41 | and set the value of plugin-impl-class to 42 | org.linuxha.sam.plugin.LinuxHAPlugin. For example: 43 | plugin-impl-class = org.linuxha.sam.plugin.LinuxHAPlugin 44 | This tells the adapater to use the linux-ha plugin. 45 | 46 | 47 | 4. START AND STOP THE PLUGIN 48 | To start the plugin: 49 | /usr/lib/heartbeat/linuxha-adapter start 50 | This will start the tsa_eventd and the adapter in order. 51 | To stop the plugin: 52 | /usr/lib/heartbeat/linuxha-adapter stop 53 | This will stop the adapter and the tsa_eventd in order. 54 | 55 | Notice: linuxha-adapter is modified and simplified from 56 | the sam adapter script /usr/bin/samadapter. 57 | If linuxha-adapter does not work. You may want to try 58 | the original one: 59 | cp /usr/bin/samadapter /usr/bin/linuxha-samadapter 60 | then edit /usr/bin/linuxha-samadapter and append 61 | ":$plib/linuxhafla.jar" to the end of line 365. This tells 62 | the adapter to load the linux-ha plugin when it starts. 63 | You should start or stop the tsa_eventd manually if 64 | you use the original samadapter. 65 | -------------------------------------------------------------------------------- /tsa_plugin/dummy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dummy.c: dummy 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2006 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #include 24 | #ifdef HAVE_STDINT_H 25 | #include 26 | #endif /* HAVE_STDINT_H */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include "ha_mgmt_client.h" 42 | 43 | #define MAX_CMD_LEN 1024 44 | 45 | int main(int argc, char *argv[]) 46 | { 47 | char *result; 48 | 49 | init_logger("dummy"); 50 | result = process_cmnd_eventd("hb_config"); 51 | printf("%s", result); 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /tsa_plugin/ha_mgmt_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ha_mgmt_client.h: header file for ha_mgmt_client.c 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2006 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef _HA_MGMT_CLIENT_H 24 | #define _HA_MGMT_CLIENT_H 25 | 26 | char* wait_for_events(void); 27 | void clLog(int priority, const char* logs); 28 | 29 | void start_heartbeat(const char* node); 30 | void stop_heartbeat(const char* node); 31 | 32 | char* process_cmnd_native(const char* cmd); 33 | char* process_cmnd_external(const char *cmd); 34 | char* process_cmnd_eventd(const char* cmd); 35 | 36 | void init_logger(const char *entity); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /tsa_plugin/ha_mgmt_client.i: -------------------------------------------------------------------------------- 1 | /* 2 | * ha_mgmt_client.i: swig interface file 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2006 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | %module LHAMgmtLib 24 | %{ 25 | #include "ha_mgmt_client.h" 26 | %} 27 | 28 | %pragma(java) jniclasscode=%{ 29 | static { 30 | try { 31 | System.loadLibrary("lhamgmt"); 32 | } catch (UnsatisfiedLinkError e) { 33 | System.exit(1); 34 | } 35 | } 36 | 37 | %} 38 | 39 | %pragma(java) modulecode=%{ 40 | public static final String MSG_OK = "ok"; 41 | public static final String MSG_FAIL = "fail"; 42 | public static final String MSG_LOGIN = "login"; 43 | public static final String MSG_LOGOUT = "logout"; 44 | public static final String MSG_ECHO = "echo"; 45 | public static final String MSG_REGEVT = "regevt"; 46 | public static final String MSG_CIB_VERSION = "cib_version"; 47 | public static final String MSG_CRM_CONFIG = "crm_config"; 48 | public static final String MSG_UP_CRM_CONFIG = "up_crm_config"; 49 | public static final String MSG_HB_CONFIG = "hb_config"; 50 | public static final String MSG_ALLNODES = "all_nodes"; 51 | public static final String MSG_ACTIVENODES = "active_nodes"; 52 | public static final String MSG_CRMNODES = "crm_nodes"; 53 | public static final String MSG_DC = "dc"; 54 | public static final String MSG_NODE_CONFIG = "node_config"; 55 | public static final String MSG_STANDBY = "standby"; 56 | public static final String MSG_RUNNING_RSC = "running_rsc"; 57 | public static final String MSG_ALL_RSC = "all_rsc"; 58 | public static final String MSG_RSC_ATTRS = "rsc_attrs"; 59 | public static final String MSG_RSC_TYPE = "rsc_type"; 60 | public static final String MSG_SUB_RSC = "sub_rsc"; 61 | public static final String MSG_RSC_RUNNING_ON = "rsc_running_on"; 62 | public static final String MSG_RSC_STATUS = "rsc_status"; 63 | public static final String MSG_ADD_RSC = "add_rsc"; 64 | public static final String MSG_ADD_GRP = "add_grp"; 65 | public static final String MSG_DEL_RSC = "del_rsc"; 66 | public static final String MSG_CLEANUP_RSC = "cleanup_rsc"; 67 | public static final String MSG_MOVE_RSC = "move_rsc"; 68 | public static final String MSG_UP_RSC_ATTR = "up_rsc_attr"; 69 | public static final String MSG_RSC_PARAMS = "rsc_params"; 70 | public static final String MSG_UP_RSC_PARAMS = "up_rsc_params"; 71 | public static final String MSG_DEL_RSC_PARAM = "del_rsc_param"; 72 | public static final String MSG_SET_TARGET_ROLE = "set_target_role"; 73 | public static final String MSG_RSC_OPS = "rsc_ops"; 74 | public static final String MSG_UP_RSC_OPS = "up_rsc_ops"; 75 | public static final String MSG_DEL_RSC_OP = "del_rsc_op"; 76 | public static final String MSG_UPDATE_CLONE = "up_clone"; 77 | public static final String MSG_GET_CLONE = "get_clone"; 78 | public static final String MSG_UPDATE_MASTER = "up_master"; 79 | public static final String MSG_GET_MASTER = "get_master"; 80 | public static final String MSG_GET_CONSTRAINTS = "get_cos"; 81 | public static final String MSG_GET_CONSTRAINT = "get_co"; 82 | public static final String MSG_DEL_CONSTRAINT = "del_co"; 83 | public static final String MSG_UP_CONSTRAINT = "up_co"; 84 | public static final String MSG_RSC_CLASSES = "rsc_classes"; 85 | public static final String MSG_RSC_TYPES = "rsc_types"; 86 | public static final String MSG_RSC_PROVIDERS = "rsc_providers"; 87 | public static final String MSG_RSC_METADATA = "rsc_metadata"; 88 | public static final String EVT_CIB_CHANGED = "evt:cib_changed"; 89 | public static final String EVT_DISCONNECTED = "evt:disconnected"; 90 | public static final String EVT_TEST = "evt:test"; 91 | 92 | public static final int LOG_INFO = 6; 93 | public static final int LOG_DEBUG = 7; 94 | public static final int LOG_WARNING = 4; 95 | public static final int LOG_ERR = 3; 96 | 97 | %} 98 | 99 | 100 | char* process_cmnd_native(const char* cmd); 101 | char* process_cmnd_external(const char *cmd); 102 | char* process_cmnd_eventd(const char *cmd); 103 | 104 | char* wait_for_events(void); 105 | void clLog(int priority, const char* logs); 106 | 107 | void start_heartbeat(const char* node); 108 | void stop_heartbeat(const char* node); 109 | 110 | -------------------------------------------------------------------------------- /tsa_plugin/ha_tsa_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ha_tsa_common.c: common functions 3 | * 4 | * Author: Jia Ming Pan 5 | * Copyright (c) 2006 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #include 24 | #ifdef HAVE_STDINT_H 25 | #include 26 | #endif /* HAVE_STDINT_H */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "ha_tsa_common.h" 43 | 44 | 45 | void 46 | init_logger(const char * entity) 47 | { 48 | int debug_level = 2; 49 | cl_log_set_entity(entity); 50 | cl_log_enable_stderr(debug_level?TRUE:FALSE); 51 | cl_log_set_facility(HA_LOG_FACILITY); 52 | } 53 | 54 | char ** 55 | split_string(const char* string, int *len, const char *delim) 56 | { 57 | char **strings = NULL; 58 | const char *p; 59 | 60 | *len = 0; 61 | while(*string){ 62 | char * token = NULL; 63 | /* eat up delim chars */ 64 | while (*string && strchr(delim, *string)) { 65 | string++; 66 | continue; 67 | } 68 | if(!*string) { 69 | break; 70 | } 71 | 72 | /* reach a delim char */ 73 | p = string; 74 | while ( *p && !strchr(delim, *p) ) { 75 | p ++; 76 | continue; 77 | } 78 | 79 | /* copy string~(p-1) to token */ 80 | token = malloc(p-string+1); 81 | if ( token == NULL ) { 82 | return strings; 83 | } 84 | memcpy(token, string, p - string); 85 | token[p-string] = EOS; 86 | 87 | strings = realloc(strings, (*len+1) * sizeof(char *)); 88 | if ( strings == NULL ) { 89 | return NULL; 90 | } 91 | strings[*len] = token; 92 | *len = *len + 1; 93 | string = p; 94 | } 95 | return strings; 96 | } 97 | 98 | void 99 | free_array(void** array, int len) 100 | { 101 | int i; 102 | for (i=0; i 5 | * Copyright (c) 2006 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #ifndef _HA_TSA_COMMON_H 24 | #define _HA_TSA_COMMON_H 25 | 26 | void init_logger(const char * entity); 27 | char** split_string(const char *string, int *len, const char *delim); 28 | void free_array(void** array, int len); 29 | char* run_shell_cmnd(const char *cmnd, int *rc, int *len); 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /tsa_plugin/org/linuxha/sam/plugin/LHACLIClient.java: -------------------------------------------------------------------------------- 1 | package org.linuxha.sam.plugin; 2 | 3 | 4 | public class LHACLIClient extends LHALIBClient 5 | { 6 | synchronized String[] processCommand(String[] command) 7 | { 8 | String msg = ""; 9 | for(int i=0; i 5 | * Copyright (c) 2006 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | #ifdef HAVE_STDINT_H 26 | #include 27 | #endif /* HAVE_STDINT_H */ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "ha_tsa_common.h" 43 | 44 | #define PID_FILE HA_VARRUNDIR"/tsa_hacli.pid" 45 | #define MAX_CMD_LEN 1024 46 | 47 | static char* 48 | process_command(int argc, char * argv[]) 49 | { 50 | char *msg = NULL, *result = NULL; 51 | int i; 52 | char *buf = NULL; 53 | 54 | msg = mgmt_new_msg(argv[1], NULL); 55 | for(i = 2; i < argc; i++ ) { 56 | msg = mgmt_msg_append(msg, argv[i]); 57 | } 58 | 59 | cl_log(LOG_DEBUG, "msg sent: %s", msg); 60 | result = process_msg(msg); 61 | mgmt_del_msg(msg); 62 | if ( result == NULL ) { 63 | return NULL; 64 | } 65 | buf = strdup(result); 66 | mgmt_del_msg(result); 67 | return buf; 68 | } 69 | 70 | int main(int argc, char *argv[]) 71 | { 72 | char *result = NULL; 73 | 74 | init_logger("tsa_cli"); 75 | if ( argc < 2 ) { 76 | return 1; 77 | } 78 | 79 | if(cl_lock_pidfile(PID_FILE) < 0 ){ 80 | exit(100); 81 | } 82 | 83 | init_mgmt_lib("tsa", ENABLE_LRM|ENABLE_CRM|ENABLE_HB|CACHE_CIB); 84 | result = process_command(argc, argv); 85 | final_mgmt_lib(); 86 | if (result) { 87 | printf("%s\n", result); 88 | } 89 | return 0; 90 | } 91 | 92 | --------------------------------------------------------------------------------