Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=d2ef4558785c33551…
Commit: d2ef4558785c33551e4614241a6266822b28e30c
Parent: da90c9bfee84aff6b55964f4db5a19086f4db963
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 28 15:46:42 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 28 15:46:42 2017 -0600
source moved to https://pagure.io/dlm
---
README.rst | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/README.rst b/README.rst
index b6b76b5..40da15b 100644
--- a/README.rst
+++ b/README.rst
@@ -1,2 +1,3 @@
+| ``See https://pagure.io/dlm``
| ``See dlm_controld(8) at dlm.git/dlm_controld/dlm_controld.8``
| ``See dlm.conf(5) at dlm.git/dlm_controld/dlm.conf.5``
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=da90c9bfee84aff6b…
Commit: da90c9bfee84aff6b55964f4db5a19086f4db963
Parent: e9302c077724a9de814022a48438966ffc4fa89c
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 23 11:36:09 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Feb 23 11:36:09 2017 -0600
add readme
---
README.rst | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..b6b76b5
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,2 @@
+| ``See dlm_controld(8) at dlm.git/dlm_controld/dlm_controld.8``
+| ``See dlm.conf(5) at dlm.git/dlm_controld/dlm.conf.5``
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=183aa4fae1f34…
Commit: 183aa4fae1f34ca594c4e782948bfd4790ba5b3d
Parent: aabd30fca943f8c865691bbc76ddb045c1ec0a33
Author: Jan Pokorn�� <jpokorny(a)redhat.com>
AuthorDate: Tue Feb 28 02:31:57 2017 +0100
Committer: Jan Pokorn�� <jpokorny(a)redhat.com>
CommitterDate: Tue Feb 28 02:31:57 2017 +0100
fedorahosted.org discontinued
Signed-off-by: Jan Pokorn�� <jpokorny(a)redhat.com>
---
README | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/README b/README
index d2d00c9..ded30cd 100644
--- a/README
+++ b/README
@@ -1,3 +1,3 @@
-cluster.git master branch is no longer actively developed.
+DISCONTINUED ON FEDORAHOSTED.ORG
-Please refer to STABLE31 branch or RHEL6 branch for stable releases.
+New home: https://pagure.io/linux-cluster/cluster
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=6d44fe232bbe7…
Commit: 6d44fe232bbe709ecb405f6ae455efe47c336cd0
Parent: 1ac358de4743de3bc401eac639ca88252231f3d9
Author: Jan Pokorn�� <jpokorny(a)redhat.com>
AuthorDate: Tue Feb 28 02:32:10 2017 +0100
Committer: Jan Pokorn�� <jpokorny(a)redhat.com>
CommitterDate: Tue Feb 28 02:32:10 2017 +0100
fedorahosted.org discontinued
Signed-off-by: Jan Pokorn�� <jpokorny(a)redhat.com>
---
Makefile | 69 -
README | 3 +
bindings/Makefile | 4 -
bindings/perl/Makefile | 4 -
bindings/perl/ccs/CCS.pm.in | 145 --
bindings/perl/ccs/CCS.xs | 82 -
bindings/perl/ccs/MANIFEST | 7 -
bindings/perl/ccs/META.yml.in | 13 -
bindings/perl/ccs/Makefile.PL | 28 -
bindings/perl/ccs/Makefile.bindings | 13 -
bindings/perl/ccs/test.pl | 20 -
bindings/perl/ccs/typemap | 1 -
bindings/python/Makefile | 4 -
cman/Makefile | 4 -
cman/cman_tool/Makefile | 33 -
cman/cman_tool/cman_tool.h | 109 -
cman/cman_tool/join.c | 396 ---
cman/cman_tool/main.c | 1297 ----------
cman/daemon/Makefile | 41 -
cman/daemon/ais.c | 378 ---
cman/daemon/ais.h | 14 -
cman/daemon/barrier.c | 469 ----
cman/daemon/barrier.h | 6 -
cman/daemon/cman-preconfig.c | 1781 -------------
cman/daemon/cman.h | 19 -
cman/daemon/cmanconfig.c | 312 ---
cman/daemon/cmanconfig.h | 3 -
cman/daemon/cnxman-private.h | 183 --
cman/daemon/cnxman-socket.h | 289 ---
cman/daemon/commands.c | 2459 ------------------
cman/daemon/commands.h | 37 -
cman/daemon/daemon.c | 528 ----
cman/daemon/daemon.h | 12 -
cman/daemon/fnvhash.c | 93 -
cman/daemon/fnvhash.h | 1 -
cman/daemon/list.h | 97 -
cman/daemon/nodelist.h | 91 -
cman/init.d/Makefile | 21 -
cman/init.d/cman.in | 1038 --------
cman/init.d/cman.init.defaults.in | 132 -
cman/lib/Makefile | 12 -
cman/lib/libcman.c | 1145 ---------
cman/lib/libcman.h | 457 ----
cman/lib/libcman.pc.in | 11 -
cman/man/Makefile | 17 -
cman/man/checkquorum.8 | 29 -
cman/man/cman.5 | 211 --
cman/man/cman_notify.8 | 17 -
cman/man/cman_tool.8 | 442 ----
cman/man/cmannotifyd.8 | 66 -
cman/man/mkqdisk.8 | 31 -
cman/man/qdisk.5 | 530 ----
cman/man/qdiskd.8 | 25 -
cman/notifyd/Makefile | 37 -
cman/notifyd/cman_notify.in | 40 -
cman/notifyd/main.c | 430 ----
cman/qdisk/Makefile | 52 -
cman/qdisk/bitmap.c | 91 -
cman/qdisk/daemon_init.c | 236 --
cman/qdisk/disk.c | 784 ------
cman/qdisk/disk.h | 298 ---
cman/qdisk/disk_util.c | 264 --
cman/qdisk/iostate.c | 154 --
cman/qdisk/iostate.h | 19 -
cman/qdisk/main.c | 2289 -----------------
cman/qdisk/mkqdisk.c | 102 -
cman/qdisk/platform.h | 40 -
cman/qdisk/proc.c | 262 --
cman/qdisk/scandisk.c | 782 ------
cman/qdisk/scandisk.h | 86 -
cman/qdisk/score.c | 488 ----
cman/qdisk/score.h | 47 -
cman/scripts/Makefile | 11 -
cman/scripts/checkquorum | 97 -
cman/scripts/checkquorum.wdmd | 104 -
cman/tests/Makefile | 23 -
cman/tests/client.c | 113 -
cman/tests/libtest.c | 132 -
cman/tests/qwait.c | 58 -
cman/tests/sysman.c | 72 -
cman/tests/sysmand.c | 469 ----
cman/tests/user_service.c | 285 ---
common/Makefile | 4 -
common/liblogthread/Makefile | 13 -
common/liblogthread/liblogthread.c | 378 ---
common/liblogthread/liblogthread.h | 19 -
common/liblogthread/liblogthread.pc.in | 11 -
config/Makefile | 4 -
config/libs/Makefile | 4 -
config/libs/libccsconfdb/Makefile | 24 -
config/libs/libccsconfdb/ccs.h | 16 -
config/libs/libccsconfdb/ccs_internal.h | 29 -
config/libs/libccsconfdb/extras.c | 454 ----
config/libs/libccsconfdb/fullxpath.c | 361 ---
config/libs/libccsconfdb/libccs.c | 660 -----
config/libs/libccsconfdb/libccs.pc.in | 11 -
config/libs/libccsconfdb/xpathlite.c | 454 ----
config/man/Makefile | 9 -
config/man/cluster.conf.5 | 237 --
config/plugins/Makefile | 4 -
config/plugins/ldap/99cluster.ldif | 1899 --------------
config/plugins/ldap/Makefile | 30 -
config/plugins/ldap/configldap.c | 295 ---
config/plugins/ldap/example.ldif | 137 -
config/plugins/ldap/ldap-base.csv | 352 ---
config/plugins/xml/Makefile | 27 -
config/plugins/xml/config.c | 149 --
config/tools/Makefile | 4 -
config/tools/ccs_tool/Makefile | 39 -
config/tools/ccs_tool/ccs_tool.c | 380 ---
config/tools/ccs_tool/editconf.c | 2395 ------------------
config/tools/ccs_tool/editconf.h | 18 -
config/tools/ldap/Makefile | 30 -
config/tools/ldap/confdb2ldif.c | 180 --
config/tools/ldap/rng2ldif/Makefile | 46 -
config/tools/ldap/rng2ldif/debug.h | 10 -
config/tools/ldap/rng2ldif/genclass.c | 106 -
config/tools/ldap/rng2ldif/ldaptypes.c | 53 -
config/tools/ldap/rng2ldif/ldaptypes.h | 8 -
config/tools/ldap/rng2ldif/name.c | 58 -
config/tools/ldap/rng2ldif/name.h | 6 -
config/tools/ldap/rng2ldif/rng2ldif.c | 242 --
config/tools/ldap/rng2ldif/tree.c | 469 ----
config/tools/ldap/rng2ldif/tree.h | 40 -
config/tools/ldap/rng2ldif/value-list.c | 206 --
config/tools/ldap/rng2ldif/value-list.h | 28 -
config/tools/ldap/rng2ldif/zalloc.c | 23 -
config/tools/ldap/rng2ldif/zalloc.h | 6 -
config/tools/man/Makefile | 14 -
config/tools/man/ccs_config_dump.8 | 35 -
config/tools/man/ccs_config_validate.8 | 56 -
config/tools/man/ccs_tool.8 | 151 --
config/tools/man/ccs_update_schema.8 | 29 -
config/tools/man/confdb2ldif.8 | 64 -
config/tools/xml/Makefile | 47 -
config/tools/xml/ccs_config_dump.c | 187 --
config/tools/xml/ccs_config_validate.in | 242 --
config/tools/xml/ccs_update_schema.in | 382 ---
config/tools/xml/cluster.rng.in.head | 1126 ---------
config/tools/xml/cluster.rng.in.tail | 1 -
configure | 686 -----
contrib/Makefile | 6 -
contrib/libaislock/Makefile | 15 -
contrib/libaislock/libaislock.c | 466 ----
contrib/libaislock/libaislock.h | 190 --
contrib/libaislock/libaislock.pc.in | 11 -
dlm/Makefile | 4 -
dlm/doc/dlm_tool.txt | 167 --
dlm/doc/example.c | 52 -
dlm/doc/libdlm.txt | 533 ----
dlm/doc/user-dlm-overview.txt | 325 ---
dlm/libdlm/51-dlm.rules | 2 -
dlm/libdlm/Makefile | 81 -
dlm/libdlm/libdlm.c | 1485 -----------
dlm/libdlm/libdlm.h | 275 --
dlm/libdlm/libdlm.pc.in | 11 -
dlm/libdlm/libdlm_internal.h | 9 -
dlm/libdlm/libdlm_lt.pc.in | 11 -
dlm/libdlmcontrol/Makefile | 17 -
dlm/libdlmcontrol/libdlmcontrol.h | 90 -
dlm/libdlmcontrol/libdlmcontrol.pc.in | 11 -
dlm/libdlmcontrol/main.c | 419 ----
dlm/man/Makefile | 30 -
dlm/man/dlm_cleanup.3 | 1 -
dlm/man/dlm_close_lockspace.3 | 1 -
dlm/man/dlm_create_lockspace.3 | 94 -
dlm/man/dlm_dispatch.3 | 1 -
dlm/man/dlm_get_fd.3 | 1 -
dlm/man/dlm_lock.3 | 239 --
dlm/man/dlm_lock_wait.3 | 1 -
dlm/man/dlm_ls_lock.3 | 1 -
dlm/man/dlm_ls_lock_wait.3 | 1 -
dlm/man/dlm_ls_lockx.3 | 1 -
dlm/man/dlm_ls_pthread_init.3 | 1 -
dlm/man/dlm_ls_unlock.3 | 1 -
dlm/man/dlm_ls_unlock_wait.3 | 1 -
dlm/man/dlm_new_lockspace.3 | 1 -
dlm/man/dlm_open_lockspace.3 | 1 -
dlm/man/dlm_pthread_init.3 | 1 -
dlm/man/dlm_release_lockspace.3 | 1 -
dlm/man/dlm_tool.8 | 98 -
dlm/man/dlm_unlock.3 | 94 -
dlm/man/dlm_unlock_wait.3 | 1 -
dlm/man/libdlm.3 | 105 -
dlm/tests/Makefile | 4 -
dlm/tests/usertest/Makefile | 23 -
dlm/tests/usertest/alternate-lvb.c | 165 --
dlm/tests/usertest/asttest.c | 281 ---
dlm/tests/usertest/dlmtest.c | 289 ---
dlm/tests/usertest/dlmtest2.c | 1454 -----------
dlm/tests/usertest/flood.c | 170 --
dlm/tests/usertest/joinleave.c | 62 -
dlm/tests/usertest/lstest.c | 326 ---
dlm/tests/usertest/lvb.c | 244 --
dlm/tests/usertest/pingtest.c | 343 ---
dlm/tests/usertest/sublocks.c | 178 --
dlm/tests/usertest/threads.c | 309 ---
dlm/tool/Makefile | 32 -
dlm/tool/main.c | 1324 ----------
doc/COPYING.applications | 339 ---
doc/COPYING.libraries | 510 ----
doc/COPYRIGHT | 141 --
doc/Makefile | 24 -
doc/README.licence | 33 -
doc/cluster.logrotate.in | 9 -
doc/cluster_conf.html | 1212 ---------
doc/cman_notify_template.sh | 57 -
doc/usage.txt | 67 -
fence/Makefile | 4 -
fence/fence_check/Makefile | 20 -
fence/fence_check/fence_check.in | 241 --
fence/fence_node/Makefile | 35 -
fence/fence_node/fence_node.c | 306 ---
fence/fence_tool/Makefile | 32 -
fence/fence_tool/fence_tool.c | 737 ------
fence/fenced/Makefile | 49 -
fence/fenced/config.c | 226 --
fence/fenced/config.h | 39 -
fence/fenced/cpg.c | 2510 -------------------
fence/fenced/dbus.c | 87 -
fence/fenced/fd.h | 299 ---
fence/fenced/fenced.h | 36 -
fence/fenced/group.c | 489 ----
fence/fenced/logging.c | 92 -
fence/fenced/main.c | 1092 --------
fence/fenced/member_cman.c | 416 ---
fence/fenced/recover.c | 477 ----
fence/include/linux_endian.h | 68 -
fence/include/list.h | 336 ---
fence/libfence/Makefile | 20 -
fence/libfence/agent.c | 1142 ---------
fence/libfence/libfence.h | 65 -
fence/libfence/libfence.pc.in | 11 -
fence/libfenced/Makefile | 14 -
fence/libfenced/libfenced.h | 53 -
fence/libfenced/libfenced.pc.in | 11 -
fence/libfenced/main.c | 323 ---
fence/man/Makefile | 10 -
fence/man/fence_check.8 | 65 -
fence/man/fence_node.8 | 127 -
fence/man/fence_tool.8 | 60 -
fence/man/fenced.8 | 353 ---
group/Makefile | 4 -
group/daemon/Makefile | 35 -
group/daemon/app.c | 1846 --------------
group/daemon/cman.c | 206 --
group/daemon/cpg.c | 1116 ---------
group/daemon/gd_internal.h | 325 ---
group/daemon/groupd.h | 13 -
group/daemon/joinleave.c | 165 --
group/daemon/logging.c | 60 -
group/daemon/main.c | 1074 --------
group/dlm_controld/Makefile | 52 -
group/dlm_controld/action.c | 1089 --------
group/dlm_controld/config.c | 306 ---
group/dlm_controld/config.h | 53 -
group/dlm_controld/cpg.c | 2631 --------------------
group/dlm_controld/crc.c | 72 -
group/dlm_controld/deadlock.c | 1550 ------------
group/dlm_controld/dlm_controld.h | 38 -
group/dlm_controld/dlm_daemon.h | 391 ---
group/dlm_controld/group.c | 376 ---
group/dlm_controld/logging.c | 61 -
group/dlm_controld/main.c | 1429 -----------
group/dlm_controld/member_cman.c | 350 ---
group/dlm_controld/netlink.c | 225 --
group/dlm_controld/plock.c | 2388 ------------------
group/include/linux_endian.h | 68 -
group/include/list.h | 336 ---
group/lib/Makefile | 14 -
group/lib/libgroup.c | 524 ----
group/lib/libgroup.h | 81 -
group/man/Makefile | 12 -
group/man/dlm_controld.8 | 313 ---
group/man/group_tool.8 | 80 -
group/man/groupd.8 | 64 -
group/test/Makefile | 16 -
group/test/client.c | 45 -
group/test/clientd.c | 179 --
group/tool/Makefile | 30 -
group/tool/main.c | 735 ------
make/binding-passthrough.mk | 7 -
make/clean.mk | 7 -
make/cobj.mk | 38 -
make/copyright.cf | 6 -
make/defines.mk.input | 80 -
make/install.mk | 92 -
make/libs.mk | 59 -
make/official_release_version | 1 -
make/passthrough.mk | 7 -
make/perl-binding-common.mk | 30 -
make/release.mk | 160 --
make/uninstall.mk | 59 -
rgmanager/ChangeLog | 634 -----
rgmanager/Makefile | 4 -
rgmanager/README | 359 ---
rgmanager/errors.txt | 552 ----
rgmanager/event-script.txt | 305 ---
rgmanager/examples/cluster.conf | 106 -
rgmanager/include/cman-private.h | 14 -
rgmanager/include/cpglock-internal.h | 35 -
rgmanager/include/cpglock.h | 40 -
rgmanager/include/daemon_init.h | 10 -
rgmanager/include/ds.h | 13 -
rgmanager/include/event.h | 143 --
rgmanager/include/fdops.h | 14 -
rgmanager/include/findproc.h | 11 -
rgmanager/include/fo_domain.h | 49 -
rgmanager/include/gettid.h | 7 -
rgmanager/include/groups.h | 43 -
rgmanager/include/list.h | 95 -
rgmanager/include/lock.h | 17 -
rgmanager/include/logging.h | 11 -
rgmanager/include/members.h | 40 -
rgmanager/include/message.h | 175 --
rgmanager/include/msgsimple.h | 64 -
rgmanager/include/platform.h | 59 -
rgmanager/include/pthread_dbg.h | 41 -
rgmanager/include/res-ocf.h | 53 -
rgmanager/include/resgroup.h | 258 --
rgmanager/include/reslist.h | 210 --
rgmanager/include/restart_counter.h | 15 -
rgmanager/include/rg_dbus.h | 20 -
rgmanager/include/rg_locks.h | 47 -
rgmanager/include/rg_queue.h | 48 -
rgmanager/include/rg_types.h | 18 -
rgmanager/include/rmtab.h | 101 -
rgmanager/include/sets.h | 22 -
rgmanager/include/signals.h | 9 -
rgmanager/include/sock.h | 18 -
rgmanager/include/vf.h | 181 --
rgmanager/init.d/Makefile | 20 -
rgmanager/init.d/cpglockd.in | 147 --
rgmanager/init.d/cpglockd.init.defaults.in | 7 -
rgmanager/init.d/rgmanager.in | 162 --
rgmanager/man/Makefile | 19 -
rgmanager/man/clubufflush.8 | 13 -
rgmanager/man/clufindhostname.8 | 22 -
rgmanager/man/clulog.8 | 27 -
rgmanager/man/clurgmgrd.8 | 1 -
rgmanager/man/clustat.8 | 53 -
rgmanager/man/clusvcadm.8 | 147 --
rgmanager/man/cpglockd.8 | 21 -
rgmanager/man/rgmanager.8 | 392 ---
rgmanager/src/Makefile | 4 -
rgmanager/src/clulib/Makefile | 41 -
rgmanager/src/clulib/ckpt_state.c | 536 ----
rgmanager/src/clulib/cman.c | 249 --
rgmanager/src/clulib/cpg_lock.c | 137 -
rgmanager/src/clulib/daemon_init.c | 228 --
rgmanager/src/clulib/dlm_lock.c | 301 ---
rgmanager/src/clulib/fdops.c | 176 --
rgmanager/src/clulib/gettid.c | 24 -
rgmanager/src/clulib/libcpglock.c | 287 ---
rgmanager/src/clulib/lock.c | 6 -
rgmanager/src/clulib/locktest.c | 67 -
rgmanager/src/clulib/logging.c | 112 -
rgmanager/src/clulib/members.c | 527 ----
rgmanager/src/clulib/message.c | 273 --
rgmanager/src/clulib/msg_cluster.c | 1278 ----------
rgmanager/src/clulib/msg_socket.c | 440 ----
rgmanager/src/clulib/msgsimple.c | 108 -
rgmanager/src/clulib/msgtest.c | 266 --
rgmanager/src/clulib/rg_strings.c | 219 --
rgmanager/src/clulib/sets.c | 353 ---
rgmanager/src/clulib/signals.c | 68 -
rgmanager/src/clulib/sock.c | 354 ---
rgmanager/src/clulib/tmgr.c | 150 --
rgmanager/src/clulib/vft.c | 1801 --------------
rgmanager/src/clulib/wrap_lock.c | 205 --
rgmanager/src/daemons/Makefile | 137 -
rgmanager/src/daemons/cpglockd.c | 1814 --------------
rgmanager/src/daemons/cpglockdump.c | 8 -
rgmanager/src/daemons/event_config.c | 514 ----
rgmanager/src/daemons/fo_domain.c | 655 -----
rgmanager/src/daemons/groups.c | 1986 ---------------
rgmanager/src/daemons/main.c | 1283 ----------
rgmanager/src/daemons/reslist.c | 995 --------
rgmanager/src/daemons/resrules.c | 1218 ---------
rgmanager/src/daemons/restart_counter.c | 193 --
rgmanager/src/daemons/restree.c | 1935 --------------
rgmanager/src/daemons/rg_event.c | 568 -----
rgmanager/src/daemons/rg_forward.c | 279 ---
rgmanager/src/daemons/rg_locks.c | 368 ---
rgmanager/src/daemons/rg_queue.c | 71 -
rgmanager/src/daemons/rg_state.c | 2366 ------------------
rgmanager/src/daemons/rg_thread.c | 770 ------
rgmanager/src/daemons/sbuf.c | 85 -
rgmanager/src/daemons/service_op.c | 359 ---
rgmanager/src/daemons/slang_event.c | 1468 -----------
rgmanager/src/daemons/test-expand-time.c | 25 -
rgmanager/src/daemons/test.c | 450 ----
.../daemons/tests/delta-test001-test002.expected | 22 -
.../daemons/tests/delta-test002-test003.expected | 34 -
.../daemons/tests/delta-test003-test004.expected | 46 -
.../daemons/tests/delta-test004-test005.expected | 58 -
.../daemons/tests/delta-test005-test006.expected | 70 -
.../daemons/tests/delta-test006-test007.expected | 70 -
.../daemons/tests/delta-test007-test008.expected | 80 -
.../daemons/tests/delta-test008-test009.expected | 96 -
.../daemons/tests/delta-test009-test010.expected | 110 -
.../daemons/tests/delta-test010-test011.expected | 180 --
.../daemons/tests/delta-test011-test012.expected | 248 --
.../daemons/tests/delta-test012-test013.expected | 254 --
.../daemons/tests/delta-test013-test014.expected | 319 ---
.../daemons/tests/delta-test014-test015.expected | 384 ---
.../daemons/tests/delta-test015-test016.expected | 385 ---
.../daemons/tests/delta-test016-test017.expected | 408 ---
rgmanager/src/daemons/tests/deptest1.conf | 63 -
rgmanager/src/daemons/tests/deptest1.in | 11 -
rgmanager/src/daemons/tests/deptest2.conf | 50 -
rgmanager/src/daemons/tests/deptest2.in | 11 -
rgmanager/src/daemons/tests/gentests.sh | 74 -
rgmanager/src/daemons/tests/runtests.sh | 122 -
rgmanager/src/daemons/tests/test001.conf | 7 -
rgmanager/src/daemons/tests/test001.expected | 11 -
rgmanager/src/daemons/tests/test001.start.expected | 3 -
rgmanager/src/daemons/tests/test001.stop.expected | 3 -
rgmanager/src/daemons/tests/test002.conf | 13 -
rgmanager/src/daemons/tests/test002.expected | 11 -
rgmanager/src/daemons/tests/test002.start.expected | 3 -
rgmanager/src/daemons/tests/test002.stop.expected | 3 -
rgmanager/src/daemons/tests/test003.conf | 14 -
rgmanager/src/daemons/tests/test003.expected | 23 -
rgmanager/src/daemons/tests/test003.start.expected | 4 -
rgmanager/src/daemons/tests/test003.stop.expected | 4 -
rgmanager/src/daemons/tests/test004.conf | 15 -
rgmanager/src/daemons/tests/test004.expected | 23 -
rgmanager/src/daemons/tests/test004.start.expected | 4 -
rgmanager/src/daemons/tests/test004.stop.expected | 4 -
rgmanager/src/daemons/tests/test005.conf | 16 -
rgmanager/src/daemons/tests/test005.expected | 35 -
rgmanager/src/daemons/tests/test005.start.expected | 5 -
rgmanager/src/daemons/tests/test005.stop.expected | 5 -
rgmanager/src/daemons/tests/test006.conf | 16 -
rgmanager/src/daemons/tests/test006.expected | 35 -
rgmanager/src/daemons/tests/test006.start.expected | 5 -
rgmanager/src/daemons/tests/test006.stop.expected | 5 -
rgmanager/src/daemons/tests/test007.conf | 17 -
rgmanager/src/daemons/tests/test007.expected | 35 -
rgmanager/src/daemons/tests/test007.start.expected | 5 -
rgmanager/src/daemons/tests/test007.stop.expected | 5 -
rgmanager/src/daemons/tests/test008.conf | 20 -
rgmanager/src/daemons/tests/test008.expected | 45 -
rgmanager/src/daemons/tests/test008.start.expected | 5 -
rgmanager/src/daemons/tests/test008.stop.expected | 5 -
rgmanager/src/daemons/tests/test009.conf | 19 -
rgmanager/src/daemons/tests/test009.expected | 51 -
rgmanager/src/daemons/tests/test009.start.expected | 6 -
rgmanager/src/daemons/tests/test009.stop.expected | 6 -
rgmanager/src/daemons/tests/test010.conf | 19 -
rgmanager/src/daemons/tests/test010.expected | 59 -
rgmanager/src/daemons/tests/test010.start.expected | 6 -
rgmanager/src/daemons/tests/test010.stop.expected | 6 -
rgmanager/src/daemons/tests/test011.conf | 38 -
rgmanager/src/daemons/tests/test011.expected | 121 -
rgmanager/src/daemons/tests/test011.start.expected | 9 -
rgmanager/src/daemons/tests/test011.stop.expected | 9 -
rgmanager/src/daemons/tests/test012.conf | 33 -
rgmanager/src/daemons/tests/test012.expected | 127 -
rgmanager/src/daemons/tests/test012.start.expected | 10 -
rgmanager/src/daemons/tests/test012.stop.expected | 10 -
rgmanager/src/daemons/tests/test013.conf | 34 -
rgmanager/src/daemons/tests/test013.expected | 127 -
rgmanager/src/daemons/tests/test013.start.expected | 10 -
rgmanager/src/daemons/tests/test013.stop.expected | 10 -
rgmanager/src/daemons/tests/test014.conf | 46 -
rgmanager/src/daemons/tests/test014.expected | 192 --
rgmanager/src/daemons/tests/test014.start.expected | 20 -
rgmanager/src/daemons/tests/test014.stop.expected | 20 -
rgmanager/src/daemons/tests/test015.conf | 51 -
rgmanager/src/daemons/tests/test015.expected | 192 --
rgmanager/src/daemons/tests/test015.start.expected | 20 -
rgmanager/src/daemons/tests/test015.stop.expected | 20 -
rgmanager/src/daemons/tests/test016.conf | 50 -
rgmanager/src/daemons/tests/test016.expected | 193 --
rgmanager/src/daemons/tests/test016.start.expected | 22 -
rgmanager/src/daemons/tests/test016.stop.expected | 22 -
rgmanager/src/daemons/tests/test017.conf | 68 -
rgmanager/src/daemons/tests/test017.expected | 215 --
rgmanager/src/daemons/tests/test017.start.expected | 22 -
rgmanager/src/daemons/tests/test017.stop.expected | 22 -
rgmanager/src/daemons/tests/test018.conf | 78 -
rgmanager/src/daemons/tests/test018.start.expected | 24 -
rgmanager/src/daemons/tests/test018.stop.expected | 24 -
rgmanager/src/daemons/tests/testlist | 4 -
rgmanager/src/daemons/update-dbus.c | 319 ---
rgmanager/src/daemons/watchdog.c | 108 -
rgmanager/src/resources/Makefile | 12 -
rgmanager/src/resources/default_event_script.sl | 652 -----
rgmanager/src/resources/follow-service.sl | 157 --
rgmanager/src/utils/Makefile | 73 -
rgmanager/src/utils/clubufflush.c | 121 -
rgmanager/src/utils/clufindhostname.c | 77 -
rgmanager/src/utils/clulog.c | 70 -
rgmanager/src/utils/clunfslock.sh | 69 -
rgmanager/src/utils/clustat.c | 1216 ---------
rgmanager/src/utils/clusvcadm.c | 465 ----
scripts/uninstall.pl | 71 -
499 files changed, 3 insertions(+), 114787 deletions(-)
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 5d4b50f..0000000
--- a/Makefile
+++ /dev/null
@@ -1,69 +0,0 @@
-include make/defines.mk
-
-REALSUBDIRS = common config cman dlm fence/libfenced group \
- fence rgmanager bindings doc contrib
-
-SUBDIRS = $(filter-out \
- $(if ${without_common},common) \
- $(if ${without_config},config) \
- $(if ${without_cman},cman) \
- $(if ${without_dlm},dlm) \
- $(if ${without_fence},fence/libfenced) \
- $(if ${without_group},group) \
- $(if ${without_fence},fence) \
- $(if ${without_rgmanager},rgmanager) \
- $(if ${without_bindings},bindings) \
- , $(REALSUBDIRS))
-
-all: ${SUBDIRS}
-
-${SUBDIRS}:
- ${MAKE} -C $@ all
-
-# Dependencies
-
-common:
-config:
-cman: common config
-dlm: config
-fence/libfenced:
-group: cman dlm fence/libfenced
-fence: group
-rgmanager: cman dlm
-bindings: cman
-contrib: dlm
-
-oldconfig:
- @if [ -f $(OBJDIR)/.configure.sh ]; then \
- sh $(OBJDIR)/.configure.sh; \
- else \
- echo "Unable to find old configuration data"; \
- fi
-
-install:
- set -e && for i in ${SUBDIRS}; do ${MAKE} -C $$i $@; done
- install -d ${notifyddir}
- install -d ${logdir}
- install -d ${DESTDIR}/var/lib/cluster
- install -d ${DESTDIR}/var/run/cluster
-
-uninstall:
- set -e && for i in ${SUBDIRS}; do ${MAKE} -C $$i $@; done
- rmdir ${notifyddir} || :;
- rmdir ${logdir} || :;
- rmdir ${DESTDIR}/var/lib/cluster || :;
- rmdir ${DESTDIR}/var/run/cluster || :;
-
-clean:
- set -e && for i in ${REALSUBDIRS}; do \
- contrib_code=1 \
- ${MAKE} -C $$i $@;\
- done
-
-distclean: clean
- rm -f make/defines.mk
- rm -f .configure.sh
- rm -f *tar.gz
- rm -rf build
-
-.PHONY: ${REALSUBDIRS}
diff --git a/README b/README
new file mode 100644
index 0000000..ded30cd
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
+DISCONTINUED ON FEDORAHOSTED.ORG
+
+New home: https://pagure.io/linux-cluster/cluster
diff --git a/bindings/Makefile b/bindings/Makefile
deleted file mode 100644
index 21085c2..0000000
--- a/bindings/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../make/defines.mk
-include $(OBJDIR)/make/passthrough.mk
-
-SUBDIRS=perl python
diff --git a/bindings/perl/Makefile b/bindings/perl/Makefile
deleted file mode 100644
index cf3a25a..0000000
--- a/bindings/perl/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../../make/defines.mk
-include $(OBJDIR)/make/binding-passthrough.mk
-
-SUBDIRS=ccs
diff --git a/bindings/perl/ccs/CCS.pm.in b/bindings/perl/ccs/CCS.pm.in
deleted file mode 100644
index 97a3a87..0000000
--- a/bindings/perl/ccs/CCS.pm.in
+++ /dev/null
@@ -1,145 +0,0 @@
-package Cluster::CCS;
-
-use strict;
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
-
-require Exporter;
-require DynaLoader;
-
-@ISA = qw(Exporter DynaLoader);
-# Items to export into callers namespace by default. Note: do not export
-# names by default without a very good reason. Use EXPORT_OK instead.
-# Do not simply export all your public functions/methods/constants.
-our %EXPORT_TAGS = ( 'all' => [qw(
-
-)]);
-@EXPORT = qw(
-
-);
-@EXPORT_OK = (@{$EXPORT_TAGS{'all'}});
-
-our $VERSION = '@VERSION@';
-
-require XSLoader;
-XSLoader::load('Cluster::CCS', $VERSION);
-
-sub new {
- my $class = shift;
- my $self = bless {
- @_
- };
- return $self;
-}
-
-1;
-__END__
-
-=head1 NAME
-
-Cluster::CCS - Perl wrapper for the Cluster Configuration Service library
-
-=head1 SYNOPSIS
-
- use Cluster::CCS;
-
- my $ccs = new Cluster::CCS();
-
- $ccs->fullxpath(1);
-
- my $ccshandle = $ccs->connect();
-
- if ($ccshandle < 1) {
- print "Cannot comunicate with libccs\n";
- exit $ccshandle;
- }
-
- my $rtn;
- my $err;
-
- $err = $ccs->get($ccshandle, '/cluster/@name', $rtn);
-
- if ($err != 0) {
- print "Query is not valid\n";
- }
-
- print "My Cluster name is $rtn\n";
-
- $err = $ccs->disconnect($ccshandle);
-
- if ($err != 0) {
- print "Problems disconnecting from libccs\n";
- }
-
- exit $err;
-
-=head1 DESCRIPTION
-
- Cluster::CCS provides a perl XS wrapper for libccs.
-
-=head1 METHODS
-
-=head2 new
-
- Creates a new Cluster::CCS object.
-
-=head2 fullxpath(value)
-
- Enable or disable full xpath queries. Set 1 to enable, 0 to disable.
- This has to be set before connect() or force_connect.
- In order to change this value, a disconnect operation is required.
-
-=head2 connect(void)
-
- Initialize the connection to libccs/libconfdb/corosync objdb.
- Returns 1 on success or negative on failure.
-
-=head2 force_connect(cluster_name, blocking)
-
- Initialize the connection to libccs/libconfdb/corosync objdb.
- If blocking is set, it will retry the operation until it succeed.
- Returns 1 on success or negative on failure.
-
-=head2 disconnect(desc)
-
- Disconnect and free resources allocated during opertaion.
- Returns 0 on success.
-
-=head2 get(desc, query, rtn)
-
- Perform a simple xpath query.
- Returns 0 on success, negative otherwise. On success rtn will contain the
- requested data.
-
-=head2 get_list(desc, query, rtn)
-
- Perform a simple xpath query and retain some data to iterate over a list of
- results.
- Returns 0 on success, negative otherwise. On success rtn will contain the
- requested data.
-
-=head2 set(desc, path, val)
-
- This operation is not yet implemented in libccs.
-
-=head2 lookup_nodename(desc, nodename, rtn)
-
- Perform a nodename lookup using several methods.
- Return 0 on success and rtn will contain the requested data.
-
-=head1 EXPORTS
-
-Nothing is exported by default.
-
-=head1 BUGS
-
- https://bugzilla.redhat.com/
-
-=head1 SEE ALSO
-
- cluster.conf(5), ccs(7), ccs_tool(8)
-
-=head1 AUTHOR
-
-Fabio M. Di Nitto <fdinitto(a)redhat.com>
-
-=cut
diff --git a/bindings/perl/ccs/CCS.xs b/bindings/perl/ccs/CCS.xs
deleted file mode 100644
index 21a651d..0000000
--- a/bindings/perl/ccs/CCS.xs
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "ccs.h"
-
-MODULE = Cluster::CCS PACKAGE = Cluster::CCS
-
-PROTOTYPES: ENABLE
-
-void
-fullxpath(self, value)
- int value;
- CODE:
- fullxpath = value;
-
-int
-connect(self)
- CODE:
- RETVAL = ccs_connect();
- OUTPUT:
- RETVAL
-
-int
-force_connect(self, cluster_name, blocking)
- const char *cluster_name;
- int blocking;
- CODE:
- RETVAL = ccs_force_connect(cluster_name, blocking);
- OUTPUT:
- RETVAL
-
-int
-disconnect(self, desc)
- int desc;
- CODE:
- RETVAL = ccs_disconnect(desc);
- OUTPUT:
- RETVAL
-
-int
-get(self, desc, query, rtn)
- int desc;
- const char *query;
- char *rtn;
- CODE:
- RETVAL = ccs_get(desc, query, &rtn);
- OUTPUT:
- RETVAL
- rtn
-
-int
-get_list(self, desc, query, rtn)
- int desc;
- const char *query;
- char *rtn;
- CODE:
- RETVAL = ccs_get_list(desc, query, &rtn);
- OUTPUT:
- RETVAL
- rtn
-
-int
-set(self, desc, path, val)
- int desc;
- char *path;
- char *val;
- CODE:
- RETVAL = ccs_set(desc, path, val);
- OUTPUT:
- RETVAL
-
-int
-lookup_nodename(self, desc, nodename, rtn)
- int desc;
- const char *nodename;
- char *rtn;
- CODE:
- RETVAL = ccs_lookup_nodename(desc, nodename, &rtn);
- OUTPUT:
- RETVAL
- rtn
diff --git a/bindings/perl/ccs/MANIFEST b/bindings/perl/ccs/MANIFEST
deleted file mode 100644
index c089dd7..0000000
--- a/bindings/perl/ccs/MANIFEST
+++ /dev/null
@@ -1,7 +0,0 @@
-CCS.pm
-CCS.xs
-Makefile.PL
-MANIFEST
-test.pl
-typemap
-META.yml Module meta-data (added by MakeMaker)
diff --git a/bindings/perl/ccs/META.yml.in b/bindings/perl/ccs/META.yml.in
deleted file mode 100644
index 32ae9a3..0000000
--- a/bindings/perl/ccs/META.yml.in
+++ /dev/null
@@ -1,13 +0,0 @@
---- #YAML:1.0
-name: Cluster-CCS
-version: @VERSION@
-abstract: ~
-license: ~
-author:
- - Fabio M. Di Nitto <fdinitto(a)redhat.com>
-generated_by: ExtUtils::MakeMaker version 6.42
-distribution_type: module
-requires:
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.3.html
- version: 1.3
diff --git a/bindings/perl/ccs/Makefile.PL b/bindings/perl/ccs/Makefile.PL
deleted file mode 100644
index b5504ea..0000000
--- a/bindings/perl/ccs/Makefile.PL
+++ /dev/null
@@ -1,28 +0,0 @@
-use ExtUtils::MakeMaker;
-
-my %INFOS = (
- 'NAME' => 'Cluster::CCS',
- 'VERSION_FROM' => 'CCS.pm', # finds $VERSION
- 'AUTHOR' => 'Fabio M. Di Nitto <fdinitto(a)redhat.com>',
- 'ABSTRACT' => 'Interface to Cluster Configuration Service library',
-);
-
-# read extra configurations from the commandline
-my %params;
-@params{qw(DEBUG DEFINE EXTRALIBDIR GDOME INC LIBS SKIP_SAX_INSTALL XMLPREFIX)}=();
-
-@ARGV = grep {
- my ($key, $val) = split(/=/, $_, 2);
- if (exists $params{$key}) {
- $config{$key} = $val; 0
- } else { 1 }
-} @ARGV;
-
-$extralibdir = $config{EXTRALIBDIR};
-delete $config{EXTRALIBDIR};
-
-WriteMakefile(
- %INFOS,
- %config,
-);
-
diff --git a/bindings/perl/ccs/Makefile.bindings b/bindings/perl/ccs/Makefile.bindings
deleted file mode 100644
index 9818a89..0000000
--- a/bindings/perl/ccs/Makefile.bindings
+++ /dev/null
@@ -1,13 +0,0 @@
-include ../../../make/defines.mk
-
-PMTARGET = CCS.pm
-
-TARGET = $(PMTARGET)
-
-CFLAGS += -I${ccsincdir}
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${ccslibdir} -lccs
-LDFLAGS += -L${libdir}
-
-include $(OBJDIR)/make/perl-binding-common.mk
diff --git a/bindings/perl/ccs/test.pl b/bindings/perl/ccs/test.pl
deleted file mode 100644
index 64d740d..0000000
--- a/bindings/perl/ccs/test.pl
+++ /dev/null
@@ -1,20 +0,0 @@
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl test.pl'
-
-######################### We start with some black magic to print on failure.
-
-# Change 1..1 below to 1..last_test_to_print .
-# (It may become useful if the test is moved to ./t subdirectory.)
-
-BEGIN { $| = 1; print "1..1\n"; }
-END {print "not ok 1\n" unless $loaded;}
-use Cluster::CCS;
-$loaded = 1;
-print "ok 1\n";
-
-######################### End of black magic.
-
-# Insert your test code below (better if it prints "ok 13"
-# (correspondingly "not ok 13") depending on the success of chunk 13
-# of the test code):
-
diff --git a/bindings/perl/ccs/typemap b/bindings/perl/ccs/typemap
deleted file mode 100644
index 02522e8..0000000
--- a/bindings/perl/ccs/typemap
+++ /dev/null
@@ -1 +0,0 @@
-TYPEMAP
diff --git a/bindings/python/Makefile b/bindings/python/Makefile
deleted file mode 100644
index 810b2d4..0000000
--- a/bindings/python/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../../make/defines.mk
-include $(OBJDIR)/make/passthrough.mk
-
-SUBDIRS=
diff --git a/cman/Makefile b/cman/Makefile
deleted file mode 100644
index 1cf8bc9..0000000
--- a/cman/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../make/defines.mk
-include $(OBJDIR)/make/passthrough.mk
-
-SUBDIRS=lib cman_tool daemon qdisk notifyd init.d man scripts
diff --git a/cman/cman_tool/Makefile b/cman/cman_tool/Makefile
deleted file mode 100644
index 77b48db..0000000
--- a/cman/cman_tool/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-TARGET= cman_tool
-
-SBINDIRT=$(TARGET)
-
-all: depends ${TARGET}
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-OBJS= main.o \
- join.o
-
-CFLAGS += -DCOROSYNCBIN=\"${corosyncbin}\" -DSBINDIR=\"${sbindir}\"
-CFLAGS += -I${cmanincdir} -I${ccsincdir}
-CFLAGS += -I${corosyncincdir}
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${cmanlibdir} -lcman -L${ccslibdir} -lccs
-LDFLAGS += -L${corosynclibdir} -lconfdb
-LDFLAGS += -L${libdir}
-
-${TARGET}: ${OBJS}
- $(CC) -o $@ $^ $(LDFLAGS)
-
-depends:
- $(MAKE) -C ../lib all
-
-clean: generalclean
-
--include $(OBJS:.o=.Tpo)
diff --git a/cman/cman_tool/cman_tool.h b/cman/cman_tool/cman_tool.h
deleted file mode 100644
index 6c5744e..0000000
--- a/cman/cman_tool/cman_tool.h
+++ /dev/null
@@ -1,109 +0,0 @@
-#ifndef __CMAN_TOOL_DOT_H__
-#define __CMAN_TOOL_DOT_H__
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/utsname.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <limits.h>
-
-extern char *prog_name;
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-#define die(fmt, args...) \
-do { \
- fprintf(stderr, "%s: ", prog_name); \
- fprintf(stderr, fmt "\n", ##args); \
- exit(EXIT_FAILURE); \
-} while (0)
-
-#define DEFAULT_VOTES 1
-#define MAX_INTERFACES 10
-#define MAX_FORMAT_OPTS 10
-#define MAX_NODE_NAME_LEN 65
-#define MAX_MCAST_NAME_LEN 256
-#define MAX_PATH_LEN 256
-
-#define DEBUG_STARTUP_ONLY 32
-
-enum format_opt
-{
- FMT_NONE,
- FMT_ID,
- FMT_NAME,
- FMT_TYPE,
- FMT_ADDR,
- FMT_VOTES,
- FMT_EXP,
- FMT_STATE,
-};
-
-enum validate_options
-{
- VALIDATE_FAIL = 0,
- VALIDATE_WARN,
- VALIDATE_NONE,
-};
-
-struct commandline
-{
- int operation;
- int num_nodenames;
- char *multicast_addr;
- char *nodenames[MAX_INTERFACES];
- char *interfaces[MAX_INTERFACES];
- char *override_nodename;
- char *key_filename;
- char *filename;
- char *format_opts;
- char *config_lcrso;
- int votes;
- int expected_votes;
- int two_node;
- int port;
- char clustername[MAX_CLUSTER_NAME_LEN];
- int remove;
- int force;
- int verbose;
- int nostderr_debug;
- int nodeid;
- int timeout;
- unsigned int config_version;
-
- int config_version_opt;
- int config_validate_opt;
- int votes_opt;
- int expected_votes_opt;
- int port_opt;
- int nodeid_opt;
- int clustername_opt;
- int wait_opt;
- int wait_quorate_opt;
- int addresses_opt;
- int noconfig_opt;
- int nosync_opt;
- int nosetpri_opt;
- int noopenais_opt;
-};
-typedef struct commandline commandline_t;
-
-int join(commandline_t *comline);
-
-#endif /* __CMAN_TOOL_DOT_H__ */
diff --git a/cman/cman_tool/join.c b/cman/cman_tool/join.c
deleted file mode 100644
index 44c8d69..0000000
--- a/cman/cman_tool/join.c
+++ /dev/null
@@ -1,396 +0,0 @@
-#include <errno.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <stdint.h>
-#include <signal.h>
-#include <netinet/in.h>
-#include <corosync/confdb.h>
-#include "libcman.h"
-#include "cman_tool.h"
-
-#define MAX_ARGS 128
-
-static char *argv[MAX_ARGS];
-static char *envp[MAX_ARGS];
-
-static void be_daemon(void)
-{
- int devnull = open("/dev/null", O_RDWR);
- if (devnull == -1) {
- perror("Can't open /dev/null");
- exit(3);
- }
-
- /* Detach ourself from the calling environment */
- if (close(0) || close(1)) {
- die("Error closing terminal FDs");
- }
-
- if (dup2(devnull, 0) < 0 || dup2(devnull, 1) < 0) {
- die("Error setting terminal FDs to /dev/null: %m");
- }
-
- /* We leave stderr open to allow error messags through.
- the cman plugin will close it when it's all started
- up properly.
- */
- setsid();
-}
-
-
-static const char *corosync_exit_reason(signed char status)
-{
- static char reason[256];
- switch (status) {
- case 1:
- return "Could not determine UID to run as";
- break;
- case 2:
- return "Could not determine GID to run as";
- break;
- case 3:
- return "Error initialising memory pool";
- break;
- case 4:
- return "Could not fork";
- break;
- case 5:
- return "Could not bind to libais socket";
- break;
- case 6:
- return "Could not bind to network socket";
- break;
- case 7:
- return "Could not read security key for communications";
- break;
- case 8:
- return "Could not read cluster configuration";
- break;
- case 9:
- return "Could not set up logging";
- break;
- case 11:
- return "Could not dynamically load modules";
- break;
- case 12:
- return "Could not load and initialise object database";
- break;
- case 13:
- return "Could not initialise all required services";
- break;
- case 14:
- return "Out of memory";
- break;
- case 15:
- return "Fatal error";
- break;
- case 16:
- return "Required directory not present /var/lib/corosync.";
- break;
- case 17:
- return "Could not acquire lock";
- break;
- case 18:
- return "Another Corosync instance is already running";
- break;
- default:
- snprintf(reason, sizeof(reason) - 1, "Error, reason code is %d", status);
- return reason;
- break;
- }
-}
-
-static int check_corosync_status(pid_t pid)
-{
- int status;
- int pidstatus;
-
- status = waitpid(pid, &pidstatus, WNOHANG);
- if (status == -1 && errno == ECHILD) {
-
- return 0;
- }
- if (status == pid && pidstatus != 0) {
- if (WIFEXITED(pidstatus))
- fprintf(stderr, "corosync died: %s\n", corosync_exit_reason(WEXITSTATUS(pidstatus)));
- if (WIFSIGNALED(pidstatus))
- fprintf(stderr, "corosync died with signal: %d\n", WTERMSIG(pidstatus));
- exit(1);
- }
- return status;
-}
-
-int join(commandline_t *comline)
-{
- int i;
- int envptr = 0;
- int argvptr = 0;
- char scratch[1024];
- char config_modules[1024];
- cman_handle_t h = NULL;
- int status;
- hdb_handle_t object_handle;
- confdb_handle_t confdb_handle;
- int res;
- pid_t corosync_pid;
- int p[2];
- confdb_callbacks_t callbacks = {
- .confdb_key_change_notify_fn = NULL,
- .confdb_object_create_change_notify_fn = NULL,
- .confdb_object_delete_change_notify_fn = NULL
- };
-
- /*
- * If we can talk to cman then we're already joined (or joining);
- */
- h = cman_admin_init(NULL);
- if (h)
- die("Node is already active");
-
- /* Set up environment variables for override */
- if (comline->multicast_addr) {
- snprintf(scratch, sizeof(scratch), "CMAN_MCAST_ADDR=%s", comline->multicast_addr);
- envp[envptr++] = strdup(scratch);
- }
- if (comline->votes_opt) {
- snprintf(scratch, sizeof(scratch), "CMAN_VOTES=%d", comline->votes);
- envp[envptr++] = strdup(scratch);
- }
- if (comline->expected_votes_opt) {
- snprintf(scratch, sizeof(scratch), "CMAN_EXPECTEDVOTES=%d", comline->expected_votes);
- envp[envptr++] = strdup(scratch);
- }
- if (comline->port) {
- snprintf(scratch, sizeof(scratch), "CMAN_IP_PORT=%d", comline->port);
- envp[envptr++] = strdup(scratch);
- }
- if (comline->nodeid) {
- snprintf(scratch, sizeof(scratch), "CMAN_NODEID=%d", comline->nodeid);
- envp[envptr++] = strdup(scratch);
- }
- if (comline->clustername_opt) {
- snprintf(scratch, sizeof(scratch), "CMAN_CLUSTER_NAME=%s", comline->clustername);
- envp[envptr++] = strdup(scratch);
- }
- if (comline->nodenames[0]) {
- snprintf(scratch, sizeof(scratch), "CMAN_NODENAME=%s", comline->nodenames[0]);
- envp[envptr++] = strdup(scratch);
- }
- if (comline->key_filename) {
- snprintf(scratch, sizeof(scratch), "CMAN_KEYFILE=%s", comline->key_filename);
- envp[envptr++] = strdup(scratch);
- }
- if (comline->two_node) {
- snprintf(scratch, sizeof(scratch), "CMAN_2NODE=true");
- envp[envptr++] = strdup(scratch);
- }
- if (comline->verbose ^ DEBUG_STARTUP_ONLY) {
- snprintf(scratch, sizeof(scratch), "CMAN_DEBUG=%d", comline->verbose);
- envp[envptr++] = strdup(scratch);
- }
- if (comline->nostderr_debug) {
- snprintf(scratch, sizeof(scratch), "CMAN_NOSTDERR_DEBUG=true");
- envp[envptr++] = strdup(scratch);
- }
- if (comline->noconfig_opt) {
- envp[envptr++] = strdup("CMAN_NOCONFIG=true");
- snprintf(config_modules, sizeof(config_modules), "cmanpreconfig%s",
- comline->noopenais_opt?"":":openaisserviceenablestable");
- }
- else {
- snprintf(config_modules, sizeof(config_modules), "%s:cmanpreconfig%s", comline->config_lcrso,
- comline->noopenais_opt?"":":openaisserviceenablestable");
- }
- snprintf(scratch, sizeof(scratch), "COROSYNC_DEFAULT_CONFIG_IFACE=%s", config_modules);
- envp[envptr++] = strdup(scratch);
-
- /* Copy any COROSYNC_* env variables to the new daemon */
- i=0;
- while (i < MAX_ARGS && __environ[i]) {
- if (strncmp(__environ[i], "COROSYNC_", 9) == 0)
- envp[envptr++] = __environ[i];
- i++;
- }
-
-
- /* Create a pipe to monitor cman startup progress */
- if (pipe(p) < 0)
- die("unable to create pipe: %s", strerror(errno));
- fcntl(p[1], F_SETFD, 0); /* Don't close on exec */
- snprintf(scratch, sizeof(scratch), "CMAN_PIPE=%d", p[1]);
- envp[envptr++] = strdup(scratch);
- envp[envptr++] = NULL;
-
- /* Always run corosync -f because we have already forked twice anyway, and
- we want to return any exit code that might happen */
- /* also strdup strings because it's otherwise virtually impossible to fix
- * build warnings due to the way argv C implementation is done */
- argv[0] = strdup("corosync");
- argv[++argvptr] = strdup("-f");
- if (comline->nosetpri_opt)
- argv[++argvptr] = strdup("-p");
- argv[++argvptr] = NULL;
-
- /* Fork/exec cman */
- switch ( (corosync_pid = fork()) )
- {
- case -1:
- die("fork of corosync daemon failed: %s", strerror(errno));
-
- case 0: /* child */
- close(p[0]);
- if (comline->verbose & DEBUG_STARTUP_ONLY) {
- fprintf(stderr, "Starting %s", COROSYNCBIN);
- for (i=0; i< argvptr; i++) {
- fprintf(stderr, " %s", argv[i]);
- }
- fprintf(stderr, "\n");
- for (i=0; i<envptr-1; i++) {
- fprintf(stderr, "%s\n", envp[i]);
- }
- }
- be_daemon();
-
- sprintf(scratch, "FORKED: %d\n", getpid());
- write(p[1], scratch, strlen(scratch));
-
- execve(COROSYNCBIN, argv, envp);
-
- /* exec failed - tell the parent process */
- sprintf(scratch, "execve of " COROSYNCBIN " failed: %s", strerror(errno));
- write(p[1], scratch, strlen(scratch));
- exit(1);
- break;
-
- default: /* parent */
- break;
-
- }
-
- /* Give the daemon a chance to start up, and monitor the pipe FD for messages */
- i = 0;
- close(p[1]);
-
- /* Wait for the process to start or die */
- sleep(1);
- do {
- fd_set fds;
- struct timeval tv={1, 0};
- char message[1024];
- char *messageptr = message;
-
- FD_ZERO(&fds);
- FD_SET(p[0], &fds);
-
- status = select(p[0]+1, &fds, NULL, NULL, &tv);
-
- /* Did we get a cman-reported error? */
- if (status == 1) {
- int len;
- if ((len = read(p[0], message, sizeof(message) - 1) > 0)) {
- message[sizeof(message) - 1] = '\0';
-
- /* Forked OK - get the real corosync pid */
- if ((messageptr) && (sscanf(messageptr, "FORKED: %d", &corosync_pid) == 1)) {
- if (comline->verbose & DEBUG_STARTUP_ONLY)
- fprintf(stderr, "forked process ID is %d\n", corosync_pid);
- status = 0;
-
- /* There might be a SUCCESS or error message in the pipe too. */
- messageptr = strchr(messageptr, '\n');
- if (messageptr && strlen(messageptr) > 1)
- messageptr++;
- else
- continue;
- }
- /* Success! get the new PID of double-forked corosync */
- if ((messageptr) && (sscanf(messageptr, "SUCCESS: %d", &corosync_pid) == 1)) {
- if (comline->verbose & DEBUG_STARTUP_ONLY)
- fprintf(stderr, "corosync running, process ID is %d\n", corosync_pid);
- status = 0;
- break;
- }
- else if (messageptr) {
- fprintf(stderr, "%s\n", messageptr);
- status = 1;
- break;
- }
- }
- else if (len < 0 && errno == EINTR) {
- continue;
- }
- else { /* Error or EOF - check the child status */
- status = check_corosync_status(corosync_pid);
- if (status == 0)
- break;
- }
- }
-
- } while (status == 0);
- close(p[0]);
-
- /* If corosync has started, try to connect to cman ... if it's still there */
- if (status == 0) {
- do {
- if (status == 0) {
- if (kill(corosync_pid, 0) < 0) {
- status = check_corosync_status(corosync_pid);
- die("corosync died during startup\n");
- }
-
- h = cman_admin_init(NULL);
- if (!h && comline->verbose & DEBUG_STARTUP_ONLY)
- {
- fprintf(stderr, "waiting for cman to start\n");
- status = check_corosync_status(corosync_pid);
- }
- }
- sleep (1);
- } while (!h && ++i < 100);
- }
-
- if (!h)
- die("corosync daemon didn't start");
-
- if ((comline->verbose & DEBUG_STARTUP_ONLY) && !cman_is_active(h))
- fprintf(stderr, "corosync started, but not joined the cluster yet.\n");
-
- cman_finish(h);
-
- /* Copy all COROSYNC_* environment variables into objdb so they can be used to validate new configurations later */
- res = confdb_initialize (&confdb_handle, &callbacks);
- if (res != CS_OK)
- goto join_exit;
-
- res = confdb_object_create(confdb_handle, OBJECT_PARENT_HANDLE, "cman_private", strlen("cman_private"), &object_handle);
- if (res == CS_OK) {
- int envnum = 0;
- const char *envvar = __environ[envnum];
- const char *equal;
- char envname[PATH_MAX];
-
-
- while (envvar) {
- if (strncmp("COROSYNC_", envvar, 9) == 0) {
- equal = strchr(envvar, '=');
- if (equal) {
- strncpy(envname, envvar, PATH_MAX);
- if (equal-envvar < PATH_MAX) {
- envname[equal-envvar] = '\0';
-
- res = confdb_key_create_typed(confdb_handle, object_handle, envname,
- equal+1, strlen(equal+1),CONFDB_VALUETYPE_STRING);
- }
- }
- }
- envvar = __environ[++envnum];
- }
- }
- res = confdb_key_create_typed(confdb_handle, object_handle,
- "COROSYNC_DEFAULT_CONFIG_IFACE",
- config_modules, strlen(config_modules), CONFDB_VALUETYPE_STRING);
- confdb_finalize (confdb_handle);
-
-join_exit:
- return 0;
-}
diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c
deleted file mode 100644
index 6946e9e..0000000
--- a/cman/cman_tool/main.c
+++ /dev/null
@@ -1,1297 +0,0 @@
-#include <errno.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <signal.h>
-#include <time.h>
-#include <corosync/confdb.h>
-#include <netinet/in.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include "copyright.cf"
-#include "libcman.h"
-#include "cman_tool.h"
-
-#define DEFAULT_CONFIG_MODULE "xmlconfig"
-
-#define OPTION_STRING ("m:n:v:e:2p:c:i:N:t:o:k:F:C:VAPwfqazh?XD::Sd::r::")
-#define OP_JOIN 1
-#define OP_LEAVE 2
-#define OP_EXPECTED 3
-#define OP_VOTES 4
-#define OP_KILL 5
-#define OP_VERSION 6
-#define OP_WAIT 7
-#define OP_STATUS 8
-#define OP_NODES 9
-#define OP_SERVICES 10
-#define OP_DEBUG 11
-
-static void print_usage(int subcmd)
-{
- printf("Usage:\n");
- printf("\n");
- printf("%s <join|leave|kill|expected|votes|version|wait|status|nodes|services|debug> [options]\n",
- prog_name);
- printf("\n");
- printf("Options:\n");
- printf(" -h Print this help, then exit\n");
- printf(" -V Print program version information, then exit\n");
- printf(" -d Enable debug output\n");
- printf("\n");
-
- if (!subcmd || subcmd == OP_JOIN) {
- printf("join\n");
- printf(" Cluster & node information is taken from configuration modules.\n");
- printf(" These switches are provided to allow those values to be overridden.\n");
- printf(" Use them with extreme care.\n\n");
-
- printf(" -m <addr> Multicast address to use\n");
- printf(" -v <votes> Number of votes this node has\n");
- printf(" -e <votes> Number of expected votes for the cluster\n");
- printf(" -p <port> UDP port number for cman communications\n");
- printf(" -n <nodename> The name of this node (defaults to hostname)\n");
- printf(" -c <clustername> The name of the cluster to join\n");
- printf(" -N <id> Node id\n");
- printf(" -C <module> Config file reader (default: " DEFAULT_CONFIG_MODULE ")\n");
- printf(" -w Wait until node has joined a cluster\n");
- printf(" -q Wait until the cluster is quorate\n");
- printf(" -t Maximum time (in seconds) to wait\n");
- printf(" -k <file> Private key file for Corosync communications\n");
- printf(" -P Don't set corosync to realtime priority\n");
- printf(" -X Use internal cman defaults for configuration\n");
- printf(" -A Don't load openais services\n");
- printf(" -D<fail|warn|none> What to do about the config. Default (without -D) is to\n");
- printf(" validate the config. with -D no validation will be done.\n");
- printf(" -Dwarn will print errors but allow the operation to continue.\n");
- printf(" -z Disable stderr debugging output.\n");
- printf("\n");
- }
-
-
- if (!subcmd || subcmd == OP_WAIT) {
- printf("wait Wait until the node is a member of a cluster\n");
- printf(" -q Wait until the cluster is quorate\n");
- printf(" -t Maximum time (in seconds) to wait\n");
- printf("\n");
- }
-
- if (!subcmd || subcmd == OP_LEAVE) {
- printf("leave\n");
- printf(" -w If cluster is in transition, wait and keep trying\n");
- printf(" -t Maximum time (in seconds) to wait\n");
- printf(" remove Tell other nodes to ajust quorum downwards if necessary\n");
- printf(" force Leave even if cluster subsystems are active\n");
- printf("\n");
- }
-
- if (!subcmd || subcmd == OP_KILL) {
- printf("kill\n");
- printf(" -n <nodename> The name of the node to kill (can specify multiple times)\n");
- printf("\n");
- }
-
- if (!subcmd || subcmd == OP_EXPECTED) {
- printf("expected\n");
- printf(" -e <votes> New number of expected votes for the cluster\n");
- printf("\n");
- }
-
- if (!subcmd || subcmd == OP_VOTES) {
- printf("votes\n");
- printf(" -v <votes> New number of votes for this node\n");
- printf("\n");
- }
-
- if (!subcmd || subcmd == OP_STATUS) {
- printf("status Show local record of cluster status\n");
- printf("\n");
- }
-
- if (!subcmd || subcmd == OP_NODES) {
- printf("nodes Show local record of cluster nodes\n");
- printf(" -a Also show node address(es)\n");
- printf(" -n <nodename> Only show information for specific node\n");
- printf(" -F <format> Specify output format (see man page)\n");
- printf("\n");
- }
-
- if (!subcmd || subcmd == OP_SERVICES) {
- printf("services Show local record of cluster services\n");
- printf("\n");
- }
-
- if (!subcmd || subcmd == OP_VERSION) {
- printf("version\n");
- printf(" -r Reload cluster.conf and update config version.\n");
- printf(" -D <fail,warn,none> What to do about the config. Default (without -D) is to\n");
- printf(" validate the config. with -D no validation will be done. -Dwarn will print errors\n");
- printf(" but allow the operation to continue\n");
- printf(" -S Don't run ccs_sync to distribute cluster.conf (if appropriate)\n");
- printf("\n");
- }
-}
-
-static void sigalarm_handler(int sig)
-{
- fprintf(stderr, "Timed-out waiting for cluster\n");
- exit(2);
-}
-
-static cman_handle_t open_cman_handle(int priv)
-{
- cman_handle_t h;
-
- if (priv)
- h = cman_admin_init(NULL);
- else
- h = cman_init(NULL);
- if (!h)
- {
- if (errno == EACCES)
- die("Cannot open connection to cman, permission denied.");
- else
- die("Cannot open connection to cman, is it running ?");
- }
- return h;
-}
-
-static void print_address(char *addr)
-{
- char buf[INET6_ADDRSTRLEN];
- struct sockaddr_storage *ss = (struct sockaddr_storage *)addr;
- struct sockaddr_in *sin = (struct sockaddr_in *)addr;
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
- void *saddr;
-
- if (ss->ss_family == AF_INET6)
- saddr = &sin6->sin6_addr;
- else
- saddr = &sin->sin_addr;
-
- if (inet_ntop(ss->ss_family, saddr, buf, sizeof(buf)))
- printf("%s", buf);
- else
- printf("none");
-}
-
-static char *membership_state(char *buf, int buflen, int node_state)
-{
- switch (node_state) {
- case 1:
- strncpy(buf, "Joining", buflen);
- break;
- case 2:
- strncpy(buf, "Cluster-Member", buflen);
- break;
- case 3:
- strncpy(buf, "Not-in-Cluster", buflen);
- break;
- case 4:
- strncpy(buf, "Leaving", buflen);
- break;
- default:
- snprintf(buf, buflen - 1, "Unknown: code=%d", node_state);
- break;
- }
-
- return buf;
-}
-
-static const char *cman_error(int err)
-{
- const char *die_error;
-
- switch (err) {
- case ENOTCONN:
- die_error = "Cluster software not started";
- break;
- case ENOENT:
- die_error = "Node is not yet a cluster member";
- break;
- default:
- die_error = strerror(err);
- break;
- }
- return die_error;
-}
-
-static void show_status(void)
-{
- cman_cluster_t info;
- cman_version_t v;
- cman_handle_t h;
- cman_node_t node;
- char info_buf[PIPE_BUF];
- char tmpbuf[1024];
- cman_extra_info_t *einfo = (cman_extra_info_t *)info_buf;
- cman_qdev_info_t qinfo;
- int quorate;
- int i;
- int j;
- int portnum;
- char *addrptr;
-
- h = open_cman_handle(0);
-
- if (cman_get_cluster(h, &info) < 0)
- die("Error getting cluster info: %s\n", cman_error(errno));
- if (cman_get_version(h, &v) < 0)
- die("Error getting cluster version: %s\n", cman_error(errno));
- if (cman_get_extra_info(h, einfo, sizeof(info_buf)) < 0)
- die("Error getting extra info: %s\n", cman_error(errno));
-
- quorate = cman_is_quorate(h);
-
- printf("Version: %d.%d.%d\n", v.cv_major, v.cv_minor, v.cv_patch);
- printf("Config Version: %d\n", v.cv_config);
- printf("Cluster Name: %s\n", info.ci_name);
- printf("Cluster Id: %d\n", info.ci_number);
- printf("Cluster Member: Yes\n");
- printf("Cluster Generation: %d\n", info.ci_generation);
- printf("Membership state: %s\n", membership_state(tmpbuf, sizeof(tmpbuf),
- einfo->ei_node_state));
- printf("Nodes: %d\n", einfo->ei_members);
- printf("Expected votes: %d\n", einfo->ei_expected_votes);
- if (cman_get_quorum_device(h, &qinfo) == 0 && qinfo.qi_state == 2)
- printf("Quorum device votes: %d\n", qinfo.qi_votes);
- printf("Total votes: %d\n", einfo->ei_total_votes);
- printf("Node votes: %d\n", einfo->ei_node_votes);
-
- printf("Quorum: %d %s\n", einfo->ei_quorum, quorate?" ":"Activity blocked");
- printf("Active subsystems: %d\n", cman_get_subsys_count(h));
- printf("Flags:");
- if (einfo->ei_flags & CMAN_EXTRA_FLAG_2NODE)
- printf(" 2node");
- if (einfo->ei_flags & CMAN_EXTRA_FLAG_SHUTDOWN)
- printf(" Shutdown");
- if (einfo->ei_flags & CMAN_EXTRA_FLAG_ERROR)
- printf(" Error");
- if (einfo->ei_flags & CMAN_EXTRA_FLAG_DISALLOWED)
- printf(" DisallowedNodes");
- if (einfo->ei_flags & CMAN_EXTRA_FLAG_DISALLOWED_ENABLED)
- printf(" DisallowedEnabled");
- if (einfo->ei_flags & CMAN_EXTRA_FLAG_DIRTY)
- printf(" HaveState");
- printf(" \n");
-
- printf("Ports Bound: ");
- portnum = 0;
- for (i=0; i<32; i++) {
- for (j=0; j<8; j++) {
- if ((einfo->ei_ports[i] >> j) & 1)
- printf("%d ", portnum);
- portnum++;
- }
- }
- printf(" \n");
-
- node.cn_name[0] = 0;
- if (cman_get_node(h, CMAN_NODEID_US, &node) == 0) {
- printf("Node name: %s\n", node.cn_name);
- printf("Node ID: %u\n", node.cn_nodeid);
- }
-
- printf("Multicast addresses: ");
- addrptr = einfo->ei_addresses;
- for (i=0; i < einfo->ei_num_addresses; i++) {
- print_address(addrptr);
- printf(" ");
- addrptr += sizeof(struct sockaddr_storage);
- }
- printf("\n");
-
- printf("Node addresses: ");
- for (i=0; i < einfo->ei_num_addresses; i++) {
- print_address(addrptr);
- printf(" ");
- addrptr += sizeof(struct sockaddr_storage);
- }
- printf("\n");
-
- if (einfo->ei_flags & CMAN_EXTRA_FLAG_DISALLOWED) {
- int count;
- int numnodes;
- cman_node_t *nodes;
-
- count = cman_get_node_count(h);
- nodes = malloc(sizeof(cman_node_t) * count);
-
- if (cman_get_disallowed_nodes(h, count, &numnodes, nodes) == 0) {
- printf("Disallowed nodes: ");
- for (i=0; i<numnodes; i++) {
- printf("%s ", nodes[i].cn_name);
- }
- printf("\n");
- }
- }
- cman_finish(h);
-}
-
-static int node_compare(const void *va, const void *vb)
-{
- const cman_node_t *a = va;
- const cman_node_t *b = vb;
- return a->cn_nodeid - b->cn_nodeid;
-}
-
-static int node_filter(commandline_t *comline, const char *node)
-{
- int i;
-
- for (i = 0; i < comline->num_nodenames; i++) {
- if (strcmp(comline->nodenames[i], node) == 0) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static int get_format_opt(const char *opt)
-{
- if (!opt)
- return FMT_NONE;
-
- if (!strcmp(opt, "id"))
- return FMT_ID;
- if (!strcmp(opt, "name"))
- return FMT_NAME;
- if (!strcmp(opt, "type"))
- return FMT_TYPE;
- if (!strcmp(opt, "addr"))
- return FMT_ADDR;
- if (!strcmp(opt, "votes"))
- return FMT_VOTES;
- if (!strcmp(opt, "exp"))
- return FMT_EXP;
- if (!strcmp(opt, "state"))
- return FMT_STATE;
-
- return FMT_NONE;
-}
-
-
-static void print_node(commandline_t *comline, cman_handle_t h, int *format, struct cman_node *node)
-{
- char member_type;
- struct tm *jtime;
- int numaddrs=1;
- struct cman_node_address addrs[MAX_INTERFACES];
- char jstring[1024];
- int i,j,k;
- unsigned int tmpid;
- cman_node_extra_t enode;
-
- if (comline->num_nodenames > 0) {
- if (node_filter(comline, node->cn_name) == 0) {
- return;
- }
- }
-
- switch (node->cn_member) {
- case 0:
- member_type = 'X';
- break;
- case 1:
- member_type = 'M';
- break;
- case 2:
- member_type = 'd';
- break;
- default:
- member_type = '?';
- break;
- }
-
- /* Make the name more friendly if cman can't find it in cluster.conf
- * (we really don't want corosync to look up names in DNS so it invents them)
- */
- if (sscanf(node->cn_name, "Node%u", &tmpid) == 1 && tmpid == node->cn_nodeid) {
- if (!cman_get_node_addrs(h, node->cn_nodeid, MAX_INTERFACES, &numaddrs, addrs) && numaddrs) {
- getnameinfo((struct sockaddr *)addrs[0].cna_address, addrs[0].cna_addrlen, node->cn_name, sizeof(node->cn_name), NULL, 0, NI_NAMEREQD);
- }
- }
-
- jtime = localtime(&node->cn_jointime.tv_sec);
- if (node->cn_jointime.tv_sec && node->cn_member)
- strftime(jstring, sizeof(jstring), "%F %H:%M:%S", jtime);
- else
- strncpy(jstring, " ", sizeof(jstring));
-
- if (!comline->format_opts) {
- printf("%4u %c %5d %s %s\n",
- node->cn_nodeid, member_type,
- node->cn_incarnation, jstring, node->cn_name);
- }
-
- if (comline->addresses_opt || comline->format_opts) {
- if (node->cn_nodeid > 0) {
- if (!cman_get_node_addrs(h, node->cn_nodeid, MAX_INTERFACES, &numaddrs, addrs) &&
- numaddrs) {
- if (!comline->format_opts) {
- printf(" Addresses: ");
- for (i = 0; i < numaddrs; i++)
- {
- print_address(addrs[i].cna_address);
- printf(" ");
- }
- printf("\n");
- }
- }
- }
- }
-
- if (comline->format_opts && (cman_get_node_extra(h, node->cn_nodeid, &enode) == 0)) {
- for (j = 0; j < MAX_FORMAT_OPTS; j++) {
- switch (format[j]) {
- case FMT_NONE:
- break;
- case FMT_ID:
- printf("%u ", node->cn_nodeid);
- break;
- case FMT_NAME:
- printf("%s ", node->cn_name);
- break;
- case FMT_TYPE:
- printf("%c ", member_type);
- break;
- case FMT_VOTES:
- printf("%d ", enode.cnx_votes);
- break;
- case FMT_EXP:
- printf("%d ", enode.cnx_expected_votes);
- break;
- case FMT_STATE:
- switch (enode.cnx_state)
- {
- case CLUSTER_NODESTATE_JOINING:
- printf("Joining ");
- break;
- case CLUSTER_NODESTATE_MEMBER:
- printf("Member ");
- break;
- case CLUSTER_NODESTATE_DEAD:
- printf("Dead ");
- break;
- case CLUSTER_NODESTATE_LEAVING:
- printf("Leaving ");
- break;
- case CLUSTER_NODESTATE_DISALLOWED:
- printf("Disallowed ");
- break;
- default:
- printf("Unknown ");
- break;
- }
- break;
- case FMT_ADDR:
- for (k = 0; k < numaddrs; k++) {
- print_address(addrs[k].cna_address);
- if (k != (numaddrs - 1)) {
- printf(",");
- }
- }
- printf(" ");
- break;
- default:
- break;
- }
- }
- printf("\n");
- }
-}
-
-static void show_nodes(commandline_t *comline)
-{
- cman_handle_t h;
- int count;
- int i;
- int j;
- int numnodes;
- int dis_count;
- int format[MAX_FORMAT_OPTS];
- cman_node_t *dis_nodes;
- cman_node_t *nodes;
-
- h = open_cman_handle(0);
-
- count = cman_get_node_count(h);
- if (count < 0)
- die("cman_get_node_count failed: %s", cman_error(errno));
-
- count += 2; /* Extra space! */
-
- nodes = malloc(sizeof(cman_node_t) * count);
- if (!nodes)
- die("cannot allocate memory for nodes list\n");
-
- if (comline->format_opts != NULL) {
- char *format_str = comline->format_opts;
- char *format_tmp;
- for (i = 0; i < MAX_FORMAT_OPTS; i++) {
- format_tmp = strtok(format_str, ",");
- format_str = NULL;
- format[i] = get_format_opt(format_tmp);
- }
- }
-
- if (cman_get_nodes(h, count, &numnodes, nodes) < 0)
- die("cman_get_nodes failed: %s", cman_error(errno));
-
-
- /* Get Disallowed nodes, so we can show them as such */
- dis_nodes = malloc(sizeof(cman_node_t) * count);
-
- if (!dis_nodes)
- die("cannot allocate memory for disallowed node\n");
-
- if (cman_get_disallowed_nodes(h, count, &dis_count, dis_nodes) == 0) {
- for (i = 0; i < numnodes; i++) {
- for (j = 0; j < dis_count; j++) {
- if (dis_nodes[j].cn_nodeid == nodes[i].cn_nodeid)
- nodes[i].cn_member = 2;
- }
- }
- }
-
- /* Sort by nodeid to be friendly */
- qsort(nodes, numnodes, sizeof(cman_node_t), node_compare);
-
- if (dis_count) {
- printf("NOTE: There are %d disallowed nodes,\n", dis_count);
- printf(" members list may seem inconsistent across the cluster\n");
- }
-
- if (!comline->format_opts) {
- printf("Node Sts Inc Joined Name\n");
- }
-
- /* Print nodes */
- for (i = 0; i < numnodes; i++) {
- print_node(comline, h, format, &nodes[i]);
- }
-
- free(nodes);
- free(dis_nodes);
- cman_finish(h);
-}
-
-static int show_services(void)
-{
- return system("group_tool ls");
-}
-
-
-static void leave(commandline_t *comline)
-{
- cman_handle_t h;
- int result;
- int flags = 0;
-
- h = open_cman_handle(1);
-
- /* "cman_tool leave remove" adjusts quorum downward */
-
- if (comline->remove)
- flags |= CMAN_SHUTDOWN_REMOVED;
-
- if (comline->force)
- flags |= CMAN_SHUTDOWN_ANYWAY;
-
- if (comline->wait_opt && comline->timeout) {
- signal(SIGALRM, sigalarm_handler);
- alarm(comline->timeout);
- }
-
- result = cman_shutdown(h, flags);
- if (result && !comline->wait_opt) {
- die("Error leaving cluster: %s", cman_error(errno));
- }
- cman_finish(h);
-
- /* Wait until cman shuts down */
- if (comline->wait_opt) {
- while ( (h = cman_admin_init(NULL)) ) {
- cman_finish(h);
- sleep(1);
- }
- }
-}
-
-static void set_expected(commandline_t *comline)
-{
- cman_handle_t h;
-
- h = open_cman_handle(1);
-
- if (cman_set_expected_votes(h, comline->expected_votes))
- die("can't set expected votes: %s", cman_error(errno));
-
- cman_finish(h);
-}
-
-static void set_votes(commandline_t *comline)
-{
- cman_handle_t h;
- int nodeid;
- struct cman_node node;
-
-
- h = open_cman_handle(1);
-
- if (!comline->num_nodenames) {
- nodeid = 0; /* This node */
- }
- else {
- /* Resolve node name into a number */
- node.cn_nodeid = 0;
- strncpy(node.cn_name, comline->nodenames[0], CMAN_MAX_NODENAME_LEN);
- if (cman_get_node(h, node.cn_nodeid, &node))
- die("Can't set votes for node %s : %s\n", node.cn_name, strerror(errno));
- nodeid = node.cn_nodeid;
- }
-
- if (cman_set_votes(h, comline->votes, nodeid))
- die("can't set votes: %s", cman_error(errno));
-
- cman_finish(h);
-}
-
-static int validate_config(commandline_t *comline, int current_version)
-{
- struct stat st;
- char command[PATH_MAX];
- char validator[PATH_MAX];
- char ccs_quiet[8];
- int cmd_res;
-
- /* Look for ccs_config_validate */
- snprintf(validator, sizeof(validator), "%s/ccs_config_validate", SBINDIR);
- if (stat(validator, &st) != 0 || !(st.st_mode & S_IXUSR)) {
- fprintf(stderr, "Cannot find ccs_config_validate, configuration was not checked but assumed to be OK.\n");
- return 0;
- }
-
- if (comline->verbose > 1) {
- snprintf(ccs_quiet, sizeof(ccs_quiet), " ");
- } else {
- snprintf(ccs_quiet, sizeof(ccs_quiet), "-q");
- }
-
- if (current_version) {
- snprintf(command, sizeof(command), "%s %s -R %d",
- validator, ccs_quiet, current_version);
- } else {
- snprintf(command, sizeof(command), "%s %s",
- validator, ccs_quiet);
- }
-
- if (comline->verbose > 1)
- printf("calling '%s'\n", command);
-
- cmd_res = system(command);
-
- return WEXITSTATUS(cmd_res);
-}
-
-/* Here we set the COROSYNC_ variables that might be needed by the corosync
- configuration modules. We just put them into the environment and leave
- them for the sub-process to pick up.
- 'config_modules' is returned separately because it's needed internally to
- and it saves the caller from extracting it all over again.
- We only return 0 (success) if config_modules is returned as without that
- the caller can't really do anything at all.
-*/
-static int get_config_variables(commandline_t *comline, char **config_modules)
-{
- int res;
- int got_iface = 1;
- char key_name[1024];
- char *key_value = NULL;
- size_t key_value_len;
- confdb_value_types_t type;
- hdb_handle_t confdb_handle;
- hdb_handle_t cmanp_handle;
- confdb_callbacks_t callbacks = {
- .confdb_key_change_notify_fn = NULL,
- .confdb_object_create_change_notify_fn = NULL,
- .confdb_object_delete_change_notify_fn = NULL
- };
-
- *config_modules = NULL;
- res = confdb_initialize (&confdb_handle, &callbacks);
- if (res != CS_OK)
- return 0;
-
- res = confdb_object_find_start(confdb_handle, OBJECT_PARENT_HANDLE);
- if (res != CS_OK)
- goto finish;
-
- res = confdb_object_find(confdb_handle, OBJECT_PARENT_HANDLE, "cman_private", strlen("cman_private"), &cmanp_handle);
- if (res != CS_OK)
- goto finish;
-
- res = confdb_key_iter_start(confdb_handle, cmanp_handle);
- if (res != CS_OK)
- goto finish;
-
- while ( (res = confdb_key_iter_typed2(confdb_handle, cmanp_handle, key_name,
- (void**)&key_value, &key_value_len, &type)) == CS_OK) {
- key_value[key_value_len] = '\0';
-
- setenv(key_name, key_value, 1);
- if (strcmp(key_name, "COROSYNC_DEFAULT_CONFIG_IFACE") == 0) {
- *config_modules = strdup(key_value);
- got_iface = 0;
- }
- free(key_value);
- key_value = NULL;
- }
-
-finish:
- confdb_finalize(confdb_handle);
- return got_iface;
-}
-
-static void version(commandline_t *comline)
-{
- struct cman_version ver;
- cman_handle_t h;
- int result;
- char *config_modules = NULL;
-
- h = open_cman_handle(1);
-
- if ((result = cman_get_version(h, &ver)))
- die("can't get version: %s", cman_error(errno));
-
- if (!comline->config_version_opt) {
- printf("%d.%d.%d config %d\n", ver.cv_major, ver.cv_minor, ver.cv_patch,
- ver.cv_config);
- goto out;
- }
-
- if (comline->verbose)
- printf("Getting config variables\n");
- if (get_config_variables(comline, &config_modules))
- die("cannot get COROSYNC_DEFAULT_CONFIG_IFACE");
-
- /* By default we validate the configuration first */
- if (comline->config_validate_opt != VALIDATE_NONE) {
-
- if (comline->verbose)
- printf("Validating configuration\n");
- result = validate_config(comline, ver.cv_config);
- if (result == 253)
- /* Unable to find new config version */
- die("Unable to retrive the new config version\n");
- if (result == 254)
- /* Config regression = fail. */
- die("Not reloading, config version older or equal the running config");
- if (result == 255)
- /* Generic error from ccs_config_validate */
- die("Not reloading, generic error running ccs_config_validate\n"
- "Try re-running with -d options");
- else if (result && comline->config_validate_opt == VALIDATE_FAIL)
- die("Not reloading, configuration is not valid");
- }
-
- /* We don't bother looking for ccs_sync here - just assume it's in /usr/bin and
- that it exists. If this is not true then then user can choose to bypass
- the disibution and do it themselves.
- Note that ccs_sync might prompt on stderr for passwords the first time it is
- run.
- */
- if (strstr(config_modules, "xmlconfig") && !comline->nosync_opt) {
- if (comline->verbose > 1)
- printf("calling ccs_sync\n");
- result = system("/usr/bin/ccs_sync");
- if (result)
- die("ccs_sync failed.\nIf you have distributed the config file yourself, try re-running with -S\n");
- }
-
- if (comline->verbose)
- printf("Telling cman the new version number\n");
-
- ver.cv_config = comline->config_version;
-
- result = cman_set_version(h, &ver);
-
- switch(result) {
- case 0:
- if (comline->verbose)
- printf("Configuration succesfully updated or already running\n");
- break;
- default:
- die("Error loading configuration in corosync/cman");
- break;
- }
- out:
- cman_finish(h);
-}
-
-static int cluster_wait(commandline_t *comline)
-{
- cman_handle_t h;
- int ret = 0;
-
- h = open_cman_handle(0);
-
- if (comline->wait_quorate_opt) {
- while (cman_is_quorate(h) <= 0) {
- sleep(1);
- }
- }
- else {
- while (cman_get_node_count(h) < 0) {
- sleep(1);
- }
- }
-
- cman_finish(h);
-
- return ret;
-}
-
-static void kill_node(commandline_t *comline)
-{
- cman_handle_t h;
- int i;
- struct cman_node node;
-
- if (!comline->num_nodenames) {
- die("No node name specified\n");
- }
-
- h = open_cman_handle(1);
-
- for (i=0; i<comline->num_nodenames; i++) {
-
- /* Resolve node name into a number */
- node.cn_nodeid = 0;
- strncpy(node.cn_name, comline->nodenames[i], CMAN_MAX_NODENAME_LEN);
- if (cman_get_node(h, node.cn_nodeid, &node)) {
- fprintf(stderr, "Can't kill node %s : %s\n", node.cn_name, strerror(errno));
- continue;
- }
-
-
- if (cman_kill_node(h, node.cn_nodeid))
- perror("kill node failed");
- }
-
- cman_finish(h);
-}
-
-static void set_debuglog(commandline_t *comline)
-{
- cman_handle_t h;
-
- h = open_cman_handle(1);
-
- if (cman_set_debuglog(h, comline->verbose))
- perror("setting debuglog failed");
-
- cman_finish(h);
-}
-
-static int get_int_arg(char argopt, char *arg)
-{
- char *tmp;
- int val;
-
- val = strtol(arg, &tmp, 10);
- if (tmp == arg || tmp != arg + strlen(arg))
- die("argument to %c (%s) is not an integer", argopt, arg);
-
- if (val < 0)
- die("argument to %c cannot be negative", argopt);
-
- return val;
-}
-
-
-static void decode_arguments(int argc, char *argv[], commandline_t *comline)
-{
- int cont = TRUE;
- int optchar, i;
- int suboptchar;
- int show_help = 0;
- char buf[16];
-
- while (cont) {
- optchar = getopt(argc, argv, OPTION_STRING);
-
- switch (optchar) {
-
- case 'm':
- comline->multicast_addr = strdup(optarg);
- break;
-
- case 'a':
- comline->addresses_opt = 1;
- break;
-
- case 'D':
- /* Just look at the upper-cased version of the first letter of the argument */
- if (optarg) {
- suboptchar = optarg[0] & 0x5F;
- switch (suboptchar)
- {
- case 'F':
- comline->config_validate_opt = VALIDATE_FAIL;
- break;
- case 'W':
- comline->config_validate_opt = VALIDATE_WARN;
- break;
- case 'N':
- comline->config_validate_opt = VALIDATE_NONE;
- break;
- default:
- die("invalid option to -D, it should be 'force', 'warn' or 'none'\n");
- break;
- }
- }
- else {
- comline->config_validate_opt = VALIDATE_NONE;
- }
- break;
- case 'S':
- comline->nosync_opt = 1;
- break;
-
- case 'n':
- i = comline->num_nodenames;
- if (i >= MAX_INTERFACES)
- die("maximum of %d node names allowed",
- MAX_INTERFACES);
- if (strlen(optarg) > MAX_NODE_NAME_LEN)
- die("maximum node name length is %d",
- MAX_NODE_NAME_LEN);
- comline->nodenames[i] = strdup(optarg);
- comline->num_nodenames++;
- break;
-
- case 'o':
- comline->override_nodename = strdup(optarg);
- break;
-
- case 'k':
- comline->key_filename = strdup(optarg);
- break;
-
- case 'C':
- comline->config_lcrso = strdup(optarg);
- break;
-
- case 'r':
- comline->config_version = 0;
- comline->config_version_opt = TRUE;
- if (optarg) {
- fprintf(stderr, "Warning: specifying a "
- "version for the -r flag is "
- "deprecated and no longer used\n");
- }
- break;
-
- case 'v':
- comline->votes = get_int_arg(optchar, optarg);
- comline->votes_opt = TRUE;
- break;
-
- case 'e':
- comline->expected_votes = get_int_arg(optchar, optarg);
- comline->expected_votes_opt = TRUE;
- break;
-
- case '2':
- comline->two_node = TRUE;
- break;
-
- case 'p':
- comline->port = get_int_arg(optchar, optarg);
- comline->port_opt = TRUE;
- break;
-
- case 'N':
- comline->nodeid = get_int_arg(optchar, optarg);
- comline->nodeid_opt = TRUE;
- break;
-
- case 'c':
- if (strlen(optarg) > MAX_NODE_NAME_LEN-1)
- die("maximum cluster name length is %d",
- MAX_CLUSTER_NAME_LEN-1);
- strncpy(comline->clustername, optarg, sizeof(comline->clustername) - 1);
- comline->clustername_opt = TRUE;
- break;
-
- case 'F':
- comline->format_opts = strdup(optarg);
- break;
-
- case 'V':
- printf("cman_tool %s (built %s %s)\n",
- RELEASE_VERSION, __DATE__, __TIME__);
- printf("%s\n", REDHAT_COPYRIGHT);
- exit(EXIT_SUCCESS);
- break;
-
- case 'h':
- show_help = 1;
- break;
-
- case ':':
- case '?':
- fprintf(stderr, "Please use '-h' for usage.\n");
- exit(EXIT_FAILURE);
- break;
-
- case 'd':
- if (optarg)
- comline->verbose = atoi(optarg);
- else
- comline->verbose = 255;
- break;
-
- case 'z':
- comline->nostderr_debug = 1;
- break;
-
- case 'w':
- comline->wait_opt = TRUE;
- break;
-
- case 'q':
- comline->wait_quorate_opt = TRUE;
- break;
-
- case 't':
- comline->timeout = get_int_arg(optchar, optarg);
- break;
-
- case EOF:
- cont = FALSE;
- break;
-
- case 'X':
- comline->noconfig_opt = TRUE;
- break;
-
- case 'A':
- comline->noopenais_opt = TRUE;
- break;
-
- case 'P':
- comline->nosetpri_opt = TRUE;
- break;
- default:
- die("unknown option: %c", optchar);
- break;
- };
- }
-
- if (comline->config_lcrso == NULL)
- comline->config_lcrso = strdup(DEFAULT_CONFIG_MODULE);
-
- while (optind < argc) {
- if (strcmp(argv[optind], "join") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_JOIN;
- } else if (strcmp(argv[optind], "leave") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_LEAVE;
- } else if (strcmp(argv[optind], "expected") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_EXPECTED;
- } else if (strcmp(argv[optind], "votes") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_VOTES;
- } else if (strcmp(argv[optind], "kill") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_KILL;
- } else if (strcmp(argv[optind], "version") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_VERSION;
- } else if (strcmp(argv[optind], "wait") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_WAIT;
- } else if (strcmp(argv[optind], "status") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_STATUS;
- } else if (strcmp(argv[optind], "nodes") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_NODES;
- } else if (strcmp(argv[optind], "services") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_SERVICES;
- } else if (strcmp(argv[optind], "debug") == 0) {
- if (comline->operation)
- die("can't specify two operations");
- comline->operation = OP_DEBUG;
- } else if (strcmp(argv[optind], "remove") == 0) {
- comline->remove = TRUE;
- } else if (strcmp(argv[optind], "force") == 0) {
- comline->force = TRUE;
- } else {
- snprintf(buf, sizeof(buf),
- "%d", atoi(argv[optind]));
- if (!strcmp(buf, argv[optind]) &&
- (comline->config_version_opt == TRUE) &&
- comline->operation == OP_VERSION) {
- fprintf(stderr, "Warning: specifying a "
- "version for the -r flag is "
- "deprecated and no longer used\n");
- } else {
- die("unknown option %s", argv[optind]);
- }
- }
-
- optind++;
- }
-
- if (show_help) {
- print_usage(comline->operation);
- exit(EXIT_SUCCESS);
- }
-
- if (!comline->operation)
- die("no operation specified");
-}
-
-static void check_arguments(commandline_t *comline)
-{
- if (comline->two_node && comline->expected_votes != 1)
- die("expected_votes value (%d) invalid in two node mode",
- comline->expected_votes);
-
- if (comline->port_opt &&
- (comline->port <= 0 || comline->port > 65535))
- die("Port must be a number between 1 and 65535");
-
- /* This message looks like it contradicts the condition but
- a nodeid of zero simply means "assign one for me" and is a
- perfectly reasonable override */
- if (comline->nodeid < 0 || comline->nodeid > 4096)
- die("Node id must be between 1 and 4096");
-
- if (strlen(comline->clustername) > MAX_CLUSTER_NAME_LEN) {
- die("Cluster name must be < %d characters long",
- MAX_CLUSTER_NAME_LEN);
- }
-
- if (comline->timeout && !comline->wait_opt && !comline->wait_quorate_opt)
- die("timeout is only appropriate with wait");
-}
-
-
-static void do_join(commandline_t *comline)
-{
- int ret;
-
- check_arguments(comline);
-
- if (comline->timeout) {
- signal(SIGALRM, sigalarm_handler);
- alarm(comline->timeout);
- }
-
- /* By default we validate the configuration first */
- if (comline->config_validate_opt != VALIDATE_NONE) {
-
- if (comline->verbose)
- printf("Validating configuration\n");
-
- if (validate_config(comline, 0) &&
- comline->config_validate_opt == VALIDATE_FAIL)
- die("Not joining, configuration is not valid\n");
- }
-
- join(comline);
- if (comline->wait_opt || comline->wait_quorate_opt) {
- do {
- ret = cluster_wait(comline);
- if (ret == ENOTCONN)
- join(comline);
-
- } while (ret == ENOTCONN);
- }
-}
-
-int main(int argc, char *argv[])
-{
- commandline_t comline;
-
- prog_name = argv[0];
-
- memset(&comline, 0, sizeof(commandline_t));
-
- decode_arguments(argc, argv, &comline);
-
- switch (comline.operation) {
- case OP_JOIN:
- do_join(&comline);
- break;
-
- case OP_LEAVE:
- leave(&comline);
- break;
-
- case OP_EXPECTED:
- set_expected(&comline);
- break;
-
- case OP_VOTES:
- set_votes(&comline);
- break;
-
- case OP_KILL:
- kill_node(&comline);
- break;
-
- case OP_VERSION:
- version(&comline);
- break;
-
- case OP_WAIT:
- if (comline.timeout) {
- signal(SIGALRM, sigalarm_handler);
- alarm(comline.timeout);
- }
- cluster_wait(&comline);
- break;
-
- case OP_STATUS:
- show_status();
- break;
-
- case OP_NODES:
- show_nodes(&comline);
- break;
-
- case OP_SERVICES:
- if (show_services() < 0) {
- fprintf(stderr, "Unable to invoke group_tool\n");
- exit(EXIT_FAILURE);
- }
- break;
-
- case OP_DEBUG:
- set_debuglog(&comline);
- break;
- }
-
- exit(EXIT_SUCCESS);
-}
-
-char *prog_name;
diff --git a/cman/daemon/Makefile b/cman/daemon/Makefile
deleted file mode 100644
index a2672e9..0000000
--- a/cman/daemon/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-TARGET1= service_cman.lcrso
-TARGET2= config_cmanpre.lcrso
-
-LCRSOT=$(TARGET1) $(TARGET2)
-
-all: depends ${TARGET1} ${TARGET2}
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -I${openaisincdir} -I${corosyncincdir}
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${libdir}
-
-OBJS1= daemon.o \
- ais.o \
- commands.o \
- barrier.o \
- cmanconfig.o
-
-OBJS2= cman-preconfig.o \
- fnvhash.o
-
-${TARGET1}: ${OBJS1}
- $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
-
-${TARGET2}: ${OBJS2}
- $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
-
-depends:
- $(MAKE) -C ../lib all
-
-clean: generalclean
-
--include $(OBJS1:.o=.Tpo)
--include $(OBJS2:.o=.Tpo)
diff --git a/cman/daemon/ais.c b/cman/daemon/ais.c
deleted file mode 100644
index ea5020c..0000000
--- a/cman/daemon/ais.c
+++ /dev/null
@@ -1,378 +0,0 @@
-#include <sys/poll.h>
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/socket.h>
-#include <sys/utsname.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <inttypes.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-/* corosync headers */
-#include <corosync/corotypes.h>
-#include <corosync/corotypes.h>
-#include <corosync/coroipc_types.h>
-#include <corosync/coroipcc.h>
-#include <corosync/corodefs.h>
-#include <corosync/mar_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-#include <corosync/engine/quorum.h>
-#include <corosync/lcr/lcr_comp.h>
-
-#include "list.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "commands.h"
-
-#include "ais.h"
-#include "cman.h"
-#define OBJDB_API struct corosync_api_v1
-#include "nodelist.h"
-#include "cmanconfig.h"
-#include "daemon.h"
-
-extern char cluster_name[MAX_CLUSTER_NAME_LEN+1];
-extern unsigned int quorumdev_poll;
-extern unsigned int ccsd_poll_interval;
-extern unsigned int enable_disallowed;
-extern unsigned int shutdown_timeout;
-extern unsigned int startup_config_timeout;
-extern int init_config(struct corosync_api_v1 *api);
-
-struct totem_ip_address mcast_addr[MAX_INTERFACES];
-struct totem_ip_address ifaddrs[MAX_INTERFACES];
-int num_interfaces;
-uint64_t incarnation;
-int num_ais_nodes;
-quorum_set_quorate_fn_t corosync_set_quorum;
-struct memb_ring_id cman_ring_id;
-extern unsigned int config_version;
-static hdb_handle_t cluster_parent_handle;
-
-static int startup_pipe;
-static int first_trans = 1;
-struct corosync_api_v1 *corosync;
-
-static hdb_handle_t group_handle;
-static struct corosync_tpg_group cman_group[1] = {
- { .group = "CMAN", .group_len = 4},
-};
-
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME);
-
-/* This structure is tacked onto the start of a cluster message packet for our
- * own nefarious purposes. */
-struct cl_protheader {
- unsigned char tgtport; /* Target port number */
- unsigned char srcport; /* Source (originating) port number */
- unsigned short pad;
- unsigned int flags;
- int srcid; /* Node ID of the sender */
- int tgtid; /* Node ID of the target */
-};
-
-/* Plugin-specific code */
-/* Need some better way of determining these.... */
-#define CMAN_SERVICE 9
-
-static int cman_exit_fn(void *conn_info);
-static int cman_exec_init_fn(struct corosync_api_v1 *api);
-static void cman_confchg_fn(enum totem_configuration_type configuration_type,
- const unsigned int *member_list, size_t member_list_entries,
- const unsigned int *left_list, size_t left_list_entries,
- const unsigned int *joined_list, size_t joined_list_entries,
- const struct memb_ring_id *ring_id);
-static void cman_deliver_fn(unsigned int nodeid, const void *msg, unsigned int msg_len,
- int endian_conversion_required);
-static void cman_quorum_init(struct corosync_api_v1 *api, quorum_set_quorate_fn_t report);
-
-/*
- * Exports the interface for the service
- */
-static struct corosync_service_engine cman_service_handler = {
- .name = (char *)"corosync CMAN membership service 2.90",
- .id = CMAN_SERVICE,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED,
- .lib_exit_fn = cman_exit_fn,
- .exec_init_fn = cman_exec_init_fn,
- .config_init_fn = NULL,
- .sync_mode = CS_SYNC_V1,
-};
-
-static struct corosync_service_engine *cman_get_handler_ver0(void)
-{
- return (&cman_service_handler);
-}
-
-static struct corosync_service_engine_iface_ver0 cman_service_handler_iface = {
- .corosync_get_service_engine_ver0 = cman_get_handler_ver0
-};
-static struct quorum_services_api_ver1 cman_quorum_iface_ver0 = {
- .init = cman_quorum_init
-};
-
-static struct lcr_iface ifaces_ver0[2] = {
- {
- .name = "corosync_cman",
- .version = 0,
- .versions_replace = 0,
- .versions_replace_count = 0,
- .dependencies = 0,
- .dependency_count = 0,
- .constructor = NULL,
- .destructor = NULL,
- .interfaces = NULL,
- },
- {
- .name = "quorum_cman",
- .version = 0,
- .versions_replace = 0,
- .versions_replace_count = 0,
- .dependencies = 0,
- .dependency_count = 0,
- .constructor = NULL,
- .destructor = NULL,
- .interfaces = (void **)(void *)&cman_quorum_iface_ver0,
- },
-};
-
-static struct lcr_comp cman_comp_ver0 = {
- .iface_count = 2,
- .ifaces = ifaces_ver0,
-};
-
-
-__attribute__ ((constructor)) static void cman_comp_register(void) {
- lcr_interfaces_set(&ifaces_ver0[0], &cman_service_handler_iface);
- lcr_interfaces_set(&ifaces_ver0[1], &cman_quorum_iface_ver0);
- lcr_component_register(&cman_comp_ver0);
-}
-
-/* ------------------------------- */
-
-static void cman_quorum_init(struct corosync_api_v1 *api, quorum_set_quorate_fn_t report)
-{
- corosync = api;
- corosync_set_quorum = report;
-}
-
-static int cman_exec_init_fn(struct corosync_api_v1 *api)
-{
- hdb_handle_t object_handle;
- hdb_handle_t find_handle;
- hdb_handle_t totem_handle;
- char pipe_msg[256];
- unsigned int totem_token;
-
- corosync = api;
-
- if (getenv("CMAN_PIPE"))
- startup_pipe = atoi(getenv("CMAN_PIPE"));
-
- /* Get our config variables */
- corosync->object_find_create(OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &find_handle);
- corosync->object_find_next(find_handle, &cluster_parent_handle);
- corosync->object_find_destroy(find_handle);
-
- /*
- * quorum_dev_poll should default to the token timeout so that quorum devices behave
- * like nodes
- */
- corosync->object_find_create(OBJECT_PARENT_HANDLE, "totem", strlen("totem"), &find_handle);
- corosync->object_find_next(find_handle, &totem_handle);
- objdb_get_int(api, totem_handle, "token", &totem_token, 1000);
- corosync->object_find_destroy(find_handle);
-
- corosync->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
- if (corosync->object_find_next(find_handle, &object_handle) == 0)
- {
- objdb_get_int(api, object_handle, "quorum_dev_poll", &quorumdev_poll, totem_token);
- objdb_get_int(api, object_handle, "shutdown_timeout", &shutdown_timeout, DEFAULT_SHUTDOWN_TIMEOUT);
- objdb_get_int(api, object_handle, "ccsd_poll", &ccsd_poll_interval, DEFAULT_CCSD_POLL);
- objdb_get_int(api, object_handle, "disallowed", &enable_disallowed, DEFAULT_DISALLOWED);
- objdb_get_int(api, object_handle, "startup_config_timeout", &startup_config_timeout, DEFAULT_STARTUP_CONFIG_TIMEOUT);
- }
- corosync->object_find_destroy(find_handle);
- log_printf(LOGSYS_LEVEL_DEBUG, CMAN_NAME " starting");
-
- /* Open local sockets and initialise I/O queues */
- if (read_cman_config(api, &config_version)) {
- /* An error message will have been written to cman_pipe */
- exit(9);
- }
- cman_init(api);
-
- /* Let cman_tool know we are running and our PID */
- snprintf(pipe_msg, sizeof(pipe_msg) - 1,"SUCCESS: %d", getpid());
- write_cman_pipe(pipe_msg);
- close(startup_pipe);
- startup_pipe = 0;
-
- /* Start totem */
- api->tpg_init(&group_handle, cman_deliver_fn, cman_confchg_fn);
- api->tpg_join(group_handle, cman_group, 1);
-
- if (getenv("CMAN_NOSTDERR_DEBUG")) {
- int tmpfd;
- tmpfd = open("/dev/null", O_RDWR);
- if (tmpfd > -1 && tmpfd != STDERR_FILENO) {
- dup2(tmpfd, STDERR_FILENO);
- close(tmpfd);
- }
- }
-
- return 0;
-}
-
-
-int cman_exit_fn(void *conn_info)
-{
- cman_finish();
- return 0;
-}
-
-/* END Plugin-specific code */
-
-int comms_send_message(void *buf, int len,
- unsigned char toport, unsigned char fromport,
- int nodeid,
- unsigned int flags)
-{
- struct iovec iov[2];
- struct cl_protheader header;
- int totem_flags = TOTEM_AGREED;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "ais: comms send message %p len = %d\n", buf,len);
- header.tgtport = toport;
- header.srcport = fromport;
- header.flags = flags;
- header.srcid = our_nodeid();
- header.tgtid = nodeid;
-
- iov[0].iov_base = &header;
- iov[0].iov_len = sizeof(header);
- iov[1].iov_base = buf;
- iov[1].iov_len = len;
-
- if (flags & MSG_TOTEM_SAFE)
- totem_flags = TOTEM_SAFE;
-
- return corosync->tpg_joined_mcast(group_handle, iov, 2, totem_flags);
-}
-
-static void cman_deliver_fn(unsigned int nodeid, const void *msg, unsigned int msg_len,
- int endian_conversion_required)
-{
- const struct cl_protheader *original_header = msg;
- struct cl_protheader header;
- const char *buf = msg;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "ais: deliver_fn source nodeid = %d, len=%d, endian_conv=%d\n",
- nodeid, msg_len, endian_conversion_required);
-
- if (endian_conversion_required) {
- header.srcid = swab32(original_header->srcid);
- header.tgtid = swab32(original_header->tgtid);
- header.flags = swab32(original_header->flags);
- header.srcport = original_header->srcport;
- header.tgtport = original_header->tgtport;
- }
- else {
- memcpy(&header, original_header, sizeof(header));
- }
-
- /* Only pass on messages for us or everyone */
- if (header.tgtid == our_nodeid() ||
- header.tgtid == 0) {
- send_to_userport(header.srcport, header.tgtport,
- header.srcid, header.tgtid,
- buf + sizeof(struct cl_protheader), msg_len - sizeof(struct cl_protheader),
- endian_conversion_required);
- }
-}
-
-static void cman_confchg_fn(enum totem_configuration_type configuration_type,
- const unsigned int *member_list, size_t member_list_entries,
- const unsigned int *left_list, size_t left_list_entries,
- const unsigned int *joined_list, size_t joined_list_entries,
- const struct memb_ring_id *ring_id)
-{
- int i;
- static int last_memb_count = 0;
- static size_t saved_left_list_entries;
- static size_t saved_left_list_size;
- static unsigned int *saved_left_list = NULL;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "ais: confchg_fn called type = %d, seq=%lld\n", configuration_type, ring_id->seq);
-
- memcpy(&cman_ring_id, ring_id, sizeof(*ring_id));
- incarnation = ring_id->seq;
- num_ais_nodes = member_list_entries;
-
- /* Tell the cman membership layer */
- for (i=0; i<left_list_entries; i++)
- del_ais_node(left_list[i]);
-
- /* Joining nodes are only added after a valid TRANSITION message
- * is received.
- */
-
- /* Save the left list for later so we can do a consolidated confchg message */
- if (configuration_type == TOTEM_CONFIGURATION_TRANSITIONAL) {
- if (saved_left_list == NULL) {
- saved_left_list_size = left_list_entries*2;
- saved_left_list = malloc(sizeof(int) * saved_left_list_size);
- if (!saved_left_list) {
- log_printf(LOGSYS_LEVEL_CRIT, "cannot allocate memory for confchg message");
- exit(3);
- }
- }
- if (saved_left_list_size < left_list_entries) {
- saved_left_list_size = left_list_entries*2;
- saved_left_list = realloc(saved_left_list, sizeof(int) * saved_left_list_size);
- if (!saved_left_list) {
- log_printf(LOGSYS_LEVEL_CRIT, "cannot reallocate memory for confchg message");
- exit(3);
- }
- }
- saved_left_list_entries = left_list_entries;
- memcpy(saved_left_list, left_list, left_list_entries * sizeof(int));
- }
-
- if (configuration_type == TOTEM_CONFIGURATION_REGULAR) {
- log_printf(LOGSYS_LEVEL_DEBUG, "ais: last memb_count = %d, current = %"PRIuFAST32"\n", last_memb_count, member_list_entries);
- send_transition_msg(last_memb_count, first_trans);
- last_memb_count = member_list_entries;
- if (member_list_entries > 1)
- first_trans = 0;
-
- cman_send_confchg(member_list, member_list_entries,
- saved_left_list, saved_left_list_entries,
- joined_list, joined_list_entries);
- }
-}
-
-void corosync_shutdown(void)
-{
- corosync->shutdown_request();
-}
-
-/* Write an error message down the CMAN startup pipe so
- that cman_tool can display it */
-int write_cman_pipe(const char *message)
-{
- if (startup_pipe)
- return write(startup_pipe, message, strlen(message)+1);
-
- return 0;
-}
diff --git a/cman/daemon/ais.h b/cman/daemon/ais.h
deleted file mode 100644
index 44b1a8c..0000000
--- a/cman/daemon/ais.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <corosync/engine/quorum.h>
-/* DLM Currently maxes out at 3 ! */
-#define MAX_INTERFACES 8
-
-extern int ais_add_ifaddr(char *mcast, char *ifaddr, int portnum);
-extern int comms_send_message(void *buf, int len,
- unsigned char toport, unsigned char fromport,
- int nodeid,
- unsigned int flags);
-extern uint64_t incarnation;
-extern int num_ais_nodes;
-extern quorum_set_quorate_fn_t corosync_set_quorum;
-extern struct memb_ring_id cman_ring_id;
-extern void corosync_shutdown(void);
diff --git a/cman/daemon/barrier.c b/cman/daemon/barrier.c
deleted file mode 100644
index c356abe..0000000
--- a/cman/daemon/barrier.c
+++ /dev/null
@@ -1,469 +0,0 @@
-#include <getopt.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/signal.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/errno.h>
-
-#include <corosync/corotypes.h>
-#include <corosync/coroipc_types.h>
-#include <corosync/coroipcc.h>
-#include <corosync/corodefs.h>
-#include <corosync/mar_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-#include "list.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "daemon.h"
-#include "commands.h"
-#include "barrier.h"
-#include "cman.h"
-#include "ais.h"
-
-extern int we_are_a_cluster_member;
-
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME);
-
-/* A barrier */
-struct cl_barrier {
- struct list list;
-
- char name[MAX_BARRIER_NAME_LEN];
- unsigned int flags;
- enum { BARRIER_STATE_WAITING, BARRIER_STATE_INACTIVE,
- BARRIER_STATE_COMPLETE } state;
- unsigned int expected_nodes;
- unsigned int got_nodes;
- unsigned int waitsent;
- unsigned int phase; /* Completion phase */
- unsigned int endreason; /* Reason we were woken, usually 0 */
- unsigned int client_complete;
- unsigned long timeout; /* In seconds */
-
- struct connection *con;
- corosync_timer_handle_t timer;
-};
-extern struct corosync_api_v1 *corosync;
-
-/* A list of all current barriers */
-static struct list barrier_list;
-
-static void send_barrier_complete_msg(struct cl_barrier *barrier)
-{
- if (barrier->timeout) {
- corosync->timer_delete(barrier->timer);
- barrier->timeout = 0;
- }
-
- if (!barrier->client_complete) {
- if (barrier->con)
- send_status_return(barrier->con, CMAN_CMD_BARRIER, barrier->endreason);
- barrier->client_complete = 1;
- }
-}
-
-static struct cl_barrier *find_barrier(char *name)
-{
- struct list *blist;
- struct cl_barrier *bar;
-
- list_iterate(blist, &barrier_list) {
- bar = list_item(blist, struct cl_barrier);
-
- if (strcmp(name, bar->name) == 0)
- return bar;
- }
- return NULL;
-}
-
-/* Do the stuff we need to do when the barrier has completed phase 1 */
-static void check_barrier_complete_phase1(struct cl_barrier *barrier)
-{
- if (barrier->got_nodes == ((barrier->expected_nodes != 0)
- ? barrier->expected_nodes :
- cluster_members)) {
-
- struct cl_barriermsg bmsg;
-
- barrier->phase = 2; /* Wait for complete phase II */
-
- bmsg.cmd = CLUSTER_MSG_BARRIER;
- bmsg.subcmd = BARRIER_COMPLETE;
- strncpy(bmsg.name, barrier->name, MAX_BARRIER_NAME_LEN - 1);
-
- log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Sending COMPLETE for %s\n", barrier->name);
- comms_send_message((char *) &bmsg, sizeof (bmsg),
- 0, 0,
- 0,
- MSG_TOTEM_SAFE);
- }
-}
-
-/* Do the stuff we need to do when the barrier has been reached */
-/* Return 1 if we deleted the barrier */
-static int barrier_complete_phase2(struct cl_barrier *barrier, int status)
-{
- log_printf(LOGSYS_LEVEL_DEBUG, "barrier: complete_phase2 for %s\n", barrier->name);
-
- barrier->endreason = status;
-
- /* Wake up listener */
- if (barrier->state == BARRIER_STATE_WAITING) {
- send_barrier_complete_msg(barrier);
- }
- barrier->state = BARRIER_STATE_COMPLETE;
-
- /* Delete barrier if autodelete */
- if (barrier->flags & BARRIER_ATTR_AUTODELETE) {
- list_del(&barrier->list);
- free(barrier);
- return 1;
- }
-
- return 0;
-}
-
-/* Called if a barrier timeout happens */
-static void barrier_timer_fn(void *arg)
-{
- struct cl_barrier *barrier = arg;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Barrier timer_fn called for %s\n", barrier->name);
-
- /* Ignore any futher messages, they are too late. */
- barrier->phase = 0;
-
- /* and cause it to timeout */
- barrier_complete_phase2(barrier, -ETIMEDOUT);
-}
-
-static struct cl_barrier *alloc_barrier(char *name, int nodes)
-{
- struct cl_barrier *barrier;
-
- /* Build a new struct and add it to the list */
- barrier = malloc(sizeof (struct cl_barrier));
- if (barrier == NULL) {
- return NULL;
- }
- memset(barrier, 0, sizeof (*barrier));
-
- strncpy(barrier->name, name, MAX_BARRIER_NAME_LEN - 1);
- barrier->flags = 0;
- barrier->expected_nodes = nodes;
- barrier->got_nodes = 0;
- barrier->endreason = 0;
- barrier->state = BARRIER_STATE_INACTIVE;
-
- list_add(&barrier_list, &barrier->list);
- return barrier;
-}
-
-/* Process BARRIER messages from other nodes */
-void process_barrier_msg(struct cl_barriermsg *msg,
- struct cluster_node *node)
-{
- struct cl_barrier *barrier;
-
- /* Ignore other peoples' messages */
- if (!we_are_a_cluster_member)
- return;
-
- barrier = find_barrier(msg->name);
- if (!barrier)
- return;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Got %d for %s, from node %s\n", msg->subcmd, msg->name,
- node ? node->name : "unknown");
-
- switch (msg->subcmd) {
- case BARRIER_WAIT:
- if (barrier->phase == 0)
- barrier->phase = 1;
-
- if (barrier->phase == 1) {
- barrier->got_nodes++;
- check_barrier_complete_phase1(barrier);
- }
- break;
-
- case BARRIER_COMPLETE:
- /* Once we receive COMPLETE, we know that everyone has completed.
- I love VS */
- barrier_complete_phase2(barrier, 0);
- break;
- }
-}
-
-
-/* Barrier API */
-static int barrier_register(struct connection *con, char *name, unsigned int flags, unsigned int nodes)
-{
- struct cl_barrier *barrier;
-
- /* We are not joined to a cluster */
- if (!we_are_a_cluster_member)
- return -ENOTCONN;
-
- /* Must have a valid name */
- if (name == NULL || strlen(name) > MAX_BARRIER_NAME_LEN - 1)
- return -EINVAL;
-
- /* We don't do this yet */
- if (flags & BARRIER_ATTR_MULTISTEP)
- return -EINVAL;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "barrier: barrier_register %s, nodes = %d, flags =%x\n", name, nodes, flags);
-
- /* See if it already exists */
- if ((barrier = find_barrier(name))) {
- if (nodes != barrier->expected_nodes) {
- log_printf(LOG_ERR, "Barrier registration failed for '%s', expected nodes=%d, requested=%d\n",
- name, barrier->expected_nodes, nodes);
- return -EINVAL;
- }
- else {
- /* Fill this is as it may have been remote registered */
- barrier->con = con;
- return 0;
- }
- }
-
- barrier = alloc_barrier(name, nodes);
- if (!barrier)
- return -ENOMEM;
-
- barrier->flags = flags;
- barrier->con = con;
- return 0;
-}
-
-static int barrier_setattr_enabled(struct cl_barrier *barrier,
- unsigned int attr, unsigned long arg)
-{
- int status;
-
- /* Can't disable a barrier */
- if ((!barrier) || (!arg)) {
- return -EINVAL;
- }
-
- /* We need to send WAIT now because the user may not
- * actually call barrier_wait() */
- if (!barrier->waitsent) {
- struct cl_barriermsg bmsg;
-
- /* Send it to the rest of the cluster */
- bmsg.cmd = CLUSTER_MSG_BARRIER;
- bmsg.subcmd = BARRIER_WAIT;
- strncpy(bmsg.name, barrier->name, MAX_BARRIER_NAME_LEN - 1);
-
- barrier->waitsent = 1;
- barrier->phase = 1;
-
- /* Start the timer if one was wanted */
- if (barrier->timeout) {
- corosync->timer_add_duration((unsigned long long)barrier->timeout*1000000000ULL, barrier,
- barrier_timer_fn, &barrier->timer);
- }
-
- log_printf(LOGSYS_LEVEL_DEBUG, "barrier: Sending WAIT for %s\n", barrier->name);
- status = comms_send_message((char *)&bmsg, sizeof(bmsg), 0,0, 0, MSG_TOTEM_SAFE);
- if (status < 0) {
- return status;
- }
- }
- if (barrier->state == BARRIER_STATE_COMPLETE) {
- return barrier->endreason;
- }
- return 0; /* Nothing to propogate */
-}
-
-static int barrier_setattr(char *name, unsigned int attr, unsigned long arg)
-{
- struct cl_barrier *barrier;
-
- /* See if it already exists */
- if (!(barrier = find_barrier(name))) {
- return -ENOENT;
- }
-
- if (barrier->state == BARRIER_STATE_COMPLETE) {
- return 0;
- }
-
- switch (attr) {
- case BARRIER_SETATTR_AUTODELETE:
- if (arg)
- barrier->flags |= BARRIER_ATTR_AUTODELETE;
- else
- barrier->flags &= ~BARRIER_ATTR_AUTODELETE;
- return 0;
- break;
-
- case BARRIER_SETATTR_TIMEOUT:
- /* Can only change the timout of an inactive barrier */
- if (barrier->state == BARRIER_STATE_WAITING
- || barrier->waitsent) {
- return -EINVAL;
- }
- barrier->timeout = arg;
- return 0;
-
- case BARRIER_SETATTR_MULTISTEP:
- return -EINVAL;
-
- case BARRIER_SETATTR_ENABLED:
- return barrier_setattr_enabled(barrier, attr, arg);
-
- case BARRIER_SETATTR_NODES:
- /* Can only change the expected node count of an inactive
- * barrier */
- if (barrier->state == BARRIER_STATE_WAITING
- || barrier->waitsent)
- return -EINVAL;
- barrier->expected_nodes = arg;
- break;
- }
-
- return 0;
-}
-
-static int barrier_delete(char *name)
-{
- struct cl_barrier *barrier;
-
- /* See if it exists */
- if (!(barrier = find_barrier(name))) {
- return -ENOENT;
- }
-
- /* Delete it */
- list_del(&barrier->list);
- free(barrier);
- return 0;
-}
-
-static int barrier_wait(char *name)
-{
- struct cl_barrier *barrier;
-
- /* Enable it */
- barrier_setattr(name, BARRIER_SETATTR_ENABLED, 1L);
-
- /* See if it still exists - enable may have deleted it! */
- if (!(barrier = find_barrier(name))) {
- return -ENOENT;
- }
-
- /* If it has already completed then return the status */
- if (barrier->state == BARRIER_STATE_COMPLETE) {
- send_barrier_complete_msg(barrier);
- }
- else {
- barrier->state = BARRIER_STATE_WAITING;
- }
-
- /* User will wait */
- return -EWOULDBLOCK;
-}
-
-/* This is called from membership services when a node has left the cluster -
- * we signal all waiting barriers with ESRCH so they know to do something
- * else, if the number of nodes is left at 0 then we compare the new number of
- * nodes in the cluster with that at the barrier and return 0 (success) in that
- * case */
-void check_barrier_returns()
-{
- struct list *blist;
- struct cl_barrier *barrier;
- int status = 0;
-
- list_iterate(blist, &barrier_list) {
- barrier = list_item(blist, struct cl_barrier);
-
- if (barrier->waitsent) {
- int wakeit = 0;
-
- /* Check for a dynamic member barrier */
- if (barrier->expected_nodes == 0) {
- status = 0;
- wakeit = 1;
- }
- else {
- status = ESRCH;
- wakeit = 1;
- }
-
- /* Do we need to tell the barrier? */
- if (wakeit) {
- if (barrier->state == BARRIER_STATE_WAITING) {
- barrier->endreason = status;
- send_barrier_complete_msg(barrier);
- }
- }
- }
- }
-}
-
-/* Remote command */
-int do_cmd_barrier(struct connection *con, char *cmdbuf, int *retlen)
-{
- struct cl_barrier_info info;
-
- if (!we_are_a_cluster_member)
- return -ENOENT;
-
- memcpy(&info, cmdbuf, sizeof(info));
-
- switch (info.cmd) {
- case BARRIER_CMD_REGISTER:
- return barrier_register(con,
- info.name,
- info.flags,
- info.arg);
- case BARRIER_CMD_CHANGE:
- return barrier_setattr(info.name,
- info.flags,
- info.arg);
- case BARRIER_CMD_WAIT:
- return barrier_wait(info.name);
- case BARRIER_CMD_DELETE:
- return barrier_delete(info.name);
- default:
- return -EINVAL;
- }
-}
-
-/* Remove any barriers associated with this connection */
-void remove_barriers(struct connection *con)
-{
- struct list *blist, *tmp;
- struct cl_barrier *bar;
-
- list_iterate_safe(blist, tmp, &barrier_list) {
- bar = list_item(blist, struct cl_barrier);
-
- if (con == bar->con) {
- list_del(&bar->list);
- free(bar);
- }
- }
-}
-
-void barrier_init()
-{
- list_init(&barrier_list);
-}
diff --git a/cman/daemon/barrier.h b/cman/daemon/barrier.h
deleted file mode 100644
index 102d8b1..0000000
--- a/cman/daemon/barrier.h
+++ /dev/null
@@ -1,6 +0,0 @@
-void process_barrier_msg(struct cl_barriermsg *msg,
- struct cluster_node *node);
-int do_cmd_barrier(struct connection *con, char *cmdbuf, int *retlen);
-void barrier_init(void);
-void check_barrier_returns(void);
-void remove_barriers(struct connection *con);
diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
deleted file mode 100644
index 08b5ecf..0000000
--- a/cman/daemon/cman-preconfig.c
+++ /dev/null
@@ -1,1781 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
-#include <sys/utsname.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <netdb.h>
-#include <fcntl.h>
-#define SYSLOG_NAMES
-#include <sys/syslog.h>
-#include <ifaddrs.h>
-#include <arpa/inet.h>
-
-/* corosync headers */
-#include <corosync/engine/logsys.h>
-#include <corosync/lcr/lcr_comp.h>
-#include <corosync/engine/objdb.h>
-#include <corosync/engine/config.h>
-
-#include "cman.h"
-#define OBJDB_API struct objdb_iface_ver0
-#include "cnxman-socket.h"
-#include "nodelist.h"
-#include "fnvhash.h"
-
-#define MAX_PATH_LEN PATH_MAX
-
-enum tx_mech {
- TX_MECH_UDP,
- TX_MECH_UDPB,
- TX_MECH_UDPU,
- TX_MECH_RDMA,
-};
-
-static unsigned int debug;
-static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, const char **error_string);
-static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const char **error_string);
-
-static char *nodename_env;
-static int expected_votes;
-static int votes;
-static int num_interfaces;
-static int startup_pipe;
-static unsigned int cluster_id;
-static char nodename[MAX_CLUSTER_MEMBER_NAME_LEN];
-static int nodeid;
-static int two_node;
-static unsigned int disable_openais;
-static int num_nodenames;
-static char *key_filename=NULL;
-static char *cluster_name;
-static char error_reason[1024] = { '\0' };
-static hdb_handle_t cluster_parent_handle;
-static int use_hashed_cluster_id = 0;
-static unsigned int portnum = 0;
-static unsigned int altportnum = 0;
-static char *mcast_name = NULL;
-static char *altmcast_name = NULL;
-static unsigned int ttl = 1;
-static unsigned int altttl = 1;
-
-
-/*
- * Exports the interface for the service
- */
-static struct config_iface_ver0 cmanpreconfig_iface_ver0 = {
- .config_readconfig = cmanpre_readconfig,
- .config_reloadconfig = cmanpre_reloadconfig
-};
-
-static struct lcr_iface ifaces_ver0[2] = {
- {
- .name = "cmanpreconfig",
- .version = 0,
- .versions_replace = 0,
- .versions_replace_count = 0,
- .dependencies = 0,
- .dependency_count = 0,
- .constructor = NULL,
- .destructor = NULL,
- .interfaces = NULL,
- }
-};
-
-static struct lcr_comp cmanpre_comp_ver0 = {
- .iface_count = 1,
- .ifaces = ifaces_ver0,
-};
-
-
-
-__attribute__ ((constructor)) static void cmanpre_comp_register(void) {
- lcr_interfaces_set(&ifaces_ver0[0], &cmanpreconfig_iface_ver0);
- lcr_component_register(&cmanpre_comp_ver0);
-}
-
-static char *facility_name_get (unsigned int facility)
-{
- unsigned int i;
-
- for (i = 0; facilitynames[i].c_name != NULL; i++) {
- if (facility == facilitynames[i].c_val) {
- return (facilitynames[i].c_name);
- }
- }
- return (NULL);
-}
-
-static char *priority_name_get (unsigned int priority)
-{
- unsigned int i;
-
- for (i = 0; prioritynames[i].c_name != NULL; i++) {
- if (priority == prioritynames[i].c_val) {
- return (prioritynames[i].c_name);
- }
- }
- return (NULL);
-}
-
-
-#define LOCALHOST_IPV4 "127.0.0.1"
-#define LOCALHOST_IPV6 "::1"
-
-/* Compare two addresses */
-static int ipaddr_equal(struct sockaddr_storage *addr1, struct sockaddr_storage *addr2)
-{
- int addrlen = 0;
-
- if (addr1->ss_family != addr2->ss_family)
- return 0;
-
- if (addr1->ss_family == AF_INET) {
- addrlen = sizeof(struct sockaddr_in);
- }
- if (addr1->ss_family == AF_INET6) {
- addrlen = sizeof(struct sockaddr_in6);
- }
- assert(addrlen);
-
- if (memcmp(addr1, addr2, addrlen) == 0)
- return 1;
- else
- return 0;
-
-}
-
-/* Build a localhost ip_address */
-static int get_localhost(int family, struct sockaddr_storage *localhost)
-{
- const char *addr_text;
- struct addrinfo *ainfo;
- struct addrinfo ahints;
- int ret;
-
- if (family == AF_INET) {
- addr_text = LOCALHOST_IPV4;
- } else {
- addr_text = LOCALHOST_IPV6;
- }
-
- memset(&ahints, 0, sizeof(ahints));
- ahints.ai_socktype = SOCK_DGRAM;
- ahints.ai_protocol = IPPROTO_UDP;
- ahints.ai_family = family;
-
- /* Lookup the nodename address */
- ret = getaddrinfo(addr_text, NULL, &ahints, &ainfo);
- if (ret)
- return -1;
-
- memset(localhost, 0, sizeof(struct sockaddr_storage));
- memcpy(localhost, ainfo->ai_addr, ainfo->ai_addrlen);
-
- freeaddrinfo(ainfo);
- return 0;
-}
-
-/* Return the address family of an IP[46] name */
-static int address_family(char *addr, struct sockaddr_storage *ssaddr, int family_hint)
-{
- struct addrinfo *ainfo;
- struct addrinfo ahints;
- int family;
- int ret;
-
- memset(&ahints, 0, sizeof(ahints));
- ahints.ai_socktype = SOCK_DGRAM;
- ahints.ai_protocol = IPPROTO_UDP;
- ahints.ai_family = family_hint;
-
- /* Lookup the nodename address */
- ret = getaddrinfo(addr, NULL, &ahints, &ainfo);
- if (ret)
- return -1;
-
- memset(ssaddr, 0, sizeof(struct sockaddr_storage));
- memcpy(ssaddr, ainfo->ai_addr, ainfo->ai_addrlen);
- family = ainfo->ai_family;
-
- freeaddrinfo(ainfo);
- return family;
-}
-
-
-/* Find the "CMAN" logger_subsys object. Or create one if it does not
- exist
-*/
-static hdb_handle_t find_cman_logger(struct objdb_iface_ver0 *objdb, hdb_handle_t object_handle)
-{
- hdb_handle_t subsys_handle;
- hdb_handle_t find_handle;
- char *str;
-
- objdb->object_find_create(object_handle, "logger_subsys", strlen("logger_subsys"), &find_handle);
- while (!objdb->object_find_next(find_handle, &subsys_handle)) {
- if (!objdb_get_string(objdb, subsys_handle, "subsys", &str)) {
- if (strncmp(str, CMAN_NAME, 4) == 0) {
- objdb->object_find_destroy(find_handle);
- return subsys_handle;
- }
- }
- }
- objdb->object_find_destroy(find_handle);
-
- return -1;
-
-}
-
-static int add_udpu_members(struct objdb_iface_ver0 *objdb, hdb_handle_t interface_object_handle)
-{
- char *cur_nodename;
- hdb_handle_t altname_handle;
- hdb_handle_t find_handle = 0;
- hdb_handle_t find_handle2 = 0;
- hdb_handle_t member_object_handle;
- hdb_handle_t nodes_handle;
- int cur_altname_depth;
-
- nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &find_handle);
- while (nodes_handle) {
- if (num_interfaces == 0) {
- if (objdb_get_string(objdb, nodes_handle, "name", &cur_nodename)) {
- nodes_handle = nodeslist_next(objdb, find_handle);
- continue;
- }
- } else {
- objdb->object_find_create(nodes_handle, "altname", strlen("altname"), &find_handle2);
-
- cur_altname_depth = 0;
- while (objdb->object_find_next(find_handle2, &altname_handle) == 0 &&
- cur_altname_depth < num_interfaces)
- cur_altname_depth++;
-
- if (cur_altname_depth == num_interfaces) {
- if (objdb_get_string(objdb, altname_handle, "name", &cur_nodename)) {
- nodes_handle = nodeslist_next(objdb, find_handle);
- continue;
- }
- } else {
- nodes_handle = nodeslist_next(objdb, find_handle);
- continue;
- }
- objdb->object_find_destroy(find_handle2);
- }
-
- if (objdb->object_create(interface_object_handle, &member_object_handle,
- "member", strlen("member")) == 0) {
- objdb->object_key_create_typed(member_object_handle, "memberaddr",
- cur_nodename, strlen(cur_nodename)+1, OBJDB_VALUETYPE_STRING);
- }
-
- nodes_handle = nodeslist_next(objdb, find_handle);
- }
- objdb->object_find_destroy(find_handle);
-
- return 0;
-}
-
-#define PRIMARY_IFACE 0
-#define ALT_IFACE 1
-
-static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int port, int intttl, int altiface, enum tx_mech transport)
-{
- hdb_handle_t totem_object_handle;
- hdb_handle_t find_handle;
- hdb_handle_t interface_object_handle;
- struct sockaddr_storage if_addr, localhost, mcast_addr;
- char tmp[132];
- char *transportstr;
- int ret = 0;
- const char *tx_mech_to_str[] = {
- [TX_MECH_UDP] = "udp",
- [TX_MECH_UDPB] = "udp",
- [TX_MECH_UDPU] = "udpu",
- [TX_MECH_RDMA] = "iba",
- };
-
- if (num_interfaces >= 2) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Configuration of more than 2 rings is not supported");
- return -1;
- }
-
- memset(&mcast_addr, 0, sizeof(mcast_addr));
- memset(&localhost, 0, sizeof(localhost));
- memset(&if_addr, 0, sizeof(if_addr));
-
- /* Check the families match */
- if (address_family(mcast, &mcast_addr, 0) !=
- address_family(ifaddr, &if_addr, mcast_addr.ss_family)) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Node address family does not match multicast address family");
- return -1;
- }
-
- /* Check it's not bound to localhost, sigh */
- get_localhost(if_addr.ss_family, &localhost);
- if (ipaddr_equal(&localhost, &if_addr)) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Node name resolves to localhost, please check /etc/hosts and assign this node a network IP address");
- return -1;
- }
-
- objdb->object_find_create(OBJECT_PARENT_HANDLE, "totem", strlen("totem"), &find_handle);
- if (objdb->object_find_next(find_handle, &totem_object_handle)) {
- objdb->object_create(OBJECT_PARENT_HANDLE, &totem_object_handle,
- "totem", strlen("totem"));
- }
- objdb->object_find_destroy(find_handle);
-
- if (!altiface) {
- if (objdb_get_string(objdb, totem_object_handle, "transport", &transportstr)) {
- objdb->object_key_create_typed(totem_object_handle, "transport",
- tx_mech_to_str[transport], strlen(tx_mech_to_str[transport]) + 1, OBJDB_VALUETYPE_STRING);
- } else {
- snprintf(error_reason, sizeof(error_reason) - 1, "Transport should not be specified within <totem .../>, use <cman transport=\"...\" /> instead");
- return -1;
- }
- }
-
- if (objdb->object_create(totem_object_handle, &interface_object_handle,
- "interface", strlen("interface")) == 0) {
- struct sockaddr_in *in = (struct sockaddr_in *)&if_addr;
- struct sockaddr_in6 *in6= (struct sockaddr_in6 *)&if_addr;
- void *addrptr;
-
- snprintf(tmp, sizeof(tmp) - 1, "%d", num_interfaces);
- objdb->object_key_create_typed(interface_object_handle, "ringnumber",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
-
- if (if_addr.ss_family == AF_INET)
- addrptr = &in->sin_addr;
- else
- addrptr = &in6->sin6_addr;
- inet_ntop(if_addr.ss_family, addrptr, tmp, sizeof(tmp));
- objdb->object_key_create_typed(interface_object_handle, "bindnetaddr",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
-
- switch (transport) {
- case TX_MECH_UDPB:
- objdb->object_key_create_typed(interface_object_handle, "broadcast",
- "yes", strlen("yes")+1, OBJDB_VALUETYPE_STRING);
- break;
- case TX_MECH_UDP:
- case TX_MECH_RDMA:
- objdb->object_key_create_typed(interface_object_handle, "mcastaddr",
- mcast, strlen(mcast)+1, OBJDB_VALUETYPE_STRING);
- break;
- case TX_MECH_UDPU:
- add_udpu_members(objdb, interface_object_handle);
- break;
- }
-
- snprintf(tmp, sizeof(tmp) - 1, "%d", port);
- objdb->object_key_create_typed(interface_object_handle, "mcastport",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
-
- /* paranoia check. corosync already does it */
- if ((intttl < 0) || (intttl > 255)) {
- snprintf(error_reason, sizeof(error_reason) - 1, "TTL value (%u) out of range (0 - 255)", ttl);
- return -1;
- }
-
- /* add the key to the objdb only if value is not default */
- if (intttl != 1) {
- snprintf(tmp, sizeof(tmp) - 1, "%d", ttl);
- objdb->object_key_create_typed(interface_object_handle, "ttl",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
- }
-
- num_interfaces++;
- }
- return ret;
-}
-
-static uint16_t generate_cluster_id(char *name)
-{
- int i;
- int value = 0;
-
- for (i=0; i<strlen(name); i++) {
- value <<= 1;
- value += name[i];
- }
- return value & 0xFFFF;
-}
-
-static char *default_mcast(char *node, int altiface)
-{
- struct addrinfo *ainfo;
- struct addrinfo ahints;
- int ret;
- int family;
- static char addr[132];
- uint16_t clusterid = cluster_id + altiface;
-
- memset(&ahints, 0, sizeof(ahints));
-
- /* Lookup the the nodename address and use it's IP type to
- default a multicast address */
- ret = getaddrinfo(node, NULL, &ahints, &ainfo);
- if (ret) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Can't determine address family of nodename %s\n", node);
- write_cman_pipe("Can't determine address family of nodename");
- return NULL;
- }
-
- family = ainfo->ai_family;
- freeaddrinfo(ainfo);
-
- if (family == AF_INET) {
- snprintf(addr, sizeof(addr), "239.192.%d.%d", clusterid >> 8, clusterid % 0xFF);
- return strdup(addr);
- }
- if (family == AF_INET6) {
- snprintf(addr, sizeof(addr), "ff15::%x", clusterid);
- return strdup(addr);
- }
-
- return NULL;
-}
-
-static int verify_nodename(struct objdb_iface_ver0 *objdb, char *node)
-{
- char nodename2[MAX_CLUSTER_MEMBER_NAME_LEN+1];
- char nodename3[MAX_CLUSTER_MEMBER_NAME_LEN+1];
- char *str, *dot = NULL;
- struct ifaddrs *ifa, *ifa_list;
- struct sockaddr *sa;
- hdb_handle_t nodes_handle;
- hdb_handle_t find_handle = 0;
- int found = 0;
-
- /* nodename is either from commandline or from uname */
- if (nodelist_byname(objdb, cluster_parent_handle, node))
- return 0;
-
- /* If nodename was from uname, try a domain-less version of it */
- strncpy(nodename2, node, sizeof(nodename2) - 1);
- dot = strchr(nodename2, '.');
- if (dot) {
- *dot = '\0';
-
- if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
- strncpy(node, nodename2, MAX_CLUSTER_MEMBER_NAME_LEN - 1);
- return 0;
- }
- }
-
- /* If nodename (from uname) is domain-less, try to match against
- cluster.conf names which may have domainname specified */
- nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &find_handle);
- while (nodes_handle) {
- int len;
-
- if (objdb_get_string(objdb, nodes_handle, "name", &str)) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Cannot get node name");
- nodes_handle = nodeslist_next(objdb, find_handle);
- continue;
- }
-
- strncpy(nodename3, str, sizeof(nodename3) - 1);
- dot = strchr(nodename3, '.');
- if (dot)
- len = dot-nodename3;
- else
- len = strlen(nodename3);
-
- if (strlen(nodename2) == len &&
- !strncmp(nodename2, nodename3, len)) {
- strncpy(node, str, sizeof(nodename) - 1);
- return 0;
- }
- nodes_handle = nodeslist_next(objdb, find_handle);
- }
- objdb->object_find_destroy(find_handle);
-
- /*
- * The cluster.conf names may not be related to uname at all,
- * they may match a hostname on some network interface.
- */
- if (getifaddrs(&ifa_list))
- return -1;
-
- for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
- socklen_t salen = 0;
-
- /* Restore this */
- strncpy(nodename2, node, sizeof(nodename2) - 1);
- sa = ifa->ifa_addr;
- if (!sa)
- continue;
- if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6)
- continue;
-
- if (sa->sa_family == AF_INET)
- salen = sizeof(struct sockaddr_in);
- if (sa->sa_family == AF_INET6)
- salen = sizeof(struct sockaddr_in6);
-
- if (getnameinfo(sa, salen,
- nodename2, sizeof(nodename2),
- NULL, 0, 0) == 0) {
-
- if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
- strncpy(node, nodename2, sizeof(nodename) - 1);
- found = 1;
- goto out;
- }
-
- /* Truncate this name and try again */
- dot = strchr(nodename2, '.');
- if (dot) {
- *dot = '\0';
-
- if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
- strncpy(node, nodename2, sizeof(nodename) - 1);
- found = 1;
- goto out;
- }
- }
- }
-
- /* See if it's the IP address that's in cluster.conf */
- if (getnameinfo(sa, sizeof(*sa),
- nodename2, sizeof(nodename2),
- NULL, 0, NI_NUMERICHOST))
- continue;
-
- if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
- strncpy(node, nodename2, sizeof(nodename) - 1);
- found = 1;
- goto out;
- }
- }
-
- out:
- if (found) {
- freeifaddrs(ifa_list);
- return 0;
- }
-
- /*
- * This section covers the usecase where the nodename specified in cluster.conf
- * is an alias specified in /etc/hosts. For example:
- * <ipaddr> hostname alias1 alias2
- * and <clusternode name="alias2">
- * the above calls use uname and getnameinfo does not return aliases.
- * here we take the name specified in cluster.conf, resolve it to an address
- * and then compare against all known local ip addresses.
- * if we have a match, we found our nodename. In theory this chunk of code
- * could replace all the checks above, but let's avoid any possible regressions
- * and use it as last.
- */
-
- nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &find_handle);
- while (nodes_handle) {
- char *dbnodename = NULL;
- struct addrinfo hints;
- struct addrinfo *result = NULL, *rp = NULL;
-
- if (objdb_get_string(objdb, nodes_handle, "name", &dbnodename)) {
- goto next;
- }
-
- memset(&hints, 0, sizeof(struct addrinfo));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_flags = 0;
- hints.ai_protocol = IPPROTO_UDP;
-
- if (getaddrinfo(dbnodename, NULL, &hints, &result))
- goto next;
-
- for (rp = result; rp != NULL; rp = rp->ai_next) {
- for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
- if (ipaddr_equal((struct sockaddr_storage *)rp->ai_addr,
- (struct sockaddr_storage *)ifa->ifa_addr)) {
- freeaddrinfo(result);
- strncpy(node, dbnodename, sizeof(nodename) - 1);
- found = 1;
- goto out2;
- }
- }
- }
-
- freeaddrinfo(result);
- next:
- nodes_handle = nodeslist_next(objdb, find_handle);
- }
- out2:
- objdb->object_find_destroy(find_handle);
- freeifaddrs(ifa_list);
-
- if (found) {
- return 0;
- }
-
- return -1;
-}
-
-/* Get any environment variable overrides */
-static int get_env_overrides(void)
-{
- if (getenv("CMAN_CLUSTER_NAME")) {
- cluster_name = strdup(getenv("CMAN_CLUSTER_NAME"));
- }
-
- nodename_env = getenv("CMAN_NODENAME");
-
- expected_votes = 0;
- if (getenv("CMAN_EXPECTEDVOTES")) {
- expected_votes = atoi(getenv("CMAN_EXPECTEDVOTES"));
- if (expected_votes < 1) {
- expected_votes = 0;
- }
- }
-
- /* optional port */
- if (getenv("CMAN_IP_PORT")) {
- portnum = atoi(getenv("CMAN_IP_PORT"));
- }
-
- /* optional alternate port */
- if (getenv("CMAN_IP_ALTPORT")) {
- altportnum = atoi(getenv("CMAN_IP_ALTPORT"));
- }
-
- /* optional security key filename */
- if (getenv("CMAN_KEYFILE")) {
- key_filename = strdup(getenv("CMAN_KEYFILE"));
- if (key_filename == NULL) {
- write_cman_pipe("Cannot allocate memory for key filename");
- return -1;
- }
- }
-
- /* find our own number of votes */
- if (getenv("CMAN_VOTES")) {
- votes = atoi(getenv("CMAN_VOTES"));
- }
-
- /* nodeid */
- if (getenv("CMAN_NODEID")) {
- nodeid = atoi(getenv("CMAN_NODEID"));
- }
-
- if (getenv("CMAN_MCAST_ADDR")) {
- mcast_name = getenv("CMAN_MCAST_ADDR");
- }
-
- if (getenv("CMAN_ALTMCAST_ADDR")) {
- altmcast_name = getenv("CMAN_ALTMCAST_ADDR");
- }
-
- if (getenv("CMAN_2NODE")) {
- two_node = 1;
- expected_votes = 1;
- votes = 1;
- }
- if (getenv("CMAN_DEBUG")) {
- debug = atoi(getenv("CMAN_DEBUG"));
- if (debug > 0)
- debug = 1;
- }
-
- return 0;
-}
-
-
-static int get_nodename(struct objdb_iface_ver0 *objdb)
-{
- char *nodeid_str = NULL;
- hdb_handle_t object_handle;
- hdb_handle_t find_handle;
- hdb_handle_t node_object_handle;
- hdb_handle_t mcast_handle;
- hdb_handle_t alt_object;
- enum tx_mech transport = TX_MECH_UDP;
- char *str;
- int error;
- unsigned int mcast_portnum = DEFAULT_PORT;
- unsigned int altmcast_portnum = DEFAULT_PORT;
- char *altmcast_name_tmp = NULL;
- int broadcast = 0;
-
- if (!getenv("CMAN_NOCONFIG")) {
- /* our nodename */
- if (nodename_env != NULL) {
- if (strlen(nodename_env) >= sizeof(nodename)) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Overridden node name %s is too long", nodename);
- write_cman_pipe("Overridden node name is too long");
- error = -1;
- goto out;
- }
-
- strncpy(nodename, nodename_env, sizeof(nodename) - 1);
-
- if (!(node_object_handle = nodelist_byname(objdb, cluster_parent_handle, nodename))) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Overridden node name %s is not in CCS", nodename);
- write_cman_pipe("Overridden node name is not in CCS");
- error = -1;
- goto out;
- }
-
- } else {
- struct utsname utsname;
-
- error = uname(&utsname);
- if (error) {
- snprintf(error_reason, sizeof(error_reason) - 1, "cannot get node name, uname failed");
- write_cman_pipe("Can't determine local node name, uname failed");
- error = -1;
- goto out;
- }
-
- if (strlen(utsname.nodename) >= sizeof(nodename)) {
- snprintf(error_reason, sizeof(error_reason) - 1, "node name from uname is too long");
- write_cman_pipe("local node name is too long");
- error = -1;
- goto out;
- }
-
- strncpy(nodename, utsname.nodename, sizeof(nodename) - 1);
- }
- if (verify_nodename(objdb, nodename)) {
- write_cman_pipe("Cannot find node name in cluster.conf");
- return -1;
- }
-
- }
-
- /* Add <cman> bits to pass down to the main module*/
- if ((node_object_handle = nodelist_byname(objdb, cluster_parent_handle, nodename))) {
- if (objdb_get_string(objdb, node_object_handle, "nodeid", &nodeid_str)) {
- snprintf(error_reason, sizeof(error_reason) - 1, "This node has no nodeid in cluster.conf");
- write_cman_pipe("This node has no nodeid in cluster.conf");
- return -1;
- }
- }
-
- objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle)) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Unable to find cman in config db");
- write_cman_pipe(error_reason);
- return -1;
- }
- objdb->object_find_destroy(find_handle);
-
- /* Check for broadcast */
- if (!objdb_get_string(objdb, object_handle, "broadcast", &str)) {
- if (strcmp(str, "yes") == 0) {
- broadcast = 1;
- transport = TX_MECH_UDPB;
- }
- }
-
- /* Check for transport */
- if (!objdb_get_string(objdb, object_handle, "transport", &str)) {
- if ((broadcast) && (strcmp(str, "udpb"))) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Transport and broadcast option are mutually exclusive");
- write_cman_pipe(error_reason);
- return -1;
- }
- if (strcmp(str, "udp") == 0) {
- transport = TX_MECH_UDP;
- } else if (strcmp(str, "udpb") == 0) {
- broadcast = 1;
- transport = TX_MECH_UDPB;
- } else if (strcmp(str, "udpu") == 0) {
- transport = TX_MECH_UDPU;
- } else if (strcmp(str, "rdma") == 0) {
- transport = TX_MECH_RDMA;
- } else {
- snprintf(error_reason, sizeof(error_reason) - 1, "Transport option value can be one of udp, udpb, udpu, rdma");
- write_cman_pipe(error_reason);
- return -1;
- }
- }
-
- if (broadcast) {
- mcast_name = strdup("255.255.255.255");
- if (!mcast_name) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Unable to set mcast_name");
- write_cman_pipe(error_reason);
- return -1;
- }
- altmcast_name = strdup("255.255.255.255");
- if (!altmcast_name) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Unable to set altmcast_name");
- write_cman_pipe(error_reason);
- return -1;
- }
- altmcast_portnum = DEFAULT_PORT + 2;
- }
-
- objdb->object_find_create(object_handle, "multicast", strlen("multicast"), &find_handle);
- if (objdb->object_find_next(find_handle, &mcast_handle) == 0) {
- if (!mcast_name)
- objdb_get_string(objdb, mcast_handle, "addr", &mcast_name);
- objdb_get_int(objdb, mcast_handle, "ttl", &ttl, ttl);
- objdb_get_int(objdb, mcast_handle, "port", &mcast_portnum, DEFAULT_PORT);
- }
- objdb->object_find_destroy(find_handle);
-
- if (!mcast_name) {
- mcast_name = default_mcast(nodename, PRIMARY_IFACE);
- }
-
- if (!mcast_name) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Unable to set mcast_name");
- write_cman_pipe(error_reason);
- return -1;
- }
-
- objdb->object_find_create(object_handle, "altmulticast", strlen("altmulticast"), &find_handle);
- if (objdb->object_find_next(find_handle, &mcast_handle) == 0) {
- objdb_get_string(objdb, mcast_handle, "addr", &altmcast_name_tmp);
- objdb_get_int(objdb, mcast_handle, "ttl", &altttl, ttl);
- if (!broadcast) {
- objdb_get_int(objdb, mcast_handle, "port", &altmcast_portnum, DEFAULT_PORT);
- } else {
- objdb_get_int(objdb, mcast_handle, "port", &altmcast_portnum, DEFAULT_PORT + 2);
- }
- }
- objdb->object_find_destroy(find_handle);
-
- /* See if the user wants our default set of openais services (default=yes) */
- objdb_get_int(objdb, object_handle, "disable_openais", &disable_openais, 0);
-
- objdb->object_key_create_typed(object_handle, "nodename",
- nodename, strlen(nodename)+1, OBJDB_VALUETYPE_STRING);
-
- if (!nodeid_str) {
- snprintf(error_reason, sizeof(error_reason) - 1, "This node has no nodeid in cluster.conf");
- write_cman_pipe("This node has no nodeid in cluster.conf");
- return -1;
- }
-
- nodeid = atoi(nodeid_str);
- error = 0;
-
- /* optional port */
- if (!portnum) {
- objdb_get_int(objdb, object_handle, "port", &portnum, mcast_portnum);
- }
-
- if (add_ifaddr(objdb, mcast_name, nodename, portnum, ttl,
- PRIMARY_IFACE, transport)) {
- write_cman_pipe(error_reason);
- return -1;
- }
-
- /* Get all alternative node names */
- num_nodenames = 1;
- objdb->object_find_create(node_object_handle,"altname", strlen("altname"), &find_handle);
- while (objdb->object_find_next(find_handle, &alt_object) == 0) {
- char *node;
-
- if (objdb_get_string(objdb, alt_object, "name", &node)) {
- continue;
- }
-
- objdb_get_int(objdb, alt_object, "port", &altportnum, altmcast_portnum);
-
- objdb_get_int(objdb, alt_object, "ttl", &altttl, altttl);
-
- if (!altmcast_name) {
- if (objdb_get_string(objdb, alt_object, "mcast", &altmcast_name)) {
- if (altmcast_name_tmp) {
- altmcast_name = altmcast_name_tmp;
- } else {
- altmcast_name = default_mcast(nodename, ALT_IFACE);
- }
- }
- }
-
- if (!altmcast_name) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Unable to determine alternate multicast name");
- write_cman_pipe(error_reason);
- return -1;
- }
-
- if (!strcmp(altmcast_name, mcast_name) &&
- ((altportnum == portnum) || (altportnum == portnum - 1) || (portnum == altportnum - 1))) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Alternate communication channel (mcast: %s ports: %d,%d) cannot use\n"
- "same address and ports of primary channel (mcast: %s ports: %d,%d)",
- altmcast_name, altportnum, altportnum - 1,
- mcast_name, portnum, portnum - 1);
- write_cman_pipe(error_reason);
- return -1;
- }
-
- if (add_ifaddr(objdb, altmcast_name, node, altportnum, altttl,
- ALT_IFACE, transport)) {
- write_cman_pipe(error_reason);
- return -1;
- }
-
- num_nodenames++;
- }
- objdb->object_find_destroy(find_handle);
-
-out:
- return error;
-}
-
-static void add_logging_overrides(struct objdb_iface_ver0 *objdb)
-{
- char *logstr;
- const char *logfacility;
- const char *loglevel;
- hdb_handle_t object_handle;
- hdb_handle_t find_handle;
-
- /* Make sure mainconfig doesn't stomp on our logging options */
- objdb->object_find_create(OBJECT_PARENT_HANDLE, "logging", strlen("logging"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle)) {
-
- objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
- "logging", strlen("logging"));
- }
- objdb->object_find_destroy(find_handle);
-
- logfacility = facility_name_get(SYSLOGFACILITY);
- if (!logfacility)
- logfacility = "LOG_LOCAL4";
- loglevel = priority_name_get(SYSLOGLEVEL);
- if (!loglevel)
- loglevel = "LOG_INFO";
-
- /* enable timestamps on logging */
- if (objdb_get_string(objdb, object_handle, "timestamp", &logstr)) {
- objdb->object_key_create_typed(object_handle, "timestamp",
- "on", strlen("on")+1, OBJDB_VALUETYPE_STRING);
- }
-
- /* configure logfile */
- if (objdb_get_string(objdb, object_handle, "to_logfile", &logstr)) {
- objdb->object_key_create_typed(object_handle, "to_logfile",
- "yes", strlen("yes")+1, OBJDB_VALUETYPE_STRING);
- }
-
- if (objdb_get_string(objdb, object_handle, "logfile", &logstr)) {
- objdb->object_key_create_typed(object_handle, "logfile",
- LOGDIR "/corosync.log", strlen(LOGDIR "/corosync.log")+1, OBJDB_VALUETYPE_STRING);
- }
-
- if (objdb_get_string(objdb, object_handle, "logfile_priority", &logstr)) {
- objdb->object_key_create_typed(object_handle, "logfile_priority",
- loglevel, strlen(loglevel)+1, OBJDB_VALUETYPE_STRING);
- }
-
- /* syslog */
- if (objdb_get_string(objdb, object_handle, "to_syslog", &logstr)) {
- objdb->object_key_create_typed(object_handle, "to_syslog",
- "yes", strlen("yes")+1, OBJDB_VALUETYPE_STRING);
- }
-
- if (objdb_get_string(objdb, object_handle, "syslog_facility", &logstr)) {
- objdb->object_key_create_typed(object_handle, "syslog_facility",
- logfacility, strlen(logfacility)+1, OBJDB_VALUETYPE_STRING);
- }
-
- if (objdb_get_string(objdb, object_handle, "syslog_priority", &logstr)) {
- objdb->object_key_create_typed(object_handle, "syslog_priority",
- loglevel, strlen(loglevel)+1, OBJDB_VALUETYPE_STRING);
- }
-
- if (!debug) {
- hdb_handle_t logger_object_handle;
-
- if (!objdb_get_string(objdb, object_handle, "debug", &logstr)) {
- if (!strncmp(logstr, "on", 2)) {
- debug=1;
- }
- }
-
- logger_object_handle = find_cman_logger(objdb, object_handle);
- if (logger_object_handle > -1) {
- if (!objdb_get_string(objdb, logger_object_handle, "debug", &logstr)) {
- if (!strncmp(logstr, "on", 2)) {
- debug=1;
- }
- if (!strncmp(logstr, "off", 3)) {
- debug=0;
- }
- }
- }
- }
-
- if (debug) {
- objdb->object_key_create_typed(object_handle, "to_stderr",
- "yes", strlen("yes")+1, OBJDB_VALUETYPE_STRING);
- }
-
-
-}
-
-static int count_configured_nodes(struct objdb_iface_ver0 *objdb)
-{
- hdb_handle_t find_handle = 0;
- hdb_handle_t nodes_handle;
- int count = 0;
-
- nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &find_handle);
- while (nodes_handle) {
- count++;
- nodes_handle = nodeslist_next(objdb, find_handle);
- }
- objdb->object_find_destroy(find_handle);
-
- return count;
-}
-
-/* These are basically cman overrides to the totem config bits */
-static void add_cman_overrides(struct objdb_iface_ver0 *objdb)
-{
- hdb_handle_t object_handle;
- hdb_handle_t find_handle;
- int node_count = 0;
- char tmp[256];
-
- /* "totem" key already exists, because we have added the interfaces by now */
- objdb->object_find_create(OBJECT_PARENT_HANDLE,"totem", strlen("totem"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle) == 0)
- {
- char *value;
-
- objdb->object_key_create_typed(object_handle, "version",
- "2", 2, OBJDB_VALUETYPE_STRING);
-
- snprintf(tmp, sizeof(tmp) - 1, "%d", nodeid);
- objdb->object_key_create_typed(object_handle, "nodeid",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
-
- objdb->object_key_create_typed(object_handle, "vsftype",
- "none", strlen("none")+1, OBJDB_VALUETYPE_STRING);
-
- /* Set the token timeout is 10 seconds, but don't overrride anything that
- might be in cluster.conf */
- if (objdb_get_string(objdb, object_handle, "token", &value)) {
- snprintf(tmp, sizeof(tmp) - 1, "%d", DEFAULT_TOKEN_TIMEOUT);
- objdb->object_key_create_typed(object_handle, "token",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
- }
-
- /* Extend join timeouts per bz#214290 */
- if (objdb_get_string(objdb, object_handle, "join", &value)) {
- objdb->object_key_create_typed(object_handle, "join",
- "60", strlen("60")+1, OBJDB_VALUETYPE_STRING);
- }
- /* Extend fail_to_recv_const, see bz#587078 */
- if (objdb_get_string(objdb, object_handle, "fail_recv_const", &value)) {
- objdb->object_key_create_typed(object_handle, "fail_recv_const",
- "2500", strlen("2500")+1, OBJDB_VALUETYPE_STRING);
- }
-
- /*
- * consensus should be:
- * 2 nodes - 200 ms <= consensus = token * 0.2 <= 2000
- * > 2 nodes - consensus = token + 2000
- *
- * autoconfig clusters will work as > 2 nodes
- *
- * See 611391#c19
- */
-
- node_count=count_configured_nodes(objdb);
-
- /* if we are running in autoconfig or we can't count the nodes, then play safe */
- if ((getenv("CMAN_NOCONFIG")) || (node_count == 0))
- node_count=3;
-
- if (objdb_get_string(objdb, object_handle, "consensus", &value)) {
- unsigned int token=0;
- unsigned int consensus;
- char calc_consensus[64];
-
- objdb_get_int(objdb, object_handle, "token", &token, DEFAULT_TOKEN_TIMEOUT);
-
- if (node_count > 2) {
- consensus = (float)token+2000;
- } else {
- consensus = (float)token*0.2;
- if (consensus < 200)
- consensus = 200;
- if (consensus > 2000)
- consensus = 2000;
- }
-
- snprintf(calc_consensus, sizeof(calc_consensus) - 1, "%d", consensus);
- objdb->object_key_create_typed(object_handle, "consensus",
- calc_consensus, strlen(calc_consensus)+1, OBJDB_VALUETYPE_STRING);
- }
-
- /* Set RRP mode appropriately */
- if (objdb_get_string(objdb, object_handle, "rrp_mode", &value)) {
- if (num_interfaces > 1) {
- objdb->object_key_create_typed(object_handle, "rrp_mode",
- "passive", strlen("passive")+1, OBJDB_VALUETYPE_STRING);
- }
- else {
- objdb->object_key_create_typed(object_handle, "rrp_mode",
- "none", strlen("none")+1, OBJDB_VALUETYPE_STRING);
- }
- }
-
- if (objdb_get_string(objdb, object_handle, "rrp_problem_count_threshold", &value)) {
- if (num_interfaces > 1) {
- objdb->object_key_create_typed(object_handle, "rrp_problem_count_threshold",
- "3", 2, OBJDB_VALUETYPE_STRING);
- }
- }
-
- if (objdb_get_string(objdb, object_handle, "secauth", &value)) {
- snprintf(tmp, sizeof(tmp) - 1, "%d", 1);
- objdb->object_key_create_typed(object_handle, "secauth",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
- }
-
- /* optional security key filename */
- if (!key_filename) {
- objdb_get_string(objdb, object_handle, "keyfile", &key_filename);
- }
- else {
- objdb->object_key_create_typed(object_handle, "keyfile",
- key_filename, strlen(key_filename)+1, OBJDB_VALUETYPE_STRING);
- }
- if (!key_filename) {
- /* Use the cluster name as key,
- * This isn't a good isolation strategy but it does make sure that
- * clusters on the same port/multicast by mistake don't actually interfere
- * and that we have some form of encryption going.
- */
-
- int keylen;
- memset(tmp, 0, sizeof(tmp));
-
- strncpy(tmp, cluster_name, sizeof(tmp) - 1);
-
- /* Key length must be a multiple of 4 */
- keylen = (strlen(cluster_name)+4) & 0xFC;
- objdb->object_key_create_typed(object_handle, "key",
- tmp, keylen, OBJDB_VALUETYPE_STRING);
- }
- }
- objdb->object_find_destroy(find_handle);
-
- add_logging_overrides(objdb);
-
- /* Make sure we allow connections from user/group "ais" */
- objdb->object_find_create(OBJECT_PARENT_HANDLE, "aisexec", strlen("aisexec"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle) != 0) {
- objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
- "aisexec", strlen("aisexec"));
- }
- objdb->object_find_destroy(find_handle);
- objdb->object_key_create_typed(object_handle, "user",
- "ais", strlen("ais") + 1, OBJDB_VALUETYPE_STRING);
- objdb->object_key_create_typed(object_handle, "group",
- "ais", strlen("ais") + 1, OBJDB_VALUETYPE_STRING);
-
- objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle) == 0)
- {
- char str[255];
-
- snprintf(str, sizeof(str) - 1, "%d", cluster_id);
-
- objdb->object_key_create_typed(object_handle, "cluster_id",
- str, strlen(str) + 1, OBJDB_VALUETYPE_STRING);
-
- if (two_node) {
- snprintf(str, sizeof(str) - 1, "%d", 1);
- objdb->object_key_create_typed(object_handle, "two_node",
- str, strlen(str) + 1, OBJDB_VALUETYPE_STRING);
- }
- }
- objdb->object_find_destroy(find_handle);
-
- /* Load the quorum service */
- objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
- "service", strlen("service"));
- objdb->object_key_create_typed(object_handle, "name",
- "corosync_quorum", strlen("corosync_quorum") + 1, OBJDB_VALUETYPE_STRING);
- objdb->object_key_create_typed(object_handle, "ver",
- "0", 2, OBJDB_VALUETYPE_STRING);
-
- /* Make sure we load our alter-ego - the main cman module */
- objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
- "service", strlen("service"));
- objdb->object_key_create_typed(object_handle, "name",
- "corosync_cman", strlen("corosync_cman") + 1, OBJDB_VALUETYPE_STRING);
- objdb->object_key_create_typed(object_handle, "ver",
- "0", 2, OBJDB_VALUETYPE_STRING);
-
- /* Define cman as the quorum provider for corosync */
- objdb->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle) != 0) {
- objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
- "quorum", strlen("quorum"));
- }
- objdb->object_find_destroy(find_handle);
-
- objdb->object_key_create_typed(object_handle, "provider",
- "quorum_cman", strlen("quorum_cman") + 1, OBJDB_VALUETYPE_STRING);
-}
-
-/* If ccs is not available then use some defaults */
-static int set_noccs_defaults(struct objdb_iface_ver0 *objdb)
-{
- char tmp[255];
- hdb_handle_t object_handle;
- hdb_handle_t find_handle;
-
- /* Enforce key */
- key_filename = strdup(NOCCS_KEY_FILENAME);
- if (!key_filename) {
- snprintf(error_reason, sizeof(error_reason) - 1, "cannot allocate memory for key file name");
- write_cman_pipe("cannot allocate memory for key file name");
- return -1;
- }
-
- if (!cluster_name)
- cluster_name = strdup(DEFAULT_CLUSTER_NAME);
-
- if (!cluster_name) {
- snprintf(error_reason, sizeof(error_reason) - 1, "cannot allocate memory for cluster_name");
- write_cman_pipe("cannot allocate memory for cluster_name");
- return -1;
- }
-
- if (!cluster_id) {
- if (use_hashed_cluster_id)
- cluster_id = fnv_hash(cluster_name);
- else
- cluster_id = generate_cluster_id(cluster_name);
-
- snprintf(error_reason, sizeof(error_reason) - 1, "Generated cluster id for '%s' is %d\n", cluster_name, cluster_id);
- }
-
- if (!nodename_env) {
- int error;
- struct utsname utsname;
-
- error = uname(&utsname);
- if (error) {
- snprintf(error_reason, sizeof(error_reason) - 1, "cannot get node name, uname failed");
- write_cman_pipe("Can't determine local node name");
- return -1;
- }
-
- nodename_env = (char *)&utsname.nodename;
- }
- strncpy(nodename, nodename_env, sizeof(nodename) - 1);
- num_nodenames = 1;
-
- if (!mcast_name) {
- mcast_name = default_mcast(nodename, PRIMARY_IFACE);
- }
-
- /* This will increase as nodes join the cluster */
- if (!expected_votes)
- expected_votes = 1;
- if (!votes)
- votes = 1;
-
- if (!portnum)
- portnum = DEFAULT_PORT;
-
- /* Invent a node ID */
- if (!nodeid) {
- struct addrinfo *ainfo;
- struct addrinfo ahints;
- int ret;
-
- memset(&ahints, 0, sizeof(ahints));
- ret = getaddrinfo(nodename, NULL, &ahints, &ainfo);
- if (ret) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Can't determine address family of nodename %s\n", nodename);
- write_cman_pipe("Can't determine address family of nodename");
- return -1;
- }
-
- if (ainfo->ai_family == AF_INET) {
- struct sockaddr_in *addr = (struct sockaddr_in *)ainfo->ai_addr;
- memcpy(&nodeid, &addr->sin_addr, sizeof(int));
- }
- if (ainfo->ai_family == AF_INET6) {
- struct sockaddr_in6 *addr = (struct sockaddr_in6 *)ainfo->ai_addr;
- memcpy(&nodeid, &addr->sin6_addr.s6_addr32[3], sizeof(int));
- }
- freeaddrinfo(ainfo);
- }
-
- /* Write a local <clusternode> entry to keep the rest of the code happy */
- objdb->object_create(cluster_parent_handle, &object_handle,
- "clusternodes", strlen("clusternodes"));
- objdb->object_create(object_handle, &object_handle,
- "clusternode", strlen("clusternode"));
- objdb->object_key_create_typed(object_handle, "name",
- nodename, strlen(nodename)+1, OBJDB_VALUETYPE_STRING);
-
- snprintf(tmp, sizeof(tmp) - 1, "%d", votes);
- objdb->object_key_create_typed(object_handle, "votes",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
-
- snprintf(tmp, sizeof(tmp) - 1, "%d", nodeid);
- objdb->object_key_create_typed(object_handle, "nodeid",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
-
- /* Write the default cluster name & ID in here too */
- objdb->object_key_create_typed(cluster_parent_handle, "name",
- cluster_name, strlen(cluster_name)+1, OBJDB_VALUETYPE_STRING);
-
-
- objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle) == 0) {
-
- objdb->object_create(cluster_parent_handle, &object_handle,
- "cman", strlen("cman"));
- }
- snprintf(tmp, sizeof(tmp) - 1, "%d", cluster_id);
- objdb->object_key_create_typed(object_handle, "cluster_id",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
-
- snprintf(tmp, sizeof(tmp) - 1, "%d", expected_votes);
- objdb->object_key_create_typed(object_handle, "expected_votes",
- tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
-
- objdb->object_find_destroy(find_handle);
- return 0;
-}
-
-/* Move an object/key tree */
-static int copy_config_tree(struct objdb_iface_ver0 *objdb, hdb_handle_t source_object, hdb_handle_t target_parent_object, int always_create)
-{
- hdb_handle_t object_handle;
- hdb_handle_t new_object;
- hdb_handle_t find_handle;
- char object_name[1024];
- size_t object_name_len;
- void *key_name;
- size_t key_name_len;
- void *key_value;
- size_t key_value_len;
- int res;
-
- /* Create new parent object if necessary */
- objdb->object_name_get(source_object, object_name, &object_name_len);
-
- objdb->object_find_create(target_parent_object, object_name, strlen(object_name), &find_handle);
- if (always_create || objdb->object_find_next(find_handle, &new_object))
- objdb->object_create(target_parent_object, &new_object, object_name, object_name_len);
- objdb->object_find_destroy(find_handle);
-
- /* Copy the keys */
- objdb->object_key_iter_reset(new_object);
-
- while (!objdb->object_key_iter(source_object, &key_name, &key_name_len,
- &key_value, &key_value_len)) {
-
- objdb->object_key_create_typed(new_object, key_name,
- key_value, key_value_len, OBJDB_VALUETYPE_STRING);
- }
-
- /* Create sub-objects */
- res = objdb->object_find_create(source_object, NULL, 0, &find_handle);
- if (res) {
- snprintf(error_reason, sizeof(error_reason) - 1, "error resetting object iterator for object %ud: %d\n", (unsigned int)source_object, res);
- return -1;
- }
-
- while ( (res = objdb->object_find_next(find_handle, &object_handle) == 0)) {
-
- /* Down we go ... */
- copy_config_tree(objdb, object_handle, new_object, always_create);
- }
- objdb->object_find_destroy(find_handle);
-
- return 0;
-}
-
-/*
- * Copy trees from /cluster where they live in cluster.conf, into the root
- * of the config tree where corosync expects to find them.
- */
-static int copy_tree_to_root(struct objdb_iface_ver0 *objdb, const char *name, int always_create)
-{
- hdb_handle_t find_handle;
- hdb_handle_t object_handle;
- int res=0;
-
- objdb->object_find_create(cluster_parent_handle, name, strlen(name), &find_handle);
- while (objdb->object_find_next(find_handle, &object_handle) == 0) {
- res = copy_config_tree(objdb, object_handle, OBJECT_PARENT_HANDLE, always_create);
- }
- objdb->object_find_destroy(find_handle);
-
- return res;
-}
-
-static int get_cman_globals(struct objdb_iface_ver0 *objdb)
-{
- hdb_handle_t object_handle;
- hdb_handle_t find_handle;
- char *use_hash;
-
- objdb_get_string(objdb, cluster_parent_handle, "name", &cluster_name);
- if (!cluster_name) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Unable to determine cluster name.\n");
- write_cman_pipe("Unable to determine cluster name.\n");
- return -1;
- }
-
- if (strlen(cluster_name) > 15) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Invalid cluster name. It must be 15 characters or fewer\n\n");
- write_cman_pipe("Invalid cluster name. It must be 15 characters or fewer\n");
- return -1;
- }
-
- /* Get the <cman> bits that override <totem> bits */
- objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle) == 0) {
- if (!key_filename)
- objdb_get_string(objdb, object_handle, "keyfile", &key_filename);
-
- objdb_get_string(objdb, object_handle, "hash_cluster_id", &use_hash);
- if (use_hash) {
- if (strncasecmp(use_hash, "yes", 3) == 0 || strncasecmp(use_hash, "on", 2) == 0)
- use_hashed_cluster_id = 1;
- }
-
- if (!cluster_id)
- objdb_get_int(objdb, object_handle, "cluster_id", &cluster_id, 0);
-
- if (!cluster_id) {
- if (use_hashed_cluster_id)
- cluster_id = fnv_hash(cluster_name);
- else
- cluster_id = generate_cluster_id(cluster_name);
-
- snprintf(error_reason, sizeof(error_reason) - 1, "Generated cluster id for '%s' is %d\n", cluster_name, cluster_id);
- }
- }
- objdb->object_find_destroy(find_handle);
- return 0;
-}
-
-static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const char **error_string)
-{
- int ret = -1;
- hdb_handle_t object_handle;
- hdb_handle_t find_handle;
- hdb_handle_t cluster_parent_handle_new;
- unsigned int config_version = 0, config_version_new = 0;
- char *config_value = NULL;
- char str[255];
-
- /* don't reload if we've been told to run configless */
- if (getenv("CMAN_NOCONFIG")) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Config not updated because we were run with cman_tool -X");
- ret = 0;
- goto err;
- }
-
- /* find both /cluster entries */
- objdb->object_find_create(OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &find_handle);
- objdb->object_find_next(find_handle, &cluster_parent_handle);
- objdb->object_find_next(find_handle, &cluster_parent_handle_new);
- objdb->object_find_destroy(find_handle);
- if (!cluster_parent_handle) {
- snprintf (error_reason, sizeof(error_reason) - 1, "Cannot find old /cluster/ key in configuration\n");
- goto err;
- }
- if (!cluster_parent_handle_new) {
- snprintf (error_reason, sizeof(error_reason) - 1, "Cannot find new /cluster/ key in configuration\n");
- goto err;
- }
-
- if (!objdb->object_key_get(cluster_parent_handle, "config_version", strlen("config_version"), (void *)&config_value, NULL)) {
- if (config_value) {
- config_version = atoi(config_value);
- } else {
- /* it should never ever happen.. */
- snprintf (error_reason, sizeof(error_reason) - 1, "Cannot find old /cluster/config_version key in configuration\n");
- goto err;
- }
- }
-
- config_value = NULL;
-
- if (!objdb->object_key_get(cluster_parent_handle_new, "config_version", strlen("config_version"), (void *)&config_value, NULL)) {
- if (config_value) {
- config_version_new = atoi(config_value);
- } else {
- objdb->object_destroy(cluster_parent_handle_new);
- snprintf (error_reason, sizeof(error_reason) - 1,"Cannot find new /cluster/config_version key in configuration\n");
- goto err;
- }
- }
-
- if (config_version_new <= config_version) {
- objdb->object_destroy(cluster_parent_handle_new);
- snprintf (error_reason, sizeof(error_reason) - 1, "New configuration version has to be newer than current running configuration\n");
- goto err;
- }
-
- /* destroy the old one */
- objdb->object_destroy(cluster_parent_handle);
-
- /*
- * create cluster.cman in the new config if it doesn't exist
- */
- objdb->object_find_create(cluster_parent_handle_new, "cman", strlen("cman"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle)) {
- objdb->object_create(cluster_parent_handle_new, &object_handle,
- "cman", strlen("cman"));
- }
- objdb->object_find_destroy(find_handle);
-
- /*
- * write cluster_id/two_node/nodename
- */
- snprintf(str, sizeof(str) - 1, "%d", cluster_id);
- objdb->object_key_create_typed(object_handle, "cluster_id",
- str, strlen(str) + 1, OBJDB_VALUETYPE_STRING);
-
- if (two_node) {
- snprintf(str, sizeof(str) - 1, "%d", 1);
- objdb->object_key_create_typed(object_handle, "two_node",
- str, strlen(str) + 1, OBJDB_VALUETYPE_STRING);
- }
-
- objdb->object_key_create_typed(object_handle, "nodename",
- nodename, strlen(nodename)+1, OBJDB_VALUETYPE_STRING);
-
- /* update the reference to the new config */
- cluster_parent_handle = cluster_parent_handle_new;
-
- /* destroy top level /logging */
- objdb->object_find_create(OBJECT_PARENT_HANDLE, "logging", strlen("logging"), &find_handle);
- ret = objdb->object_find_next(find_handle, &object_handle);
- objdb->object_find_destroy(find_handle);
- if (!ret) {
- objdb->object_destroy(object_handle);
- }
-
- /* copy /cluster/logging to /logging */
- ret = copy_tree_to_root(objdb, "logging", 1);
-
- /* Note: we do NOT delete /totem as corosync stores other things in there that
- it needs! */
-
- /* copy /cluster/totem to /totem */
- ret = copy_tree_to_root(objdb, "totem", 0);
-
- add_logging_overrides(objdb);
-
- return 0;
-
-err:
- *error_string = error_reason;
- return ret;
-}
-
-
-static hdb_handle_t find_or_create_object(struct objdb_iface_ver0 *objdb, const char *name, hdb_handle_t parent_handle)
-{
- hdb_handle_t find_handle;
- hdb_handle_t ret_handle = 0;
-
- objdb->object_find_create(parent_handle, name, strlen(name), &find_handle);
- objdb->object_find_next(find_handle, &ret_handle);
- objdb->object_find_destroy(find_handle);
-
- if (!ret_handle) {
- objdb->object_create(parent_handle, &ret_handle, name, strlen(name));
- }
-
- return ret_handle;
-}
-
-static const char *groupd_compat="groupd_compat";
-static const char *clvmd_interface="interface";
-static const char *cman_disallowed="disallowed";
-static const char *totem_crypto="crypto_accept";
-static const char *plock_ownership="plock_ownership";
-
-/*
- * Flags to set:
- * - groupd:
- * - clvmd
- * - disallowed (on)
- * - rgmanager
- */
-static void setup_old_compat(struct objdb_iface_ver0 *objdb, hdb_handle_t cluster_handle)
-{
- hdb_handle_t groupd_handle;
- hdb_handle_t clvmd_handle;
- hdb_handle_t cman_handle;
- hdb_handle_t totem_handle;
- hdb_handle_t gfs_handle;
- char *value;
-
- use_hashed_cluster_id = 0;
-
- /* Set groupd to backwards compatibility mode */
- groupd_handle = find_or_create_object(objdb, "group", cluster_handle);
- if (objdb->object_key_get(groupd_handle, groupd_compat, strlen(groupd_compat),
- (void *)&value, NULL) ||
- !value) {
- objdb->object_key_create_typed(groupd_handle, groupd_compat,
- "1", 2, OBJDB_VALUETYPE_STRING);
- }
-
- /* Make clvmd use cman */
- clvmd_handle = find_or_create_object(objdb, "clvmd", cluster_handle);
- if (objdb->object_key_get(clvmd_handle, clvmd_interface, strlen(clvmd_interface),
- (void *)&value, NULL) ||
- !value) {
- objdb->object_key_create_typed(clvmd_handle, clvmd_interface,
- "cman", 5, OBJDB_VALUETYPE_STRING);
- }
-
- /* Make cman use disallowed mode */
- cman_handle = find_or_create_object(objdb, "cman", cluster_handle);
- if (objdb->object_key_get(cman_handle, cman_disallowed, strlen(cman_disallowed),
- (void *)&value, NULL) ||
- !value) {
- objdb->object_key_create_typed(cman_handle, cman_disallowed,
- "1", 2, OBJDB_VALUETYPE_STRING);
- }
-
- /* Make totem use the old communications method */
- totem_handle = find_or_create_object(objdb, "totem", OBJECT_PARENT_HANDLE);
- if (objdb->object_key_get(totem_handle, totem_crypto, strlen(totem_crypto),
- (void *)&value, NULL) ||
- !value) {
- objdb->object_key_create_typed(totem_handle, totem_crypto,
- "old", 4, OBJDB_VALUETYPE_STRING);
- }
-
- /* Disable plock ownership */
- gfs_handle = find_or_create_object(objdb, "gfs_controld", OBJECT_PARENT_HANDLE);
- if (objdb->object_key_get(gfs_handle, plock_ownership, strlen(plock_ownership),
- (void *)&value, NULL) ||
- !value) {
- objdb->object_key_create_typed(gfs_handle, plock_ownership,
- "0", 2, OBJDB_VALUETYPE_STRING);
- }
-}
-
-static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, const char **error_string)
-{
- int ret = 0;
- hdb_handle_t object_handle;
- hdb_handle_t find_handle;
- char *str;
-
- if (getenv("CMAN_PIPE"))
- startup_pipe = atoi(getenv("CMAN_PIPE"));
-
- objdb->object_find_create(OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &find_handle);
- objdb->object_find_next(find_handle, &cluster_parent_handle);
- objdb->object_find_destroy(find_handle);
- if (!cluster_parent_handle) {
- objdb->object_create(OBJECT_PARENT_HANDLE, &cluster_parent_handle,
- "cluster", strlen("cluster"));
- }
- else {
- /* Move these to a place where corosync expects to find them */
- ret = copy_tree_to_root(objdb, "totem", 0);
- ret = copy_tree_to_root(objdb, "logging", 1);
- ret = copy_tree_to_root(objdb, "event", 0);
- ret = copy_tree_to_root(objdb, "amf", 0);
- ret = copy_tree_to_root(objdb, "aisexec", 0);
- ret = copy_tree_to_root(objdb, "service", 1);
- ret = copy_tree_to_root(objdb, "uidgid", 1);
- }
-
- objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle)) {
- objdb->object_create(cluster_parent_handle, &object_handle,
- "cman", strlen("cman"));
- }
- objdb->object_find_destroy(find_handle);
-
- /* Set up STABLE2/RHEL5 compatibility modes */
- objdb_get_string(objdb, object_handle, "upgrading", &str);
- if (str && (strcasecmp(str, "on")==0 || strcasecmp(str, "yes")==0)) {
- setup_old_compat(objdb, cluster_parent_handle);
- }
-
- /* This will create /libccs/@next_handle.
- * next_handle will be atomically incremented by corosync to return ccs_handle down the pipe.
- * We create it in cman-preconfig to avoid an "init" race in libccs.
- */
-
- objdb->object_find_create(OBJECT_PARENT_HANDLE, "libccs", strlen("libccs"), &find_handle);
- if (objdb->object_find_next(find_handle, &object_handle)) {
- int next_handle = 0;
-
- objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
- "libccs", strlen("libccs"));
-
- objdb->object_key_create_typed(object_handle, "next_handle",
- &next_handle, sizeof(uint32_t), OBJDB_VALUETYPE_UINT32);
- }
- objdb->object_find_destroy(find_handle);
-
- get_env_overrides();
- if (getenv("CMAN_NOCONFIG"))
- ret = set_noccs_defaults(objdb);
- else
- ret = get_cman_globals(objdb);
-
- if (!ret) {
- ret = get_nodename(objdb);
- add_cman_overrides(objdb);
- }
-
-
- if (!ret) {
- snprintf(error_reason, sizeof(error_reason) - 1, "Successfully parsed cman config\n");
- }
- else {
- if (error_reason[0] == '\0')
- snprintf(error_reason, sizeof(error_reason) - 1, "Error parsing cman config\n");
- }
- *error_string = error_reason;
-
-
- /* nullify stderr, because cman_tool tells corosync not to.
- This helps pass error messages back to the command-line, when
- debug is enabled.
- */
- if (!debug) {
- int tmpfd;
- tmpfd = open("/dev/null", O_RDWR);
- if (tmpfd > -1 && tmpfd != STDERR_FILENO) {
- dup2(tmpfd, STDERR_FILENO);
- close(tmpfd);
- }
-
- }
- return ret;
-}
-
-/* Write an error message down the CMAN startup pipe so
- that cman_tool can display it */
-int write_cman_pipe(const char *message)
-{
- if (startup_pipe)
- return write(startup_pipe, message, strlen(message)+1);
-
- return 0;
-}
diff --git a/cman/daemon/cman.h b/cman/daemon/cman.h
deleted file mode 100644
index 1ec7eca..0000000
--- a/cman/daemon/cman.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* General cman bits */
-extern int write_cman_pipe(const char *message);
-extern void close_cman_pipe(void);
-extern int our_nodeid(void);
-
-/* How we announce ourself in syslog */
-#define CMAN_NAME "CMAN"
-
-/* Defaults for configuration variables */
-#define NOCCS_KEY_FILENAME "/etc/cluster/cman_authkey"
-#define DEFAULT_PORT 5405
-#define DEFAULT_CLUSTER_NAME "RHCluster"
-#define DEFAULT_MAX_QUEUED 128
-#define DEFAULT_TOKEN_TIMEOUT 10000
-#define DEFAULT_QUORUMDEV_POLL 10000
-#define DEFAULT_SHUTDOWN_TIMEOUT 5000
-#define DEFAULT_CCSD_POLL 1000
-#define DEFAULT_DISALLOWED 0
-#define DEFAULT_STARTUP_CONFIG_TIMEOUT 0
diff --git a/cman/daemon/cmanconfig.c b/cman/daemon/cmanconfig.c
deleted file mode 100644
index ca95609..0000000
--- a/cman/daemon/cmanconfig.c
+++ /dev/null
@@ -1,312 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <netinet/in.h>
-#include <syslog.h>
-#include <string.h>
-#include <errno.h>
-#include <netdb.h>
-
-#include <corosync/corotypes.h>
-#include <corosync/coroipc_types.h>
-#include <corosync/coroipcc.h>
-#include <corosync/corodefs.h>
-#include <corosync/mar_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-
-#include "list.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "commands.h"
-#include "cman.h"
-#define OBJDB_API struct corosync_api_v1
-#include "cmanconfig.h"
-#include "nodelist.h"
-#include "ais.h"
-
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME);
-
-/* Local vars - things we get from ccs */
- int two_node;
-static int nodeid;
-static unsigned int cluster_id;
-static char cluster_name[MAX_CLUSTER_NAME_LEN + 1];
-static unsigned int expected_votes;
-static char *our_nodename;
-static int our_votes;
-
-/* Get all the cluster node names from objdb and
- * add them to our node list.
- * Called when we start up and on "cman_tool version".
- */
-int read_cman_nodes(struct corosync_api_v1 *corosync, unsigned int *config_version, int check_nodeids)
-{
- int error;
- unsigned int expected = 0;
- unsigned int votes = 0;
- unsigned int total_votes = 0;
- hdb_handle_t object_handle;
- hdb_handle_t nodes_handle;
- hdb_handle_t find_handle;
- char *nodename;
- int this_nodeid;
- hdb_handle_t cluster_parent_handle;
-
- corosync->object_find_create(OBJECT_PARENT_HANDLE,
- "cluster", strlen("cluster"), &find_handle);
-
- corosync->object_find_next(find_handle, &cluster_parent_handle);
- corosync->object_find_destroy(find_handle);
-
- /* New config version */
- objdb_get_int(corosync, cluster_parent_handle, "config_version", config_version,0);
-
- corosync->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
-
- if (corosync->object_find_next(find_handle, &object_handle) == 0)
- {
- /* This overrides any other expected votes calculation /except/ for
- one specified on a join command-line */
- objdb_get_int(corosync, object_handle, "expected_votes", &expected, 0);
- objdb_get_int(corosync, object_handle, "two_node", (unsigned int *)&two_node, 0);
- objdb_get_int(corosync, object_handle, "cluster_id", &cluster_id, 0);
- if (objdb_get_string(corosync, object_handle, "nodename", &our_nodename) != 0) {
- char message[132];
- snprintf(message, sizeof(message),
- "cman was unable to determine our node name!\n");
- log_printf(LOG_ERR, "%s", message);
- write_cman_pipe(message);
- error = -EINVAL;
- goto out_err;
- }
- objdb_get_int(corosync, object_handle, "max_queued", &max_outstanding_messages, DEFAULT_MAX_QUEUED);
- }
- corosync->object_find_destroy(find_handle);
-
- clear_reread_flags();
-
- /* Get the nodes list */
- nodes_handle = nodeslist_init(corosync, cluster_parent_handle, &find_handle);
- do {
- if (objdb_get_string(corosync, nodes_handle, "name", &nodename)) {
- nodes_handle = nodeslist_next(corosync, find_handle);
- continue;
- }
-
- objdb_get_int(corosync, nodes_handle, "votes", (unsigned int *)&votes, 1);
- objdb_get_int(corosync, nodes_handle, "nodeid", (unsigned int *)&this_nodeid, 0);
- if (check_nodeids && this_nodeid == 0) {
- char message[132];
-
- snprintf(message, sizeof(message),
- "No node ID for %s, run 'ccs_tool addnodeids' to fix",
- nodename);
- log_printf(LOG_ERR, "%s", message);
- write_cman_pipe(message);
- error = -EINVAL;
- goto out_err;
- }
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Got node %s from ccs (id=%d, votes=%d)\n", nodename, this_nodeid, votes);
- add_ccs_node(nodename, this_nodeid, votes, expected);
- nodes_handle = nodeslist_next(corosync, find_handle);
- total_votes += votes;
- } while (nodes_handle);
- corosync->object_find_destroy(find_handle);
-
- if (!expected)
- expected = total_votes;
-
- override_expected(expected);
-
- remove_unread_nodes();
- error = 0;
-
-out_err:
- return error;
-}
-
-static int join(struct corosync_api_v1 *corosync)
-{
- int error;
- error = cman_set_nodename(our_nodename);
- error = cman_set_nodeid(nodeid);
-
- /*
- * Setup join information
- */
- error = cman_join_cluster(corosync, cluster_name, cluster_id,
- two_node, our_votes, expected_votes);
- if (error == -EINVAL) {
- write_cman_pipe("Cannot start, cluster name is too long or other CCS error");
- return error;
- }
- if (error) {
- write_cman_pipe("Cannot start, ais may already be running");
- return error;
- }
-
- return 0;
-}
-
-static int get_cman_join_info(struct corosync_api_v1 *corosync)
-{
- char *cname = NULL;
- int error, vote_sum = 0, node_count = 0;
- int votes=0;
- hdb_handle_t object_handle;
- hdb_handle_t node_object;
- hdb_handle_t nodes_handle;
- hdb_handle_t find_handle;
- hdb_handle_t cluster_parent_handle;
-
- corosync->object_find_create(OBJECT_PARENT_HANDLE,
- "cluster", strlen("cluster"), &find_handle);
-
- corosync->object_find_next(find_handle, &cluster_parent_handle);
- corosync->object_find_destroy(find_handle);
-
- /* Cluster name */
- if (objdb_get_string(corosync, cluster_parent_handle, "name", &cname)) {
- log_printf(LOG_ERR, "cannot find cluster name in config file");
- write_cman_pipe("Can't find cluster name in CCS");
- error = -ENOENT;
- goto out;
- }
-
- strncpy(cluster_name, cname, sizeof(cluster_name) - 1);
-
- expected_votes = 0;
- if (getenv("CMAN_EXPECTEDVOTES")) {
- expected_votes = atoi(getenv("CMAN_EXPECTEDVOTES"));
- if (expected_votes < 1) {
- log_printf(LOG_ERR, "CMAN_EXPECTEDVOTES environment variable is invalid, ignoring");
- expected_votes = 0;
- }
- else {
- log_printf(LOG_INFO, "Using override expected votes %d\n", expected_votes);
- }
- }
-
- /* Sum node votes for expected. Even if we already know expected_votes, we need vote_sum
- later */
- nodes_handle = nodeslist_init(corosync, cluster_parent_handle, &find_handle);
- do {
- int nodevotes;
-
- node_count++;
-
- objdb_get_int(corosync, nodes_handle, "votes", (unsigned int *)&nodevotes, 1);
- if (nodevotes < 0) {
- log_printf(LOG_ERR, "negative votes not allowed");
- write_cman_pipe("Found negative votes for this node in CCS");
- error = -EINVAL;
- goto out;
- }
- vote_sum += nodevotes;
- nodes_handle = nodeslist_next(corosync, find_handle);
- } while (nodes_handle);
- corosync->object_find_destroy(find_handle);
-
- if (expected_votes == 0) {
- corosync->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
- if (corosync->object_find_next(find_handle, &object_handle) == 0)
- {
-
- /* optional expected_votes supercedes vote sum */
- objdb_get_int(corosync, object_handle, "expected_votes", (unsigned int *)&expected_votes, 0);
- if (!expected_votes)
- expected_votes = vote_sum;
- }
- corosync->object_find_destroy(find_handle);
- }
-
- /* find our own number of votes */
- if (getenv("CMAN_VOTES")) {
- votes = atoi(getenv("CMAN_VOTES"));
- log_printf(LOG_INFO, "Using override votes %d\n", votes);
- }
-
- node_object = nodelist_byname(corosync, cluster_parent_handle, our_nodename);
- if (!votes && !node_object) {
- log_printf(LOG_ERR, "unable to find votes for %s", our_nodename);
- write_cman_pipe("Unable to find votes for node in CCS");
- return -E2BIG;
- }
-
- if (!votes) {
- unsigned int votestmp=-1;
- objdb_get_int(corosync, node_object, "votes", &votestmp, 1);
- if (votestmp > 255) {
- log_printf(LOG_ERR, "invalid votes value %d", votestmp);
- write_cman_pipe("Found invalid votes for node in CCS");
- return -EINVAL;
- }
- votes = votestmp;
- }
- our_votes = votes;
-
- /* nodeid */
- if (getenv("CMAN_NODEID")) {
- nodeid = atoi(getenv("CMAN_NODEID"));
- log_printf(LOG_INFO, "Using override nodeid %d\n", nodeid);
- }
-
- if (!nodeid) {
- objdb_get_int(corosync, node_object, "nodeid", (unsigned int *)&nodeid, 0);
- }
-
- if (!nodeid) {
- log_printf(LOG_ERR, "No nodeid specified in cluster.conf");
- write_cman_pipe("CCS does not have a nodeid for this node, run 'ccs_tool addnodeids' to fix");
- return -EINVAL;
- }
-
- /* two_node mode */
- if (two_node) {
- if (node_count != 2 || vote_sum != 2) {
- log_printf(LOG_ERR, "the two-node option requires exactly two "
- "nodes with one vote each and expected "
- "votes of 1 (node_count=%d vote_sum=%d)",
- node_count, vote_sum);
- write_cman_pipe("two_node is set but there are not 2 nodes in cluster.conf");
- error = -EINVAL;
- goto out;
- }
-
- if (votes != 1) {
- log_printf(LOG_ERR, "the two-node option requires exactly two "
- "nodes with one vote each and expected "
- "votes of 1 (votes=%d)", votes);
- write_cman_pipe("two_node set but votes not set to 1");
- error = -EINVAL;
- goto out;
- }
- }
-
- error = 0;
-
-out:
- return error;
-}
-
-
-
-/* Read the stuff we need to get started.
- This does what 'cman_tool join' used to to */
-int read_cman_config(struct corosync_api_v1 *corosync, unsigned int *config_version)
-{
- int error;
-
- read_cman_nodes(corosync, config_version, 1);
- error = get_cman_join_info(corosync);
- if (error) {
- log_printf(LOG_ERR, "Error reading configuration, cannot start");
- return error;
- }
-
- error = join(corosync);
-
- return error;
-}
diff --git a/cman/daemon/cmanconfig.h b/cman/daemon/cmanconfig.h
deleted file mode 100644
index 2d66add..0000000
--- a/cman/daemon/cmanconfig.h
+++ /dev/null
@@ -1,3 +0,0 @@
-int read_cman_nodes(struct corosync_api_v1 *api, unsigned int *config_version, int check_nodeids);
-int read_cman_config(struct corosync_api_v1 *api, unsigned int *config_version);
-
diff --git a/cman/daemon/cnxman-private.h b/cman/daemon/cnxman-private.h
deleted file mode 100644
index 002480d..0000000
--- a/cman/daemon/cnxman-private.h
+++ /dev/null
@@ -1,183 +0,0 @@
-#ifndef __CNXMAN_PRIVATE_H
-#define __CNXMAN_PRIVATE_H
-
-/* Protocol Version triplet */
-#define CNXMAN_MAJOR_VERSION 6
-#define CNXMAN_MINOR_VERSION 2
-#define CNXMAN_PATCH_VERSION 0
-
-struct cman_timer
-{
- struct list list;
- struct timeval tv;
- int active;
- void (*callback)(void *arg);
- void *arg;
-};
-
-/* A cluster internal protocol message - port number 0 */
-struct cl_protmsg {
- unsigned char cmd;
-};
-
-
-/* A Cluster PORT OPENED/CLOSED message */
-struct cl_portmsg {
- unsigned char cmd; /* CLUSTER_CMD_PORTOPENED/CLOSED */
- unsigned char port;
-};
-
-/* Subcommands for BARRIER message */
-#define BARRIER_REGISTER 1
-#define BARRIER_CHANGE 2
-#define BARRIER_WAIT 4
-#define BARRIER_COMPLETE 5
-
-/* A Cluster BARRIER message */
-struct cl_barriermsg {
- unsigned char cmd; /* CLUSTER_CMD_BARRIER */
- unsigned char subcmd; /* BARRIER sub command */
- unsigned short pad;
-
- char name[MAX_BARRIER_NAME_LEN];
-};
-
-struct cl_transmsg {
- unsigned char cmd;
- unsigned char first_trans;
- uint16_t cluster_id;
- int votes;
- int expected_votes;
-
- unsigned int major_version; /* Not backwards compatible */
- unsigned int minor_version; /* Backwards compatible */
- unsigned int patch_version; /* Backwards/forwards compatible */
- unsigned int config_version;
- unsigned int flags;
- uint64_t fence_time;
- uint64_t join_time;
- char clustername[16];
- char fence_agent[];
-};
-
-struct cl_killmsg {
- unsigned char cmd;
- unsigned char pad1;
- uint16_t reason;
- int nodeid;
-};
-
-struct cl_leavemsg {
- unsigned char cmd;
- unsigned char pad1;
- uint16_t reason;
-};
-
-
-/* Reconfigure a cluster parameter */
-struct cl_reconfig_msg {
- unsigned char cmd;
- unsigned char param;
- unsigned short pad;
- int nodeid;
- unsigned int value;
-};
-
-struct cl_fencemsg {
- unsigned char cmd;
- unsigned char fenced;
- uint16_t pad;
- int nodeid;
- uint64_t timesec;
- char agent[0];
-};
-
-typedef enum {CON_COMMS, CON_CLIENT_RENDEZVOUS, CON_ADMIN_RENDEZVOUS,
- CON_CLIENT, CON_ADMIN} con_type_t;
-
-/* One of these for every connection we have open
- and need to select() on */
-struct connection
-{
- int fd;
- con_type_t type;
- uint32_t port; /* If bound client */
- enum {SHUTDOWN_REPLY_UNK=0, SHUTDOWN_REPLY_YES, SHUTDOWN_REPLY_NO} shutdown_reply;
- uint32_t events; /* Registered for events */
- uint32_t confchg; /* Registered for confchg */
- struct list write_msgs; /* Queued messages to go to data clients */
- uint32_t num_write_msgs; /* Count of messages */
- struct connection *next;
- struct list list; /* when on the client_list */
-};
-
-/* Parameters for RECONFIG command */
-#define RECONFIG_PARAM_EXPECTED_VOTES 1
-#define RECONFIG_PARAM_NODE_VOTES 2
-#define RECONFIG_PARAM_CONFIG_VERSION 3
-#define RECONFIG_PARAM_CCS 4
-
-/* NODE_FLAGS_BEENDOWN - This node has been down.
- NODE_FLAGS_FENCED - This node has been fenced since it last went down.
- NODE_FLAGS_FENCEDWHILEUP - This node was fenced manually (probably).
- NODE_FLAGS_SEESDISALLOWED - Only set in a transition message
- NODE_FLAGS_DIRTY - This node has internal state and must not join
- a cluster that also has state.
- NODE_FLAGS_REREAD - Set when the node is re-read from config, so
- we can spot deleted nodes
-*/
-#define NODE_FLAGS_BEENDOWN 1
-#define NODE_FLAGS_FENCED 2
-#define NODE_FLAGS_FENCEDWHILEUP 4
-#define NODE_FLAGS_SEESDISALLOWED 8
-#define NODE_FLAGS_DIRTY 16
-#define NODE_FLAGS_REREAD 32
-
-/* There's one of these for each node in the cluster */
-struct cluster_node {
- struct list list;
- char *name; /* Node/host name of node */
- struct list addr_list;
- int us; /* This node is us */
- unsigned int node_id; /* Unique node ID */
- int flags;
- nodestate_t state;
- struct timeval join_time;
-
- /* When & how this node was last fenced */
- uint64_t fence_time; /* A time_t */
- char *fence_agent;
-
- uint64_t cman_join_time; /* A time_t */
-
- struct timeval last_hello; /* Only used for quorum devices */
-
- unsigned int votes;
- unsigned int expected_votes;
- unsigned int leave_reason;
- uint64_t incarnation;
-
- /* 32 bytes gives us enough for 256 bits (8 bit port number) */
-#define PORT_BITS_SIZE 32
- unsigned char port_bits[PORT_BITS_SIZE]; /* bitmap of ports open on this node */
-};
-
-/* Cluster protocol commands sent to port 0 */
-#define CLUSTER_MSG_ACK 1
-#define CLUSTER_MSG_PORTOPENED 2
-#define CLUSTER_MSG_PORTCLOSED 3
-#define CLUSTER_MSG_BARRIER 4
-#define CLUSTER_MSG_TRANSITION 5
-#define CLUSTER_MSG_KILLNODE 6
-#define CLUSTER_MSG_LEAVE 7
-#define CLUSTER_MSG_RECONFIGURE 8
-#define CLUSTER_MSG_PORTENQ 9
-#define CLUSTER_MSG_PORTSTATUS 10
-#define CLUSTER_MSG_FENCESTATUS 11
-
-/* Kill reasons */
-#define CLUSTER_KILL_REJECTED 1
-#define CLUSTER_KILL_CMANTOOL 2
-#define CLUSTER_KILL_REJOIN 3
-
-#endif
diff --git a/cman/daemon/cnxman-socket.h b/cman/daemon/cnxman-socket.h
deleted file mode 100644
index e6bb5dd..0000000
--- a/cman/daemon/cnxman-socket.h
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * CMAN socket interface header
- * Should only be used by libcman - if you want to call CMAN then use the library!
- */
-
-#ifndef __CNXMAN_SOCKET_H
-#define __CNXMAN_SOCKET_H
-
-/*
- * Commands on the socket.
- * if the top bit is set then it is only allowed
- * on the ADMIN socket.
- */
-#define CMAN_CMD_NOTIFY 0x00000001
-#define CMAN_CMD_REMOVENOTIFY 0x00000002
-#define CMAN_CMD_SETEXPECTED_VOTES 0x80000004
-#define CMAN_CMD_ISQUORATE 0x00000005
-#define CMAN_CMD_ISLISTENING 0x00000006
-#define CMAN_CMD_GETALLMEMBERS 0x00000007
-#define CMAN_CMD_SET_VOTES 0x80000008
-#define CMAN_CMD_GET_VERSION 0x00000009
-#define CMAN_CMD_SET_VERSION 0x8000000a
-#define CMAN_CMD_ISACTIVE 0x0000000b
-#define CMAN_CMD_KILLNODE 0x8000000c
-#define CMAN_CMD_GET_JOINCOUNT 0x0000000d
-#define CMAN_CMD_GETNODECOUNT 0x0000000e
-#define CMAN_CMD_GETNODE 0x00000090
-#define CMAN_CMD_GETCLUSTER 0x00000091
-#define CMAN_CMD_GETEXTRAINFO 0x00000092
-#define CMAN_CMD_BARRIER 0x000000a0
-#define CMAN_CMD_LEAVE_CLUSTER 0x800000b4
-#define CMAN_CMD_REG_QUORUMDEV 0x800000b5
-#define CMAN_CMD_UNREG_QUORUMDEV 0x800000b6
-#define CMAN_CMD_POLL_QUORUMDEV 0x800000b7
-#define CMAN_CMD_UPDATE_QUORUMDEV 0x800000b8
-#define CMAN_CMD_TRY_SHUTDOWN 0x800000bb
-#define CMAN_CMD_SHUTDOWN_REPLY 0x000000bc
-#define CMAN_CMD_UPDATE_FENCE_INFO 0x800000bd
-#define CMAN_CMD_GET_FENCE_INFO 0x000000be
-#define CMAN_CMD_GET_NODEADDRS 0x000000bf
-#define CMAN_CMD_START_CONFCHG 0x000000c0
-#define CMAN_CMD_STOP_CONFCHG 0x000000c1
-#define CMAN_CMD_SET_DIRTY 0x800000c2
-#define CMAN_CMD_SET_DEBUGLOG 0x800000c3
-#define CMAN_CMD_DUMP_OBJDB 0x800000c4
-#define CMAN_CMD_GETNODE_EXTRA 0x000000c5
-
-#define CMAN_CMD_DATA 0x00000100
-#define CMAN_CMD_BIND 0x00000101
-#define CMAN_CMD_EVENT 0x00000102
-#define CMAN_CMD_CONFCHG 0x00000103
-
-#define CMAN_CMDFLAG_PRIV 0x80000000
-#define CMAN_CMDFLAG_REPLY 0x40000000
-#define CMAN_CMDMASK_CMD 0x0000FFFF
-
-
-/* Maximum size of a cluster message */
-#define MAX_CLUSTER_MESSAGE 1500
-#define MAX_CLUSTER_MEMBER_NAME_LEN 255
-#define MAX_BARRIER_NAME_LEN 33
-#define MAX_CLUSTER_NAME_LEN 16
-#define MAX_FENCE_AGENT_NAME_LEN 255
-
-/* Well-known cluster port numbers */
-#define CLUSTER_PORT_MEMBERSHIP 1 /* Mustn't block during cluster
- * transitions! */
-#define CLUSTER_PORT_SERVICES 2
-#define CLUSTER_PORT_SYSMAN 10 /* Remote execution daemon */
-#define CLUSTER_PORT_CLVMD 11 /* Cluster LVM daemon */
-#define CLUSTER_PORT_QDISKD 178 /* Quorum disk daemon */
-
-/* Port numbers above this will be blocked when the cluster is inquorate or in
- * transition */
-#define HIGH_PROTECTED_PORT 9
-
-/* Nodeid passed to CMD_GETNODE to return the quorum device info */
-#define CLUSTER_GETNODE_QUORUMDEV -1
-
-/* Reasons for leaving the cluster */
-#define CLUSTER_LEAVEFLAG_DOWN 0 /* Normal shutdown */
-#define CLUSTER_LEAVEFLAG_KILLED 1
-#define CLUSTER_LEAVEFLAG_PANIC 2
-#define CLUSTER_LEAVEFLAG_REMOVED 3 /* This one can reduce quorum */
-#define CLUSTER_LEAVEFLAG_REJECTED 4 /* Not allowed into the cluster in the
- * first place */
-#define CLUSTER_LEAVEFLAG_INCONSISTENT 5 /* Our view of the cluster is
- * in a minority */
-#define CLUSTER_LEAVEFLAG_DEAD 6 /* Discovered to be dead */
-#define CLUSTER_LEAVEFLAG_NORESPONSE 7 /* Didn't ACK message */
-#define CLUSTER_LEAVEFLAG_FORCE 0x10 /* Forced by command-line */
-
-/* CMAN_CMD_EVENT reason codes */
-#define EVENT_REASON_PORTCLOSED 0
-#define EVENT_REASON_STATECHANGE 1
-#define EVENT_REASON_PORTOPENED 2
-#define EVENT_REASON_TRY_SHUTDOWN 3
-#define EVENT_REASON_CONFIG_UPDATE 4
-
-/* Shutdown flags */
-#define SHUTDOWN_ANYWAY 1
-#define SHUTDOWN_REMOVE 2
-
-/*
- * Sendmsg flags, these are above the normal sendmsg flags so they don't
- * interfere
- */
-#define MSG_TOTEM_AGREED 0x1000000
-#define MSG_TOTEM_SAFE 0x2000000
-#define MSG_BCASTSELF 0x4000000
-
-typedef enum { NODESTATE_JOINING=1, NODESTATE_MEMBER,
- NODESTATE_DEAD, NODESTATE_LEAVING, NODESTATE_AISONLY } nodestate_t;
-
-static const char CLIENT_SOCKNAME[]= "/var/run/cman_client";
-static const char ADMIN_SOCKNAME[]= "/var/run/cman_admin";
-
-/* This struct should be in front of all messages
- * passed down the client and admin sockets.
- */
-#define CMAN_MAGIC 0x434d414e
-#define CMAN_VERSION 0x10000003
-struct sock_header {
- uint32_t magic;
- uint32_t version;
- uint32_t length;
- uint32_t command;
- uint32_t flags;
-};
-
-/* Data message header */
-struct sock_data_header {
- struct sock_header header;
- int nodeid;
- uint32_t port;
- /* Data follows */
-};
-
-/* Reply message */
-struct sock_reply_header {
- struct sock_header header;
- int status;
- /* Any returned information follows */
-};
-
-/* Event message */
-struct sock_event_message {
- struct sock_header header;
- int reason;
- int arg;
-};
-
-/* confchg message */
-struct sock_confchg_message {
- struct sock_header header;
- int member_entries;
- int left_entries;
- int joined_entries;
- unsigned int entries[]; // In above order.
-};
-
-/* Flags */
-#define CMAN_EXTRA_FLAG_2NODE 1
-#define CMAN_EXTRA_FLAG_ERROR 2
-#define CMAN_EXTRA_FLAG_SHUTDOWN 4
-#define CMAN_EXTRA_FLAG_UNCOUNTED 8
-#define CMAN_EXTRA_FLAG_DIRTY 16
-#define CMAN_EXTRA_FLAG_DISALLOWED_ENABLED 32
-
-struct cl_extra_info {
- int node_state;
- uint32_t flags;
- int node_votes;
- int total_votes;
- int expected_votes;
- int quorum;
- int members;
- char ports[32];
- int num_addresses; /* Number of real addresses, so the array below has
- <n>*2 addresses in it */
- char addresses[1]; /* Array of num_addresses sockaddr_storage
- 1st n are multicast addresses */
-};
-
-/* This is the structure, per node, returned from the membership call */
-struct cl_cluster_node {
- unsigned int size;
- unsigned int node_id;
- unsigned int us;
- unsigned int leave_reason;
- unsigned int incarnation;
- nodestate_t state;
- char name[MAX_CLUSTER_MEMBER_NAME_LEN];
- char addr[sizeof(struct sockaddr_storage)];
- unsigned int addrlen;
- struct timeval jointime;
- unsigned char votes;
-};
-
-struct cl_node_extra
-{
- int nodeid;
- int state;
- int votes;
- int expected_votes;
- int leave_reason;
-};
-
-
-/* Structure passed to CMAN_CMD_ISLISTENING */
-struct cl_listen_request {
- unsigned char port;
- int nodeid;
-};
-
-/* Get all version numbers or set the config version */
-struct cl_version {
- unsigned int major;
- unsigned int minor;
- unsigned int patch;
- unsigned int config;
-};
-
-/* structure passed to barrier command */
-struct cl_barrier_info {
- char cmd;
- char name[MAX_BARRIER_NAME_LEN];
- unsigned int flags;
- unsigned long arg;
-};
-
-struct cl_cluster_info {
- char name[MAX_CLUSTER_NAME_LEN+1];
- uint16_t number;
- uint32_t generation;
-};
-
-struct cl_set_votes {
- int nodeid;
- int newvotes;
-};
-
-/* An array of these is returned */
-struct cl_node_addrs {
- int addrlen;
- struct sockaddr_storage addr;
-};
-
-struct cl_get_node_addrs {
- int numaddrs;
- struct cl_node_addrs addrs[];
-};
-
-#define FENCE_FLAGS_FENCED 2
-struct cl_fence_info {
- int nodeid;
- int flags;
- uint64_t fence_time;
- char fence_agent[MAX_FENCE_AGENT_NAME_LEN];
-};
-
-struct cl_qdev_info {
- char name[MAX_CLUSTER_MEMBER_NAME_LEN];
- int state;
- int votes;
-};
-
-/* Commands to the barrier cmd */
-#define BARRIER_CMD_REGISTER 1
-#define BARRIER_CMD_CHANGE 2
-#define BARRIER_CMD_DELETE 3
-#define BARRIER_CMD_WAIT 4
-
-/* Attributes of a barrier - bitmask */
-#define BARRIER_ATTR_AUTODELETE 1
-#define BARRIER_ATTR_MULTISTEP 2
-#define BARRIER_ATTR_MANUAL 4
-#define BARRIER_ATTR_ENABLED 8
-#define BARRIER_ATTR_CALLBACK 16
-
-/* Attribute setting commands */
-#define BARRIER_SETATTR_AUTODELETE 1
-#define BARRIER_SETATTR_MULTISTEP 2
-#define BARRIER_SETATTR_ENABLED 3
-#define BARRIER_SETATTR_NODES 4
-#define BARRIER_SETATTR_CALLBACK 5
-#define BARRIER_SETATTR_TIMEOUT 6
-
-#endif
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
deleted file mode 100644
index bbbc460..0000000
--- a/cman/daemon/commands.c
+++ /dev/null
@@ -1,2459 +0,0 @@
-#include <getopt.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <syslog.h>
-#include <string.h>
-#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/signal.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/errno.h>
-#include <dlfcn.h>
-
-#include <corosync/corotypes.h>
-#include <corosync/coroipc_types.h>
-#include <corosync/coroipcc.h>
-#include <corosync/corodefs.h>
-#include <corosync/mar_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-#include "list.h"
-#include "cman.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "daemon.h"
-#include "barrier.h"
-#define OBJDB_API struct corosync_api_v1
-#include "cmanconfig.h"
-#include "nodelist.h"
-#include "commands.h"
-#include "ais.h"
-
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME);
-
-/* Reference counting for cluster applications */
-static int use_count;
-
-/* Array of "ports" allocated. This is just a list of pointers to the connection that
- * has this port bound. Port 0 is reserved for protocol messages */
-static struct connection *port_array[256];
-
-// Stuff that was more global
-static LIST_INIT(cluster_members_list);
- int cluster_members;
- int we_are_a_cluster_member;
- unsigned int config_version;
-static struct cluster_node *us;
-static int quorum;
-extern int two_node;
- unsigned int quorumdev_poll=DEFAULT_QUORUMDEV_POLL;
- unsigned int shutdown_timeout=DEFAULT_SHUTDOWN_TIMEOUT;
- unsigned int ccsd_poll_interval=DEFAULT_CCSD_POLL;
- unsigned int enable_disallowed=DEFAULT_DISALLOWED;
- unsigned int startup_config_timeout=DEFAULT_STARTUP_CONFIG_TIMEOUT;
-static int cluster_is_quorate;
- char cluster_name[MAX_CLUSTER_NAME_LEN+1];
-static char nodename[MAX_CLUSTER_MEMBER_NAME_LEN+1];
-static int wanted_nodeid;
-static struct cluster_node *quorum_device;
-static uint16_t cluster_id;
-static int ais_running;
-static time_t join_time;
-static corosync_timer_handle_t quorum_device_timer;
-static struct corosync_api_v1 *corosync;
-
-/* If CCS gets out of sync, we poll it until it isn't */
-static corosync_timer_handle_t ccsd_timer;
-static unsigned int wanted_config_version;
-static int config_error;
-static int local_first_trans;
-
-static corosync_timer_handle_t shutdown_timer;
-static struct connection *shutdown_con;
-static uint32_t shutdown_flags;
-static int shutdown_yes;
-static int shutdown_no;
-static int shutdown_expected;
-static int ccsd_timer_active = 0;
-
-static struct cluster_node *find_node_by_nodeid(int nodeid);
-static struct cluster_node *find_node_by_name(char *name);
-static int get_node_count(void);
-static int send_port_open_msg(unsigned char port);
-static int send_port_enquire(int nodeid);
-static void process_internal_message(char *data, int nodeid, int byteswap);
-static void recalculate_quorum(int allow_decrease, int by_current_nodes);
-static void send_kill(int nodeid, uint16_t reason);
-static const char *killmsg_reason(int reason);
-static void ccsd_timer_fn(void *arg);
-static int reload_config(int new_version, int should_broadcast);
-
-static void set_port_bit(struct cluster_node *node, uint8_t port)
-{
- int byte;
- int bit;
-
- byte = port/8;
- bit = port%8;
-
- node->port_bits[byte] |= 1<<bit;
-}
-
-static void clear_port_bit(struct cluster_node *node, uint8_t port)
-{
- int byte;
- int bit;
-
- byte = port/8;
- bit = port%8;
-
- node->port_bits[byte] &= ~(1<<bit);
-}
-
-static int get_port_bit(struct cluster_node *node, uint8_t port)
-{
- int byte;
- int bit;
-
- byte = port/8;
- bit = port%8;
-
- return ((node->port_bits[byte] & (1<<bit)) != 0);
-}
-
-static int have_disallowed(void)
-{
- struct cluster_node *node;
-
- if (!enable_disallowed)
- return 0;
-
- list_iterate_items(node, &cluster_members_list) {
- if (node->state == NODESTATE_AISONLY)
- return 1;
- }
-
- return 0;
-}
-
-/* Make a totem_ip_address into a usable sockaddr_storage */
-static int totemip_to_sockaddr(struct totem_ip_address *ip_addr,
- uint16_t port, struct sockaddr_storage *saddr, int *addrlen)
-{
- int ret = -1;
-
- if (ip_addr->family == AF_INET) {
- struct sockaddr_in *sin = (struct sockaddr_in *)saddr;
-
- memset(sin, 0, sizeof(struct sockaddr_in));
- sin->sin_family = ip_addr->family;
- sin->sin_port = port;
- memcpy(&sin->sin_addr, ip_addr->addr, sizeof(struct in_addr));
- *addrlen = sizeof(struct sockaddr_in);
- ret = 0;
- }
-
- if (ip_addr->family == AF_INET6) {
- struct sockaddr_in6 *sin = (struct sockaddr_in6 *)saddr;
-
- memset(sin, 0, sizeof(struct sockaddr_in6));
- sin->sin6_family = ip_addr->family;
- sin->sin6_port = port;
- sin->sin6_scope_id = 2;
- memcpy(&sin->sin6_addr, ip_addr->addr, sizeof(struct in6_addr));
-
- *addrlen = sizeof(struct sockaddr_in6);
- ret = 0;
- }
-
- return ret;
-}
-
-/* If "cluster_is_quorate" is 0 then all activity apart from protected ports is
- * blocked. */
-static void set_quorate(int total_votes)
-{
- int quorate;
- unsigned int nodelist[PROCESSOR_COUNT_MAX];
- int nodecount = 0;
- struct cluster_node *node = NULL;
- struct list *tmp;
-
- if (quorum > total_votes || config_error) {
- quorate = 0;
- }
- else {
- quorate = 1;
- }
-
- if (cluster_is_quorate && !quorate)
- log_printf(LOG_INFO, "quorum lost, blocking activity\n");
- if (!cluster_is_quorate && quorate)
- log_printf(LOG_INFO, "quorum regained, resuming activity\n");
-
- /* If we are newly quorate, then kill any AISONLY nodes */
- if (!cluster_is_quorate && quorate) {
-
- list_iterate(tmp, &cluster_members_list) {
- node = list_item(tmp, struct cluster_node);
- if (node->state == NODESTATE_AISONLY)
- send_kill(node->node_id, CLUSTER_KILL_REJOIN);
- }
- }
-
- cluster_is_quorate = quorate;
-
- /* Inform corosync subsystems */
- list_iterate(tmp, &cluster_members_list) {
- node = list_item(tmp, struct cluster_node);
- if (node->state == NODESTATE_MEMBER) {
- nodelist[nodecount++] = node->node_id;
- }
- }
-
- corosync_set_quorum(nodelist, nodecount, quorate, &cman_ring_id);
-}
-
-static void node_add_ordered(struct cluster_node *newnode)
-{
- struct cluster_node *node = NULL;
- struct list *tmp;
- struct list *newlist = &newnode->list;
-
- list_iterate(tmp, &cluster_members_list) {
- node = list_item(tmp, struct cluster_node);
-
- if (newnode->node_id < node->node_id)
- break;
- }
-
- if (!node)
- list_add(&cluster_members_list, &newnode->list);
- else {
- newlist->p = tmp->p;
- newlist->n = tmp;
- tmp->p->n = newlist;
- tmp->p = newlist;
- }
-}
-
-static struct cluster_node *add_new_node(char *name, int nodeid, int votes, int expected_votes,
- nodestate_t state)
-{
- struct cluster_node *newnode = NULL;
- int newalloc = 0;
-
- if (nodeid)
- newnode = find_node_by_nodeid(nodeid);
-
- if (!newnode) {
- newnode = malloc(sizeof(struct cluster_node));
- if (!newnode) {
- log_printf(LOG_ERR, "Unable to allocate memory for node %s\n", name);
- return NULL;
- }
- memset(newnode, 0, sizeof(struct cluster_node));
- newalloc = 1;
- newnode->state = state;
- if (state == NODESTATE_MEMBER)
- newnode->incarnation = incarnation;
- }
- if (!newnode->name) {
- newnode->name = strdup(name);
- if (!newnode->name) {
- if (newalloc)
- free(newnode);
- return NULL;
- }
- }
-
- if (!newnode->node_id) /* Don't clobber existing nodeid */
- newnode->node_id = nodeid;
- if (votes >= 0)
- newnode->votes = votes;
- if (expected_votes)
- newnode->expected_votes = expected_votes;
-
- /* If this node has a name passed in then use that rather than a previous generated one */
- if (name && newnode->name && strcmp(name, newnode->name)) {
- char *newname;
-
- newname = strdup(name);
- if (newname) {
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: replacing old node name %s with %s\n", newnode->name, name);
- free(newnode->name);
- newnode->name = newname;
- }
- }
-
- if (newalloc)
- node_add_ordered(newnode);
-
- newnode->flags |= NODE_FLAGS_REREAD;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: add_new_node: %s, (id=%d, votes=%d) newalloc=%d\n",
- name, nodeid, votes, newalloc);
-
- return newnode;
-}
-
-static void send_reconfigure(int nodeid, int param, int value)
-{
- struct cl_reconfig_msg msg;
-
- msg.cmd = CLUSTER_MSG_RECONFIGURE;
- msg.param = param;
- msg.nodeid = nodeid;
- msg.value = value;
-
- comms_send_message((char *)&msg, sizeof(msg),
- 0,0,
- 0, /* multicast */
- 0); /* flags */
-}
-
-static int calculate_quorum(int allow_decrease, int max_expected, unsigned int *ret_total_votes)
-{
- struct list *nodelist;
- struct cluster_node *node;
- unsigned int total_votes = 0;
- unsigned int highest_expected = 0;
- unsigned int newquorum, q1, q2;
- unsigned int total_nodes = 0;
-
- list_iterate(nodelist, &cluster_members_list) {
- node = list_item(nodelist, struct cluster_node);
-
- if (node->state == NODESTATE_MEMBER) {
- if (max_expected)
- node->expected_votes = max_expected;
- else
- highest_expected = max(highest_expected, node->expected_votes);
- total_votes += node->votes;
- total_nodes++;
- }
- }
- if (quorum_device && quorum_device->state == NODESTATE_MEMBER)
- total_votes += quorum_device->votes;
-
- if (max_expected > 0)
- highest_expected = max_expected;
-
- /* This quorum calculation is taken from the OpenVMS Cluster Systems
- * manual, but, then, you guessed that didn't you */
- q1 = (highest_expected + 2) / 2;
- q2 = (total_votes + 2) / 2;
- newquorum = max(q1, q2);
-
- /* Normally quorum never decreases but the system administrator can
- * force it down by setting expected votes to a maximum value */
- if (!allow_decrease)
- newquorum = max(quorum, newquorum);
-
- /* The special two_node mode allows each of the two nodes to retain
- * quorum if the other fails. Only one of the two should live past
- * fencing (as both nodes try to fence each other in split-brain.)
- * Also: if there are more than two nodes, force us inquorate to avoid
- * any damage or confusion.
- */
- if (two_node && total_nodes <= 2)
- newquorum = 1;
-
- if (ret_total_votes)
- *ret_total_votes = total_votes;
- return newquorum;
-}
-
-/* Recalculate cluster quorum, set quorate and notify changes */
-static void recalculate_quorum(int allow_decrease, int by_current_nodes)
-{
- unsigned int total_votes;
-
- quorum = calculate_quorum(allow_decrease, by_current_nodes?cluster_members:0, &total_votes);
- set_quorate(total_votes);
- notify_listeners(NULL, EVENT_REASON_STATECHANGE, cluster_is_quorate);
-}
-
-/* Copy internal node format to userland format */
-static void copy_to_usernode(struct cluster_node *node,
- struct cl_cluster_node *unode)
-{
- struct sockaddr_storage ss;
- int addrlen=0;
- unsigned int numaddrs=1;
- char **status;
- struct totem_ip_address node_ifs[INTERFACE_MAX];
- /* totempg_ifaces_get always copies INTERFACE_MAX addresses */
-
- strncpy(unode->name, node->name, MAX_CLUSTER_MEMBER_NAME_LEN - 1);
- unode->jointime = node->join_time;
- unode->size = sizeof(struct cl_cluster_node);
- unode->votes = node->votes;
- unode->state = node->state;
- unode->us = node->us;
- unode->node_id = node->node_id;
- unode->leave_reason = node->leave_reason;
- unode->incarnation = node->incarnation;
-
- /* Just send the first address. If the user wants the full set they
- must ask for them */
- corosync->totem_ifaces_get(node->node_id, node_ifs, &status, &numaddrs);
-
- totemip_to_sockaddr(&node_ifs[0], 0, &ss, &addrlen);
- memcpy(unode->addr, &ss, addrlen);
- unode->addrlen = addrlen;
-}
-
-
-int cman_set_nodename(char *name)
-{
- if (ais_running)
- return -EALREADY;
-
- strncpy(nodename, name, MAX_CLUSTER_MEMBER_NAME_LEN - 1);
- return 0;
-}
-
-int cman_set_nodeid(int nodeid)
-{
- if (ais_running)
- return -EALREADY;
-
- wanted_nodeid = nodeid;
- return 0;
-}
-
-int cman_join_cluster(struct corosync_api_v1 *api,
- char *name, unsigned short cl_id,
- int two_node_flag, int votes, int expected_votes)
-{
- if (ais_running)
- return -EALREADY;
-
- if (strlen(name) > MAX_CLUSTER_NAME_LEN)
- return -EINVAL;
-
- cluster_id = cl_id;
- strncpy(cluster_name, name, MAX_CLUSTER_NAME_LEN);
- two_node = two_node_flag;
- corosync = api;
-
- quit_threads = 0;
- ais_running = 1;
-
- /* Make sure we have a node name */
- if (nodename[0] == '\0') {
- struct utsname un;
- if (uname(&un)) {
- return -EINVAL;
- }
- strncpy(nodename, un.nodename, sizeof(nodename) - 1);
- }
-
- time(&join_time);
- us = add_new_node(nodename, wanted_nodeid, votes, expected_votes,
- NODESTATE_DEAD);
- set_port_bit(us, 0);
- us->us = 1;
-
- return 0;
-}
-
-/* command processing functions */
-
-static int do_cmd_set_version(char *cmdbuf, int *retlen)
-{
- struct cl_version *version = (struct cl_version *)cmdbuf;
-
- if (!we_are_a_cluster_member)
- return -ENOENT;
-
- if (version->major != CNXMAN_MAJOR_VERSION ||
- version->minor != CNXMAN_MINOR_VERSION ||
- version->patch != CNXMAN_PATCH_VERSION)
- return -EINVAL;
-
- return reload_config(version->config, 1);
-}
-
-static int do_cmd_get_extrainfo(char *cmdbuf, char **retbuf, int retsize, int *retlen, int offset)
-{
- char *outbuf = *retbuf + offset;
- struct cl_extra_info *einfo = (struct cl_extra_info *)outbuf;
- struct totem_ip_address node_ifs[MAX_INTERFACES];
- int total_votes = 0;
- int max_expected = 0;
- int addrlen;
- int uncounted = 0;
- unsigned int num_interfaces;
- hdb_handle_t totem_object_handle;
- hdb_handle_t object_handle;
- hdb_handle_t totem_find_handle;
- hdb_handle_t iface_find_handle;
- char **status;
- struct cluster_node *node;
- struct sockaddr_storage *ss;
- char *ptr;
- int i;
-
- if (!we_are_a_cluster_member)
- return -ENOENT;
-
- corosync->totem_ifaces_get(us->node_id, node_ifs, &status, &num_interfaces);
-
- list_iterate_items(node, &cluster_members_list) {
- if (node->state == NODESTATE_MEMBER) {
- total_votes += node->votes;
- max_expected = max(max_expected, node->expected_votes);
- }
- if (node->state == NODESTATE_AISONLY)
- uncounted = 1;
- }
- if (quorum_device && quorum_device->state == NODESTATE_MEMBER)
- total_votes += quorum_device->votes;
-
- /* Enough room for addresses ? */
- if (retsize < (sizeof(struct cl_extra_info) +
- sizeof(struct sockaddr_storage) * (MAX_INTERFACES*2))) {
-
- *retbuf = malloc(sizeof(struct cl_extra_info) + sizeof(struct sockaddr_storage) * (MAX_INTERFACES*2));
- if (*retbuf == NULL)
- return -ENOMEM;
- outbuf = *retbuf + offset;
- einfo = (struct cl_extra_info *)outbuf;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: get_extrainfo: allocated new buffer\n");
- }
-
- einfo->node_state = us->state;
- einfo->node_votes = us->votes;
- einfo->total_votes = total_votes;
- einfo->expected_votes = max_expected;
- einfo->quorum = quorum;
- einfo->members = cluster_members;
- einfo->num_addresses = num_interfaces;
- memcpy(einfo->ports, us->port_bits, 32);
- einfo->flags = 0;
- if (two_node)
- einfo->flags |= CMAN_EXTRA_FLAG_2NODE;
- if (config_error)
- einfo->flags |= CMAN_EXTRA_FLAG_ERROR;
- if (shutdown_con)
- einfo->flags |= CMAN_EXTRA_FLAG_SHUTDOWN;
- if (uncounted)
- einfo->flags |= CMAN_EXTRA_FLAG_UNCOUNTED;
- if (us->flags & NODE_FLAGS_DIRTY)
- einfo->flags |= CMAN_EXTRA_FLAG_DIRTY;
- if (enable_disallowed)
- einfo->flags |= CMAN_EXTRA_FLAG_DISALLOWED_ENABLED;
-
- ptr = einfo->addresses;
-
- corosync->object_find_create(OBJECT_PARENT_HANDLE, "totem", strlen("totem"), &totem_find_handle);
- if (corosync->object_find_next(totem_find_handle, &totem_object_handle) == 0) {
-
- corosync->object_find_create(totem_object_handle, "interface", strlen("interface"), &iface_find_handle);
- while (corosync->object_find_next(iface_find_handle, &object_handle) == 0) {
-
- char *mcast;
- struct sockaddr_in *saddr4;
- struct sockaddr_in6 *saddr6;
-
- objdb_get_string(corosync, object_handle, "mcastaddr", &mcast);
- /* If this fails, it must be using broadcast*/
- if (!mcast)
- mcast = (char*)"255.255.255.255";
- memset(ptr, 0, sizeof(struct sockaddr_storage));
-
- saddr4 = (struct sockaddr_in *)ptr;
- saddr6 = (struct sockaddr_in6 *)ptr;
- if ( inet_pton(AF_INET, mcast, &saddr4->sin_addr) >0) {
- saddr4->sin_family = AF_INET;
- }
- else {
- if (inet_pton(AF_INET6, mcast, &saddr6->sin6_addr) > 0)
- saddr4->sin_family = AF_INET6;
- }
- ptr += sizeof(struct sockaddr_storage);
- }
-
- corosync->object_find_destroy(iface_find_handle);
- }
- corosync->object_find_destroy(totem_find_handle);
-
- for (i=0; i<num_interfaces; i++) {
- ss = (struct sockaddr_storage *)ptr;
- totemip_to_sockaddr(&node_ifs[i], 0, ss, &addrlen);
- ptr += sizeof(struct sockaddr_storage);
- }
-
- *retlen = ptr - outbuf;
- return 0;
-}
-
-static int do_cmd_get_all_members(char *cmdbuf, char **retbuf, int retsize, int *retlen, int offset)
-{
- struct cluster_node *node;
- struct cl_cluster_node *user_node;
- struct list *nodelist;
- char *outbuf = *retbuf + offset;
- int num_nodes = 0;
- int total_nodes = 0;
-
- if (!we_are_a_cluster_member)
- return -ENOENT;
-
- /* Count nodes */
- list_iterate(nodelist, &cluster_members_list) {
- total_nodes++;
- }
- if (quorum_device)
- total_nodes++;
-
- /* if retsize == 0 then don't return node information */
- if (retsize) {
- /* If there is not enough space in the default buffer, allocate some more. */
- if ((retsize / sizeof(struct cl_cluster_node)) < total_nodes) {
- *retbuf = malloc(sizeof(struct cl_cluster_node) * total_nodes + offset);
- if (!*retbuf)
- return -ENOMEM;
- outbuf = *retbuf + offset;
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: get_all_members: allocated new buffer (retsize=%d)\n", retsize);
- }
- }
- user_node = (struct cl_cluster_node *)outbuf;
-
- /* This returns the full list */
- list_iterate_items(node, &cluster_members_list) {
- if (retsize) {
- copy_to_usernode(node, user_node);
-
- user_node++;
- num_nodes++;
- }
- }
-
- if (quorum_device) {
- copy_to_usernode(quorum_device, user_node);
- user_node++;
- num_nodes++;
- }
-
- *retlen = sizeof(struct cl_cluster_node) * num_nodes;
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: get_all_members: retlen = %d\n", *retlen);
- return num_nodes;
-}
-
-
-static int do_cmd_get_cluster(char *cmdbuf, char *retbuf, int *retlen)
-{
- struct cl_cluster_info *info = (struct cl_cluster_info *)retbuf;
-
- info->number = cluster_id;
- info->generation = incarnation;
- memcpy(&info->name, cluster_name, strlen(cluster_name)+1);
- *retlen = sizeof(struct cl_cluster_info);
-
- return 0;
-}
-
-static int do_cmd_get_node(char *cmdbuf, char *retbuf, int *retlen)
-{
- struct cluster_node *node;
- struct cl_cluster_node *u_node = (struct cl_cluster_node *)cmdbuf;
- struct cl_cluster_node *r_node = (struct cl_cluster_node *)retbuf;
-
- if (!we_are_a_cluster_member)
- return -ENOENT;
-
- if (u_node->node_id == CLUSTER_GETNODE_QUORUMDEV) {
- if (quorum_device)
- node = quorum_device;
- else
- return -ENOENT;
- }
- else {
- if (!u_node->name[0]) {
- if (u_node->node_id == 0)
- u_node->node_id = us->node_id;
- node = find_node_by_nodeid(u_node->node_id);
- }
- else
- node = find_node_by_name(u_node->name);
-
- if (!node) {
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: cmd_get_node failed: id=%d, name='%s'\n", u_node->node_id, u_node->name);
- return -ENOENT;
- }
- }
-
- copy_to_usernode(node, r_node);
- *retlen = sizeof(struct cl_cluster_node);
-
- return 0;
-}
-
-static int do_cmd_get_node_extra(char *cmdbuf, char *retbuf, int *retlen)
-{
- struct cluster_node *node;
- struct cl_node_extra *r_node = (struct cl_node_extra *)retbuf;
- int nodeid;
-
- if (!we_are_a_cluster_member)
- return -ENOENT;
-
- memcpy(&nodeid, cmdbuf, sizeof(int));
-
- if (nodeid == CLUSTER_GETNODE_QUORUMDEV) {
- return -EINVAL;
- }
- node = find_node_by_nodeid(nodeid);
- if (nodeid == 0)
- node = us;
- if (!node)
- return -EINVAL;
-
- r_node->votes = node->votes;
- r_node->expected_votes = node->expected_votes;
- r_node->state = node->state;
- r_node->leave_reason = node->leave_reason;
- r_node->nodeid = nodeid;
-
- *retlen = sizeof(struct cl_node_extra);
-
- return 0;
-}
-
-static int do_cmd_set_expected(char *cmdbuf, int *retlen)
-{
- unsigned int total_votes;
- unsigned int newquorum;
- unsigned int newexp;
- struct cluster_node *node = NULL;
- struct list *tmp;
-
- if (!we_are_a_cluster_member)
- return -ENOENT;
-
- /* If there are any AISONLY nodes then we can't allow
- the user to set expected votes as it may destroy data */
- list_iterate(tmp, &cluster_members_list) {
- node = list_item(tmp, struct cluster_node);
- if (node->state == NODESTATE_AISONLY) {
- log_printf(LOG_NOTICE, "Attempt to set expected votes when cluster has AISONLY nodes in it.");
- return -EINVAL;
- }
- }
-
- memcpy(&newexp, cmdbuf, sizeof(int));
- newquorum = calculate_quorum(1, newexp, &total_votes);
-
- if (newquorum < total_votes / 2
- || newquorum > total_votes) {
- return -EINVAL;
- }
-
- override_expected(newexp);
- send_reconfigure(us->node_id, RECONFIG_PARAM_EXPECTED_VOTES, newexp);
-
- /* We will recalculate quorum when we get our own message back */
- return 0;
-}
-
-static void send_kill(int nodeid, uint16_t reason)
-{
- struct cl_killmsg msg;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Sending KILL to node %d\n", nodeid);
-
- msg.cmd = CLUSTER_MSG_KILLNODE;
- msg.reason = reason;
- msg.nodeid = nodeid;
-
- comms_send_message((char *)&msg, sizeof(msg),
- 0,0,
- nodeid,
- 0); /* flags */
-}
-
-static void send_leave(uint16_t reason)
-{
- struct cl_leavemsg msg;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Sending LEAVE, reason %d\n", reason);
-
- msg.cmd = CLUSTER_MSG_LEAVE;
- msg.reason = reason;
-
- comms_send_message((char *)&msg, sizeof(msg),
- 0,0,
- 0, /* multicast */
- 0); /* flags */
-}
-
-static int do_cmd_kill_node(char *cmdbuf, int *retlen)
-{
- struct cluster_node *node;
- int nodeid;
-
- if (!we_are_a_cluster_member)
- return -ENOENT;
-
- memcpy(&nodeid, cmdbuf, sizeof(int));
-
- if ((node = find_node_by_nodeid(nodeid)) == NULL)
- return -EINVAL;
-
- if (node->state != NODESTATE_MEMBER && node->state != NODESTATE_AISONLY)
- return -EINVAL;
-
- node->leave_reason = CLUSTER_LEAVEFLAG_KILLED;
- node->state = NODESTATE_LEAVING;
-
- /* Send a KILL message */
- send_kill(nodeid, CLUSTER_KILL_CMANTOOL);
-
- return 0;
-}
-
-
-static int do_cmd_islistening(struct connection *con, char *cmdbuf, int *retlen)
-{
- struct cl_listen_request rq;
- struct cluster_node *rem_node;
- int nodeid;
-
- if (!we_are_a_cluster_member)
- return -ENOENT;
-
- memcpy(&rq, cmdbuf, sizeof(rq));
-
- nodeid = rq.nodeid;
- if (!nodeid)
- nodeid = us->node_id;
-
- rem_node = find_node_by_nodeid(nodeid);
-
- /* Node not in the cluster */
- if (!rem_node)
- return -ENOENT;
-
- if (rem_node->state != NODESTATE_MEMBER)
- return -ENOTCONN;
-
- /* If the request is for us then just look in the ports
- * array */
- if (rem_node->us)
- return (port_array[rq.port] != 0) ? 1 : 0;
-
-
- /* If we don't know the node's port status then ask it.
- This should only need to be done when we are the new node in
- a cluster that has been running for a while
- */
- if (!get_port_bit(rem_node, 0)) {
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: islistening, no data for node %d, sending PORTENQ\n", nodeid);
- send_port_enquire(rem_node->node_id);
-
- /* Admit our ignorance */
- return -EBUSY;
- }
- else {
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: islistening, for node %d, low bytes are %x %x\n", nodeid, rem_node->port_bits[0], rem_node->port_bits[1]);
- return get_port_bit(rem_node, rq.port);
- }
-}
-
-
-static int do_cmd_set_votes(char *cmdbuf, int *retlen)
-{
- unsigned int total_votes;
- unsigned int newquorum;
- int saved_votes;
- struct cl_set_votes arg;
- struct cluster_node *node;
-
- if (!we_are_a_cluster_member)
- return -ENOTCONN;
-
- memcpy(&arg, cmdbuf, sizeof(arg));
-
- if (!arg.nodeid)
- arg.nodeid = us->node_id;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Setting votes for node %d to %d\n", arg.nodeid, arg.newvotes);
-
- node = find_node_by_nodeid(arg.nodeid);
- if (!node)
- return -ENOENT;
-
- /* Check votes is valid */
- saved_votes = node->votes;
- node->votes = arg.newvotes;
-
- newquorum = calculate_quorum(1, 0, &total_votes);
-
- if (newquorum < total_votes / 2 || newquorum > total_votes) {
- node->votes = saved_votes;
- return -EINVAL;
- }
-
- recalculate_quorum(1, 0);
-
- send_reconfigure(arg.nodeid, RECONFIG_PARAM_NODE_VOTES, arg.newvotes);
-
- return 0;
-}
-
-static int do_cmd_bind(struct connection *con, char *cmdbuf)
-{
- unsigned int port;
- int ret = -EADDRINUSE;
-
- memcpy(&port, cmdbuf, sizeof(int));
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: requested bind to port %d, (us=%p)\n", port, con);
-
- if (port == 0 || port > 255)
- return -EINVAL;
-
- if (port_array[port])
- goto out;
-
- ret = 0;
- port_array[port] = con;
- con->port = port;
-
- set_port_bit(us, con->port);
- send_port_open_msg(con->port);
-
- out:
- return ret;
-}
-
-static int do_cmd_leave_cluster(char *cmdbuf, int *retlen)
-{
- int leave_flags;
-
- if (!ais_running)
- return -ENOTCONN;
-
- memcpy(&leave_flags, cmdbuf, sizeof(int));
-
- /* Ignore the use count if FORCE is set */
- if (!(leave_flags == CLUSTER_LEAVEFLAG_FORCE)) {
- if (use_count)
- return -ENOTCONN;
- }
-
- us->leave_reason = leave_flags;
- quit_threads = 1;
-
- /* No messaging available yet, just die */
- if (!we_are_a_cluster_member) {
- cman_finish();
- exit(0);
- }
-
- send_leave(leave_flags);
- use_count = 0;
-
- /* When we get our leave message back, then quit */
- return 0;
-}
-
-static void check_shutdown_status(void)
-{
- int reply;
- int leaveflags = CLUSTER_LEAVEFLAG_DOWN;
-
- /* All replies safely gathered in ? */
- if (shutdown_yes + shutdown_no >= shutdown_expected) {
-
- if (shutdown_timer)
- corosync->timer_delete(shutdown_timer);
-
- if (shutdown_yes >= shutdown_expected ||
- shutdown_flags & SHUTDOWN_ANYWAY) {
- quit_threads = 1;
- if (shutdown_flags & SHUTDOWN_REMOVE)
- leaveflags = CLUSTER_LEAVEFLAG_REMOVED;
- send_leave(leaveflags);
- reply = 0;
- }
- else {
- reply = -EBUSY;
-
- /* Tell originator that shutdown was cancelled */
- send_status_return(shutdown_con, CMAN_CMD_TRY_SHUTDOWN, reply);
- shutdown_con = NULL;
- }
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: shutdown decision is: %d (yes=%d, no=%d) flags=%x\n", reply, shutdown_yes, shutdown_no, shutdown_flags);
- }
-}
-
-/* Not all nodes responded to the shutdown */
-static void shutdown_timer_fn(void *arg)
-{
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Shutdown timer fired. flags = %x\n", shutdown_flags);
-
- /* Mark undecideds as "NO" */
- shutdown_no = shutdown_expected;
- check_shutdown_status();
-}
-
-/* A service's response to a TRY_SHUTDOWN event. This NEVER returns a response */
-static int do_cmd_shutdown_reply(struct connection *con, char *cmdbuf)
-{
- int response = *(int *)cmdbuf;
-
- /* Not shutting down, but don't respond. */
- if (!shutdown_con)
- return -EWOULDBLOCK;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Shutdown reply is %d\n", response);
-
- /* We only need to keep a track of a client's response in
- case it pulls the connection before the shutdown process
- has completed */
- if (response) {
- shutdown_yes++;
- con->shutdown_reply = SHUTDOWN_REPLY_YES;
- }
- else {
- shutdown_no++;
- con->shutdown_reply = SHUTDOWN_REPLY_NO;
- }
- check_shutdown_status();
-
- /* No response needed to this message */
- return -EWOULDBLOCK;
-}
-
-/* User requested shutdown. We poll all listening clients and see if they are
- willing to shutdown */
-static int do_cmd_try_shutdown(struct connection *con, char *cmdbuf)
-{
- int flags = *(int *)cmdbuf;
-
- /* Are we already in shutdown ? */
- if (shutdown_con || quit_threads)
- return -EALREADY;
-
- shutdown_con = con;
- shutdown_flags = flags;
- shutdown_yes = 0;
- shutdown_no = 0;
- shutdown_expected = num_listeners();
-
- /* If no-one is listening for events then we can just go down now */
- if (shutdown_expected == 0) {
- shutdown_timer = 0;
- check_shutdown_status();
- }
- else {
-
- /* Start the timer. If we don't get a full set of replies before this goes
- off we'll cancel the shutdown */
- corosync->timer_add_duration((unsigned long long)shutdown_timeout*1000000, NULL,
- shutdown_timer_fn, &shutdown_timer);
-
- notify_listeners(NULL, EVENT_REASON_TRY_SHUTDOWN, flags);
-
- return -EWOULDBLOCK;
- }
- return 0;
-}
-
-static void free_quorum_device(void)
-{
- if (!quorum_device)
- return;
-
- if (quorum_device->name)
- free(quorum_device->name);
-
- free(quorum_device);
-
- quorum_device = NULL;
-}
-
-static void quorum_device_update_votes(int votes)
-{
- int oldvotes;
-
- /* Update votes even if it existed before */
- oldvotes = quorum_device->votes;
- quorum_device->votes = votes;
-
- /* If it is a member and votes changed, recalculate quorum */
- if (quorum_device->state == NODESTATE_MEMBER &&
- oldvotes != votes) {
- recalculate_quorum(1, 0);
- }
-}
-
-static int do_cmd_register_quorum_device(char *cmdbuf, int *retlen)
-{
- int votes;
- char *name = cmdbuf+sizeof(int);
-
- if (!ais_running) {
- log_printf(LOG_ERR, "unable to register quorum device: corosync is not running\n");
- return -ENOTCONN;
- }
-
- if (!we_are_a_cluster_member) {
- log_printf(LOG_ERR, "unable to register quorum device: this node is not part of a cluster\n");
- return -ENOENT;
- }
-
- if (strlen(name) > MAX_CLUSTER_MEMBER_NAME_LEN) {
- log_printf(LOG_ERR, "unable to register quorum device: name is too long\n");
- /* this should probably return -E2BIG? */
- return -EINVAL;
- }
-
- /* Allow re-registering of a quorum device if the name is the same */
- if (quorum_device && strcmp(name, quorum_device->name)) {
- log_printf(LOG_ERR, "unable to re-register quorum device: device names do not match\n");
- log_printf(LOG_DEBUG, "memb: old name: %s new name: %s\n", quorum_device->name, name);
- return -EBUSY;
- }
-
- if (find_node_by_name(name)) {
- log_printf(LOG_ERR, "unable to register quorum device: a node with the same name (%s) already exists\n", name);
- return -EALREADY;
- }
-
- memcpy(&votes, cmdbuf, sizeof(int));
-
- /* A new quorum device */
- if (!quorum_device)
- {
- quorum_device = malloc(sizeof(struct cluster_node));
- if (!quorum_device) {
- log_printf(LOG_ERR, "unable to register quorum device: not enough memory\n");
- return -ENOMEM;
- }
- memset(quorum_device, 0, sizeof(struct cluster_node));
-
- quorum_device->name = strdup(name);
- if (!quorum_device->name) {
- log_printf(LOG_ERR, "unable to register quorum device: not enough memory\n");
- free_quorum_device();
- return -ENOMEM;
- }
-
- quorum_device->state = NODESTATE_DEAD;
- gettimeofday(&quorum_device->join_time, NULL);
-
- /* Keep this list valid so it doesn't confuse other code */
- list_init(&quorum_device->addr_list);
- log_printf(LOG_INFO, "quorum device registered\n");
- }
- else
- {
- log_printf(LOG_INFO, "quorum device re-registered\n");
- }
-
- quorum_device_update_votes(votes);
-
- return 0;
-}
-
-static int do_cmd_unregister_quorum_device(char *cmdbuf, int *retlen)
-{
- if (!quorum_device) {
- log_printf(LOG_DEBUG, "memb: failed to unregister a non existing quorum device\n");
- return -EINVAL;
- }
-
- if (quorum_device->state == NODESTATE_MEMBER) {
- log_printf(LOG_DEBUG, "memb: failed to unregister: quorum device still active.\n");
- return -EBUSY;
- }
-
- free_quorum_device();
-
- log_printf(LOG_INFO, "quorum device unregistered\n");
- return 0;
-}
-
-static int do_cmd_update_quorum_device(char *cmdbuf, int *retlen)
-{
- int votes, ret = 0;
- char *name = cmdbuf+sizeof(int);
-
- if (!quorum_device) {
- log_printf(LOG_DEBUG, "memb: failed to update a non-existing quorum device\n");
- return -EINVAL;
- }
-
- memcpy(&votes, cmdbuf, sizeof(int));
-
- /* allow name change of the quorum device */
- if (quorum_device && strcmp(name, quorum_device->name)) {
- char *newname = NULL;
- char *oldname = NULL;
-
- log_printf(LOG_DEBUG, "memb: old name: %s new name: %s\n", quorum_device->name, name);
- newname = strdup(name);
- if (!newname) {
- log_printf(LOG_ERR, "memb: unable to update quorum device name: out of memory\n");
- ret = -ENOMEM;
- goto out;
- }
- log_printf(LOG_INFO, "quorum device name changed to %s\n", name);
- oldname = quorum_device->name;
- quorum_device->name = newname;
- free(oldname);
- }
-
-out:
- quorum_device_update_votes(votes);
-
- return ret;
-}
-
-static int reload_config(int new_version, int should_broadcast)
-{
- const char *reload_err = NULL;
-
- if (config_version == new_version) {
- log_printf(LOG_DEBUG, "We are already using config version [%d]\n",
- config_version);
- return 0;
- }
-
- if (new_version > 0 && new_version < config_version) {
- log_printf(LOG_ERR, "Requested version [%d] older than running version [%d]\n",
- new_version, config_version);
- return -1;
- }
-
- wanted_config_version = new_version;
-
- /* Tell objdb to reload */
- config_error = corosync->object_reload_config(1, &reload_err);
- if (config_error)
- log_printf(LOG_ERR, "Unable to load new config in corosync: %s\n",
- reload_err);
-
- if (!config_error)
- config_error = read_cman_nodes(corosync, &config_version, 0);
-
- if (config_error) {
- if (wanted_config_version) {
- log_printf(LOG_ERR, "Can't get updated config version %d: %s.\n",
- wanted_config_version, reload_err?reload_err:"version mismatch on this node");
- } else {
- log_printf(LOG_ERR, "Can't get updated config version: %s.\n",
- reload_err?reload_err:"version mismatch on this node");
- }
-
- if (should_broadcast) {
- log_printf(LOG_ERR, "Continuing activity with old configuration\n");
- config_error=0;
- return -2;
- } else {
- log_printf(LOG_ERR, "Activity suspended on this node\n");
-
- if (!ccsd_timer_active) {
- log_printf(LOG_ERR, "Error reloading the configuration, will retry every second\n");
- corosync->timer_add_duration((unsigned long long)ccsd_poll_interval*1000000, NULL,
- ccsd_timer_fn, &ccsd_timer);
- ccsd_timer_active = 1;
- }
- }
- } else {
-
- /*
- * at this point we know:
- * config is loaded in objdb with a newer version than the previous one
- * we have been able to activate it in cman (via read_cman_nodes)
- */
-
- if (should_broadcast) {
- log_printf(LOG_DEBUG, "Sending reconfigure message to all nodes\n");
- send_reconfigure(us->node_id, RECONFIG_PARAM_CONFIG_VERSION, config_version);
- }
-
- log_printf(LOG_DEBUG, "Recalculating quorum\n");
- recalculate_quorum(1, 0);
-
- log_printf(LOG_DEBUG, "Notify all listeners\n");
- notify_listeners(NULL, EVENT_REASON_CONFIG_UPDATE, config_version);
- }
- return config_error;
-}
-
-static void ccsd_timer_fn(void *arg)
-{
- log_printf(LOG_DEBUG, "Polling configuration for updated information\n");
-
- ccsd_timer_active = 0;
-
- if (!reload_config(wanted_config_version, 0) &&
- config_version >= wanted_config_version) {
- log_printf(LOG_DEBUG, "ccsd_timer_fn got the new config\n");
- config_error = 0;
- return;
- }
-
- if (local_first_trans) {
- time_t now;
- now = time(NULL);
-
- if (now > join_time+startup_config_timeout) {
- log_printf(LOG_ERR, "Checking for startup failure: time=%d\n", (int)(now - join_time));
- log_printf(LOG_ERR, "Failed to get an up-to-date config file, wanted %d, only got %d. Will exit\n",
- wanted_config_version, config_version);
- log_printf(LOG_ERR, "Check your configuration distribution method is working correctly\n");
- cman_finish();
- corosync_shutdown();
- }
- }
-}
-
-static void quorum_device_timer_fn(void *arg)
-{
- struct timeval now;
- unsigned long long timediff_us;
- if (!quorum_device || quorum_device->state == NODESTATE_DEAD)
- return;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: quorum_device_timer_fn\n");
- gettimeofday(&now, NULL);
- timediff_us=((now.tv_sec - quorum_device->last_hello.tv_sec)*1000000 + (now.tv_usec - quorum_device->last_hello.tv_usec));
- if (timediff_us >= quorumdev_poll*1000) {
- quorum_device->state = NODESTATE_DEAD;
- log_printf(LOG_INFO, "lost contact with quorum device\n");
- recalculate_quorum(0, 0);
- }
- else {
- corosync->timer_add_duration(1000*(quorumdev_poll*1000 - timediff_us),
- quorum_device, quorum_device_timer_fn, &quorum_device_timer);
- }
-}
-
-static int do_cmd_poll_quorum_device(char *cmdbuf, int *retlen)
-{
- int yesno;
-
- if (!quorum_device)
- return -EINVAL;
-
- memcpy(&yesno, cmdbuf, sizeof(int));
-
- if (yesno) {
- gettimeofday(&quorum_device->last_hello, NULL);
- if (quorum_device->state == NODESTATE_DEAD) {
- quorum_device->state = NODESTATE_MEMBER;
- recalculate_quorum(0, 0);
-
- corosync->timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
- quorum_device_timer_fn, &quorum_device_timer);
- }
- }
- else {
- if (quorum_device->state == NODESTATE_MEMBER) {
- quorum_device->state = NODESTATE_DEAD;
- recalculate_quorum(0, 0);
- corosync->timer_delete(quorum_device_timer);
- }
- }
-
- return 0;
-}
-
-/* fence_tool tells us it has fenced a node */
-static int do_cmd_update_fence_info(char *cmdbuf)
-{
- struct cl_fence_info *f = (struct cl_fence_info *)cmdbuf;
- struct cluster_node *node;
- char msg[sizeof(struct cl_fencemsg)+strlen(f->fence_agent)+1];
- struct cl_fencemsg *fence_msg = (struct cl_fencemsg *)msg;
-
- node = find_node_by_nodeid(f->nodeid);
- if (!node)
- return -EINVAL;
-
- if (strlen(f->fence_agent) >= MAX_FENCE_AGENT_NAME_LEN)
- return -EINVAL;
-
- node->flags |= NODE_FLAGS_FENCED;
- if (node->state == NODESTATE_MEMBER)
- node->flags |= NODE_FLAGS_FENCEDWHILEUP;
-
- /* Tell the rest of the cluster (and us!) */
- fence_msg->cmd = CLUSTER_MSG_FENCESTATUS;
- fence_msg->nodeid = f->nodeid;
- fence_msg->timesec = f->fence_time;
- fence_msg->fenced = 1;
- strncpy(fence_msg->agent, f->fence_agent, MAX_FENCE_AGENT_NAME_LEN - 1);
- comms_send_message(msg, sizeof(msg), 0,0, 0, 0);
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: node %d fenced by %s\n", f->nodeid, f->fence_agent);
- return 0;
-}
-
-static int do_cmd_get_fence_info(char *cmdbuf, char **retbuf, int retsize, int *retlen, int offset)
-{
- int nodeid;
- char *outbuf = *retbuf + offset;
- struct cl_fence_info *f = (struct cl_fence_info *)outbuf;
- struct cluster_node *node;
-
- if (retsize < sizeof(struct cl_fence_info))
- return -EINVAL;
- memcpy(&nodeid, cmdbuf, sizeof(nodeid));
-
- node = find_node_by_nodeid(nodeid);
- if (!node)
- return -EINVAL;
-
- f->nodeid = nodeid;
- f->fence_time = node->fence_time;
- f->flags = node->flags&NODE_FLAGS_FENCED;
-
- if (node->fence_agent)
- strncpy(f->fence_agent, node->fence_agent, MAX_FENCE_AGENT_NAME_LEN - 1);
- else
- f->fence_agent[0] = '\0';
- *retlen = sizeof(struct cl_fence_info);
- return 0;
-}
-
-static int do_cmd_get_node_addrs(char *cmdbuf, char **retbuf, int retsize, int *retlen, int offset)
-{
- int nodeid;
- int i;
- char *outbuf = *retbuf + offset;
- struct cl_get_node_addrs *addrs = (struct cl_get_node_addrs *)outbuf;
- struct totem_ip_address node_ifs[INTERFACE_MAX]; /* totempg_ifaces_get always copies INTERFACE_MAX addresses */
- struct cluster_node *node;
- char **status;
-
- if (retsize < sizeof(struct cl_node_addrs))
- return -EINVAL;
- memcpy(&nodeid, cmdbuf, sizeof(nodeid));
-
- node = find_node_by_nodeid(nodeid);
- if (!node)
- return -EINVAL;
-
- memset(outbuf, 0, retsize - offset);
-
- /* AIS doesn't know about nodes that are not members */
- if (node->state != NODESTATE_MEMBER) {
- addrs->numaddrs = 0;
- *retlen = sizeof(struct cl_get_node_addrs);
- return 0;
- }
-
- if (corosync->totem_ifaces_get(nodeid, node_ifs, &status, (unsigned int *)&addrs->numaddrs))
- return -errno;
-
- for (i=0; i<addrs->numaddrs; i++) {
- totemip_to_sockaddr(&node_ifs[i], 0,
- &addrs->addrs[i].addr,
- &addrs->addrs[i].addrlen);
- }
- *retlen = sizeof(struct cl_get_node_addrs) +
- addrs->numaddrs * sizeof(struct cl_node_addrs);
-
- return 0;
-}
-
-int process_command(struct connection *con, int cmd, char *cmdbuf,
- char **retbuf, int *retlen, int retsize, int offset)
-{
- int err = -EINVAL;
- struct cl_version cnxman_version;
- char *outbuf = *retbuf;
- int value;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: command to process is %x\n", cmd);
-
- switch (cmd) {
-
- case CMAN_CMD_NOTIFY:
- con->events = 1;
- err = 0;
- /* If a shutdown is in progress, ask the newcomer what it thinks... */
- if (shutdown_con) {
- notify_listeners(con, EVENT_REASON_TRY_SHUTDOWN, shutdown_flags);
- shutdown_expected++;
- }
- break;
-
- case CMAN_CMD_REMOVENOTIFY:
- con->events = 0;
- err = 0;
- break;
-
- case CMAN_CMD_SET_DIRTY:
- us->flags |= NODE_FLAGS_DIRTY;
- err = 0;
- break;
-
- case CMAN_CMD_SET_DEBUGLOG:
- memcpy(&value, cmdbuf, sizeof(int));
- /* sanitize input value */
- if (value > 0)
- value = 1;
-
- logsys_config_debug_set(CMAN_NAME, value);
- err = 0;
- break;
- case CMAN_CMD_START_CONFCHG:
- con->confchg = 1;
- err = 0;
- break;
-
- case CMAN_CMD_STOP_CONFCHG:
- con->confchg = 0;
- err = 0;
- break;
-
- /* Return the cnxman version number */
- case CMAN_CMD_GET_VERSION:
- err = 0;
- cnxman_version.major = CNXMAN_MAJOR_VERSION;
- cnxman_version.minor = CNXMAN_MINOR_VERSION;
- cnxman_version.patch = CNXMAN_PATCH_VERSION;
- cnxman_version.config = config_version;
- memcpy(outbuf+offset, &cnxman_version, sizeof(struct cl_version));
- *retlen = sizeof(struct cl_version);
- break;
-
- /* Set the cnxman config version number */
- case CMAN_CMD_SET_VERSION:
- err = do_cmd_set_version(cmdbuf, retlen);
- break;
-
- /* Bind to a "port" */
- case CMAN_CMD_BIND:
- err = do_cmd_bind(con, cmdbuf);
- break;
-
- /* Return the full membership list including dead nodes */
- case CMAN_CMD_GETALLMEMBERS:
- err = do_cmd_get_all_members(cmdbuf, retbuf, retsize, retlen, offset);
- break;
-
- case CMAN_CMD_GETNODECOUNT:
- err = get_node_count();
- break;
-
- case CMAN_CMD_GETNODE:
- err = do_cmd_get_node(cmdbuf, outbuf+offset, retlen);
- break;
-
- case CMAN_CMD_GETNODE_EXTRA:
- err = do_cmd_get_node_extra(cmdbuf, outbuf+offset, retlen);
- break;
-
- case CMAN_CMD_GETCLUSTER:
- err = do_cmd_get_cluster(cmdbuf, outbuf+offset, retlen);
- break;
-
- case CMAN_CMD_GETEXTRAINFO:
- err = do_cmd_get_extrainfo(cmdbuf, retbuf, retsize, retlen, offset);
- break;
-
- case CMAN_CMD_ISQUORATE:
- return cluster_is_quorate;
-
- case CMAN_CMD_ISACTIVE:
- return ais_running;
-
- case CMAN_CMD_SETEXPECTED_VOTES:
- err = do_cmd_set_expected(cmdbuf, retlen);
- break;
-
- /* Change the number of votes for this node */
- case CMAN_CMD_SET_VOTES:
- err = do_cmd_set_votes(cmdbuf, retlen);
- break;
-
- /* Return 1 if the specified node is listening on a given port */
- case CMAN_CMD_ISLISTENING:
- err = do_cmd_islistening(con, cmdbuf, retlen);
- break;
-
- /* Forcibly kill a node */
- case CMAN_CMD_KILLNODE:
- err = do_cmd_kill_node(cmdbuf, retlen);
- break;
-
- case CMAN_CMD_BARRIER:
- err = do_cmd_barrier(con, cmdbuf, retlen);
- break;
-
- case CMAN_CMD_LEAVE_CLUSTER:
- err = do_cmd_leave_cluster(cmdbuf, retlen);
- break;
-
- case CMAN_CMD_GET_JOINCOUNT:
- err = num_connections;
- break;
-
- case CMAN_CMD_TRY_SHUTDOWN:
- err = do_cmd_try_shutdown(con, cmdbuf);
- break;
-
- case CMAN_CMD_SHUTDOWN_REPLY:
- err = do_cmd_shutdown_reply(con, cmdbuf);
- break;
-
- case CMAN_CMD_REG_QUORUMDEV:
- err = do_cmd_register_quorum_device(cmdbuf, retlen);
- break;
-
- case CMAN_CMD_UNREG_QUORUMDEV:
- err = do_cmd_unregister_quorum_device(cmdbuf, retlen);
- break;
-
- case CMAN_CMD_UPDATE_QUORUMDEV:
- err = do_cmd_update_quorum_device(cmdbuf, retlen);
- break;
-
- case CMAN_CMD_POLL_QUORUMDEV:
- err = do_cmd_poll_quorum_device(cmdbuf, retlen);
- break;
-
- case CMAN_CMD_UPDATE_FENCE_INFO:
- err = do_cmd_update_fence_info(cmdbuf);
- break;
-
- case CMAN_CMD_GET_FENCE_INFO:
- err = do_cmd_get_fence_info(cmdbuf, retbuf, retsize, retlen, offset);
- break;
-
- case CMAN_CMD_GET_NODEADDRS:
- err = do_cmd_get_node_addrs(cmdbuf, retbuf, retsize, retlen, offset);
- break;
- }
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: command return code is %d\n", err);
- return err;
-}
-
-
-int send_to_userport(unsigned char fromport, unsigned char toport,
- int nodeid, int tgtid,
- const char *recv_buf, int len,
- int endian_conv)
-{
- int ret = -1;
-
- if (toport == 0) {
-
- /* We need to make a private copy here so that the internal command
- * processors can do byteswapping.
- */
- char *newmsg = alloca(len);
- if (!newmsg)
- return -1;
- memcpy(newmsg, recv_buf, len);
- process_internal_message(newmsg, nodeid, endian_conv);
- ret = 0;
- }
- else {
- /* Send to external listener */
- if (port_array[toport]) {
- struct connection *c = port_array[toport];
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: send_to_userport. cmd=%d, endian_conv=%d\n", recv_buf[0],endian_conv);
-
- send_data_reply(c, nodeid, fromport, recv_buf, len);
- ret = 0;
- }
- }
- return ret;
-}
-
-void cman_send_confchg(const unsigned int *member_list, size_t member_list_entries,
- const unsigned int *left_list, size_t left_list_entries,
- const unsigned int *joined_list, size_t joined_list_entries)
-{
- char buf[sizeof(struct sock_confchg_message) +
- (member_list_entries+left_list_entries+joined_list_entries) * sizeof(int)];
- struct sock_confchg_message *msg = (struct sock_confchg_message *)buf;
-
- msg->header.magic = CMAN_MAGIC;
- msg->header.command = CMAN_CMD_CONFCHG;
- msg->header.length = sizeof(buf);
- msg->header.flags = 0;
-
- msg->member_entries = member_list_entries;
- msg->joined_entries = joined_list_entries;
- msg->left_entries = left_list_entries;
-
- memcpy(msg->entries, member_list, sizeof(int)*member_list_entries);
- memcpy(msg->entries+member_list_entries, left_list, sizeof(int)*left_list_entries);
- memcpy(msg->entries+member_list_entries+left_list_entries, joined_list, sizeof(int)*joined_list_entries);
-
- notify_confchg((struct sock_header *)msg);
-}
-
-
-/* Send a port closedown message to all cluster nodes - this tells them that a
- * port listener has gone away */
-static int send_port_close_msg(unsigned char port)
-{
- struct cl_portmsg portmsg;
-
- /* Build the header */
- portmsg.cmd = CLUSTER_MSG_PORTCLOSED;
- portmsg.port = port;
-
- return comms_send_message(&portmsg, sizeof(portmsg), 0,0, 0, 0);
-}
-
-static int send_port_enquire(int nodeid)
-{
- char msg[1];
-
- /* Build the header */
- msg[0] = CLUSTER_MSG_PORTENQ;
-
- return comms_send_message(msg, 1, 0,0, nodeid, 0);
-}
-
-static int send_port_open_msg(unsigned char port)
-{
- struct cl_portmsg portmsg;
-
- /* Build the header */
- portmsg.cmd = CLUSTER_MSG_PORTOPENED;
- portmsg.port = port;
-
- return comms_send_message(&portmsg, sizeof(portmsg), 0,0, 0, 0);
-}
-
-void unbind_con(struct connection *con)
-{
- if (con->port) {
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Unbinding con for port %d\n", con->port);
- port_array[con->port] = NULL;
- send_port_close_msg(con->port);
- clear_port_bit(us, con->port);
- con->port = 0;
- }
-
- /* If we're in shutdown and this client was listening for events
- then we take its closedown as a "Yes" to the "can we shutdown"
- question. If it previously answered "No", we need to change its vote */
- if (shutdown_con && con->events) {
- if (con->shutdown_reply) {
- if (con->shutdown_reply == SHUTDOWN_REPLY_YES)
- shutdown_yes--;
- if (con->shutdown_reply == SHUTDOWN_REPLY_NO)
- shutdown_no--;
- }
- con->shutdown_reply = SHUTDOWN_REPLY_YES; /* I'll take that as a "Yes" then */
- shutdown_yes++;
-
- check_shutdown_status();
- }
-
- /* If the controlling shutdown process has quit, then cancel the
- shutdown session */
- if (con == shutdown_con)
- shutdown_con = NULL;
-}
-
-/* Post a PORT OPEN/CLOSE event to anyone listening on this end */
-static void post_port_event(int reason, unsigned char port, int nodeid)
-{
- struct connection *con = port_array[port];
-
- if (con)
- notify_listeners(con, reason, nodeid);
-}
-
-int our_nodeid(void)
-{
- if (us)
- return us->node_id;
- else
- return 0;
-}
-
-/* Sanity check TRANSITION message */
-static int valid_transition_msg(int nodeid, struct cl_transmsg *msg)
-{
- if (strcmp(msg->clustername, cluster_name) != 0) {
- log_printf(LOG_ERR, "Node %d conflict, remote cluster name='%s', local='%s'\n",
- nodeid, msg->clustername, cluster_name);
- return -1;
- }
-
- if (msg->cluster_id != cluster_id) {
- log_printf(LOG_ERR, "Node %d conflict, remote cluster id=%d, local=%d\n",
- nodeid, msg->cluster_id, cluster_id);
- return -1;
- }
-
- if (msg->major_version != CNXMAN_MAJOR_VERSION) {
-
- log_printf(LOG_ERR, "Node %d conflict, remote version id=%d, local=%d\n",
- nodeid, msg->major_version, CNXMAN_MAJOR_VERSION);
- return -1;
- }
-
- if (local_first_trans) {
- time_t now;
- now = time(NULL);
-
- if (now > join_time+startup_config_timeout) {
- log_printf(LOG_DEBUG, "ccs: disable startup transition check\n");
- local_first_trans = 0;
- }
- }
-
- /* New config version - try to read new file */
- if (msg->config_version > config_version) {
- log_printf(LOG_DEBUG, "Reloading config from TRANSITION message\n");
- if (reload_config(msg->config_version, 0)) {
- if (msg->config_version != config_version) {
- log_printf(LOG_ERR, "Node %d conflict, remote config version id=%d, local=%d\n",
- nodeid, msg->config_version, config_version);
- return -1;
- }
- }
- }
-
- if ((msg->config_version == config_version) && (nodeid != us->node_id)) {
- log_printf(LOG_DEBUG, "Completed first transition with nodes on the same config versions\n");
- local_first_trans = 0;
- }
-
- return 0;
-}
-
-
-void send_transition_msg(int last_memb_count, int first_trans)
-{
- char buf[sizeof(struct cl_transmsg)+1024] __attribute__((aligned(8)));
- struct cl_transmsg *msg = (struct cl_transmsg *)buf;
- int len = sizeof(struct cl_transmsg);
-
- we_are_a_cluster_member = 1;
- local_first_trans = first_trans;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: sending TRANSITION message. cluster_name = %s\n", cluster_name);
- msg->cmd = CLUSTER_MSG_TRANSITION;
- msg->first_trans = first_trans;
- msg->votes = us->votes;
- msg->expected_votes = us->expected_votes;
- msg->cluster_id = cluster_id;
- msg->major_version = CNXMAN_MAJOR_VERSION;
- msg->minor_version = CNXMAN_MINOR_VERSION;
- msg->patch_version = CNXMAN_PATCH_VERSION;
- msg->config_version = config_version;
- msg->flags = us->flags;
- msg->fence_time = us->fence_time;
- msg->join_time = join_time;
- memcpy(msg->clustername, cluster_name, MAX_CLUSTER_NAME_LEN);
- if (us->fence_agent)
- {
- strncpy(msg->fence_agent, us->fence_agent, MAX_FENCE_AGENT_NAME_LEN - 1);
- len += strlen(us->fence_agent)+1;
- }
- else
- {
- msg->fence_agent[0] = '\0';
- len += 1;
- }
-
- if (have_disallowed())
- msg->flags |= NODE_FLAGS_SEESDISALLOWED;
-
- comms_send_message(msg, len,
- 0,0,
- 0, /* multicast */
- 0); /* flags */
-}
-
-static void byteswap_internal_message(char *data)
-{
- struct cl_protmsg *msg = (struct cl_protmsg *)data;
- struct cl_killmsg *killmsg;
- struct cl_leavemsg *leavemsg;
- struct cl_transmsg *transmsg;
- struct cl_fencemsg *fencemsg;
- struct cl_reconfig_msg *reconfmsg;
-
- switch (msg->cmd) {
- case CLUSTER_MSG_PORTOPENED:
- case CLUSTER_MSG_PORTCLOSED:
- /* Just a byte */
- break;
-
- case CLUSTER_MSG_TRANSITION:
- transmsg = (struct cl_transmsg *)data;
- transmsg->cluster_id = swab16(transmsg->cluster_id);
- transmsg->votes = swab32(transmsg->votes);
- transmsg->expected_votes = swab32(transmsg->expected_votes);
- transmsg->major_version = swab32(transmsg->major_version);
- transmsg->minor_version = swab32(transmsg->minor_version);
- transmsg->patch_version = swab32(transmsg->patch_version);
- transmsg->config_version = swab32(transmsg->config_version);
- transmsg->flags = swab32(transmsg->flags);
- transmsg->fence_time = swab64(transmsg->fence_time);
- break;
-
- case CLUSTER_MSG_KILLNODE:
- killmsg = (struct cl_killmsg *)data;
- killmsg->reason = swab16(killmsg->reason);
- killmsg->nodeid = swab32(killmsg->nodeid);
- break;
-
- case CLUSTER_MSG_LEAVE:
- leavemsg = (struct cl_leavemsg *)data;
- leavemsg->reason = swab16(leavemsg->reason);
- break;
-
- case CLUSTER_MSG_BARRIER:
- break;
-
- case CLUSTER_MSG_RECONFIGURE:
- reconfmsg = (struct cl_reconfig_msg *)data;
- reconfmsg->nodeid = swab32(reconfmsg->nodeid);
- reconfmsg->value = swab32(reconfmsg->value);
- break;
-
- case CLUSTER_MSG_FENCESTATUS:
- fencemsg = (struct cl_fencemsg *)data;
- fencemsg->timesec = swab64(fencemsg->timesec);
- fencemsg->nodeid = swab32(fencemsg->nodeid);
- break;
- }
-}
-
-
-static void do_reconfigure_msg(void *data)
-{
- struct cl_reconfig_msg *msg = data;
- struct cluster_node *node;
- struct list *nodelist;
-
- node = find_node_by_nodeid(msg->nodeid);
- if (!node)
- return;
-
- /* We must be fully started by now */
- local_first_trans = 0;
-
- switch(msg->param)
- {
- case RECONFIG_PARAM_EXPECTED_VOTES:
- node->expected_votes = msg->value;
-
- list_iterate(nodelist, &cluster_members_list) {
- node = list_item(nodelist, struct cluster_node);
- if (node->state == NODESTATE_MEMBER &&
- node->expected_votes > msg->value) {
- node->expected_votes = msg->value;
- }
- }
- recalculate_quorum(1, 0); /* Allow decrease */
- break;
-
- case RECONFIG_PARAM_NODE_VOTES:
- node->votes = msg->value;
- recalculate_quorum(1, 0); /* Allow decrease */
- break;
-
- case RECONFIG_PARAM_CONFIG_VERSION:
- reload_config(msg->value, 0);
- break;
- }
-}
-
-static void do_fence_msg(void *data)
-{
- struct cl_fencemsg *msg = data;
- struct cluster_node *node;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: got FENCE message, node %d fenced by %s\n", msg->nodeid, msg->agent);
-
- node = find_node_by_nodeid(msg->nodeid);
- if (!node)
- return;
-
- node->fence_time = msg->timesec;
- if (node->fence_agent)
- free(node->fence_agent);
- node->fence_agent = strdup(msg->agent);
- if (msg->fenced) {
- node->flags |= NODE_FLAGS_FENCED;
-
- if (node->state == NODESTATE_MEMBER)
- node->flags |= NODE_FLAGS_FENCEDWHILEUP;
- }
-
-}
-
-static void do_process_transition(int nodeid, char *data)
-{
- struct cl_transmsg *msg = (struct cl_transmsg *)data;
- struct cluster_node *node;
- unsigned int old_expected;
- nodestate_t old_state;
-
- if (valid_transition_msg(nodeid, msg) != 0) {
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Transition message from %d does not match current config - should quit ?\n", nodeid);
- // Now what ??
- return;
- }
-
- /* If the remote node can see AISONLY nodes and we want to join,
- then we can't, as we don't know the full state */
- if (enable_disallowed &&
- local_first_trans && msg->flags & NODE_FLAGS_SEESDISALLOWED && !have_disallowed()) {
- /* Must use syslog directly here or the message will never arrive */
- syslog(LOG_CRIT, "CMAN: Joined a cluster with disallowed nodes. must die");
- cman_finish();
- exit(2);
- }
- msg->flags &= ~NODE_FLAGS_SEESDISALLOWED;
-
- node = find_node_by_nodeid(nodeid);
- if (!node) {
- add_ais_node(nodeid, incarnation, num_ais_nodes);
- node = find_node_by_nodeid(nodeid);
- }
- assert(node);
- old_expected = node->expected_votes;
- old_state = node->state;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Got TRANSITION message. msg->flags=%x, node->flags=%x, first_trans=%d\n",
- msg->flags, node->flags, msg->first_trans);
-
- /* Newer nodes 6.1.0 onwards, set the DIRTY flag if they have state. If the new node has been down
- and has state then we mark it disallowed because we cannot merge stateful nodes */
- if (enable_disallowed) {
- if ( (msg->flags & NODE_FLAGS_DIRTY && (node->flags & NODE_FLAGS_BEENDOWN)) ||
- (msg->flags & NODE_FLAGS_DIRTY && msg->first_trans && !node->us && (us->flags & NODE_FLAGS_DIRTY))) {
- /* Don't duplicate messages */
- if (node->state != NODESTATE_AISONLY) {
- if (cluster_is_quorate) {
- node->state = NODESTATE_AISONLY;
-
- /* Oh, this gets even more complicated. Don't send a KILL message if we are in a two_node
- * cluster and that node has a lower node ID than us.
- * This allows fencing time to startup and caters for the situation where
- * a node rejoins REALLY quickly, before fencing has had time to work.
- * I've split this up a bit partly for clarity, but mainly so allow us to
- * print out helpful messages as to what we are up to here.
- */
- if (two_node) {
- if (node->node_id > us->node_id) {
- log_printf(LOG_CRIT, "Killing node %s because it has rejoined the cluster with existing state and has higher node ID", node->name);
- send_kill(nodeid, CLUSTER_KILL_REJOIN);
- }
- else {
- log_printf(LOG_CRIT, "Not killing node %s despite it rejoining the cluster with existing state, it has a lower node ID", node->name);
- }
- }
- else {
- log_printf(LOG_CRIT, "Killing node %s because it has rejoined the cluster with existing state", node->name);
- send_kill(nodeid, CLUSTER_KILL_REJOIN);
- }
- }
- else {
- log_printf(LOG_CRIT, "Node %s not joined to cman because it has existing state", node->name);
- node->state = NODESTATE_AISONLY;
- }
- }
- return;
- }
-
- /* This is for older nodes. If the join_time of the node matches that already stored AND
- the node has been down, then we kill it as this must be a rejoin */
- if (msg->minor_version == 0 &&
- msg->join_time == node->cman_join_time && node->flags & NODE_FLAGS_BEENDOWN) {
- /* Don't duplicate messages */
- if (node->state != NODESTATE_AISONLY) {
- if (cluster_is_quorate) {
- log_printf(LOG_CRIT, "Killing node %s because it has rejoined the cluster without cman_tool join", node->name);
- node->state = NODESTATE_AISONLY;
- send_kill(nodeid, CLUSTER_KILL_REJOIN);
- }
- else {
- log_printf(LOG_CRIT, "Node %s not joined to cman because it has rejoined an inquorate cluster", node->name);
- node->state = NODESTATE_AISONLY;
- }
- }
- return;
- }
- else {
- node->cman_join_time = msg->join_time;
- add_ais_node(nodeid, incarnation, num_ais_nodes);
- }
- }
- else {
- add_ais_node(nodeid, incarnation, num_ais_nodes);
- }
-
- /* If the new node is joining and the existing cluster already has some AISONLY
- nodes then we can't make sense of the membership.
- So the new node has to also be AISONLY until we are consistent again */
- if (enable_disallowed &&
- msg->first_trans && !node->us && have_disallowed())
- node->state = NODESTATE_AISONLY;
-
- node->flags = msg->flags; /* This will clear the BEENDOWN flag of course */
-
- /* Take into account any new expected_votes value that the new node has */
- node->expected_votes = msg->expected_votes;
- us->expected_votes = max(us->expected_votes, msg->expected_votes);
-
- if (old_state != node->state || old_expected != node->expected_votes)
- recalculate_quorum(0, 0);
-
- if (node->fence_agent && msg->fence_agent[0] && strcmp(node->fence_agent, msg->fence_agent))
- {
- free(node->fence_agent);
- node->fence_agent = strdup(msg->fence_agent);
- node->fence_time = msg->fence_time;
- }
-
- /*
- * If this is a rejoined node then it won't know about its own fence data, send it
- * some
- */
- if (node->fence_time && !msg->fence_time &&
- node->fence_agent && !msg->fence_agent[0])
- {
- char fencemsg[sizeof(struct cl_fencemsg)+strlen(node->fence_agent)+1];
- struct cl_fencemsg *fence_msg = (struct cl_fencemsg *)fencemsg;
-
- fence_msg->cmd = CLUSTER_MSG_FENCESTATUS;
- fence_msg->nodeid = nodeid;
- fence_msg->timesec = node->fence_time;
- fence_msg->fenced = 0;
- strncpy(fence_msg->agent, node->fence_agent, MAX_FENCE_AGENT_NAME_LEN - 1);
- comms_send_message(fencemsg, sizeof(fencemsg), 0,0, nodeid, 0);
- }
-}
-
-static void process_internal_message(char *data, int nodeid, int need_byteswap)
-{
- struct cl_protmsg *msg = (struct cl_protmsg *)data;
- struct cl_portmsg *portmsg;
- struct cl_barriermsg *barriermsg;
- struct cl_killmsg *killmsg;
- struct cl_leavemsg *leavemsg;
- struct cluster_node *node = find_node_by_nodeid(nodeid);
- unsigned char portresult[PORT_BITS_SIZE+1];
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Message on port 0 is %d\n", msg->cmd);
-
- /* Byteswap messages if needed */
- if (need_byteswap)
- byteswap_internal_message(data);
-
- switch (msg->cmd) {
- case CLUSTER_MSG_PORTOPENED:
- portmsg = (struct cl_portmsg *)data;
- if (node)
- set_port_bit(node, portmsg->port);
- post_port_event(EVENT_REASON_PORTOPENED, portmsg->port, nodeid);
- break;
-
- case CLUSTER_MSG_PORTCLOSED:
- portmsg = (struct cl_portmsg *)data;
- if (node)
- clear_port_bit(node, portmsg->port);
- post_port_event(EVENT_REASON_PORTCLOSED, portmsg->port, nodeid);
- break;
-
- case CLUSTER_MSG_PORTENQ:
- portresult[0] = CLUSTER_MSG_PORTSTATUS;
- memcpy(portresult+1, us->port_bits, PORT_BITS_SIZE);
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Sending PORTRESULT, low bytes = %x %x\n", us->port_bits[0], us->port_bits[1]);
-
- /* Broadcast reply as other new nodes may be interested */
- comms_send_message(portresult, PORT_BITS_SIZE+1, 0,0, 0, 0);
- break;
-
- case CLUSTER_MSG_PORTSTATUS:
- if (nodeid != us->node_id) {
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: got PORTRESULT from %d, low bytes = %x %x\n", nodeid, data[1], data[2]);
- if (node)
- memcpy(node->port_bits, data+1, PORT_BITS_SIZE);
- }
- break;
-
- case CLUSTER_MSG_TRANSITION:
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: got TRANSITION from node %d\n", nodeid);
- do_process_transition(nodeid, data);
- break;
-
- case CLUSTER_MSG_KILLNODE:
- killmsg = (struct cl_killmsg *)data;
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: got KILL for node %d\n", killmsg->nodeid);
- if (killmsg->nodeid == wanted_nodeid) {
- /* Must use syslog directly here or the message will never arrive */
- syslog(LOG_CRIT, "cman killed by node %d because %s\n", nodeid,
- killmsg_reason(killmsg->reason));
- cman_finish();
- exit(1);
- }
- break;
-
- case CLUSTER_MSG_LEAVE:
- leavemsg = (struct cl_leavemsg *)data;
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: got LEAVE from node %d, reason = %d\n", nodeid, leavemsg->reason);
-
- /* We got our own leave message back. now quit */
- if (node && node->node_id == us->node_id) {
- /* Tell whomever asked us to leave that we are now going down */
- if (shutdown_con)
- send_status_return(shutdown_con, CMAN_CMD_TRY_SHUTDOWN, 0);
- cman_finish();
- corosync_shutdown();
- }
-
- /* Someone else, make a note of the reason for leaving */
- if (node)
- node->leave_reason = leavemsg->reason;
-
- /* Mark it as leaving, and remove it when we get an AIS node down event for it */
- if (node && (node->state == NODESTATE_MEMBER || node->state == NODESTATE_AISONLY))
- node->state = NODESTATE_LEAVING;
- break;
-
- case CLUSTER_MSG_BARRIER:
- barriermsg = (struct cl_barriermsg *)data;
- if (node)
- process_barrier_msg(barriermsg, node);
- break;
-
- case CLUSTER_MSG_RECONFIGURE:
- do_reconfigure_msg(data);
- break;
-
- case CLUSTER_MSG_FENCESTATUS:
- do_fence_msg(data);
- break;
-
- default:
- log_printf(LOG_WARNING, "Unknown protocol message %d received\n", msg->cmd);
- break;
-
- }
-}
-
-void override_expected(int newexp)
-{
- struct list *nodelist;
- struct cluster_node *node;
-
- list_iterate(nodelist, &cluster_members_list) {
- node = list_item(nodelist, struct cluster_node);
- if (node->state == NODESTATE_MEMBER
- && node->expected_votes > newexp) {
- node->expected_votes = newexp;
- }
- }
-}
-
-void clear_reread_flags()
-{
- struct list *nodelist;
- struct cluster_node *node;
-
- list_iterate(nodelist, &cluster_members_list) {
- node = list_item(nodelist, struct cluster_node);
- node->flags &= ~NODE_FLAGS_REREAD;
- }
-}
-
-void remove_unread_nodes()
-{
- struct list *nodelist, *tmp;
- struct cluster_node *node;
-
- list_iterate_safe(nodelist, tmp, &cluster_members_list) {
- node = list_item(nodelist, struct cluster_node);
- if (!(node->flags & NODE_FLAGS_REREAD) &&
- node->state == NODESTATE_DEAD) {
-
- list_del(&node->list);
- free(node);
- }
- }
-}
-
-/* Add a node from CCS, note that it may already exist if user has simply updated the config file */
-void add_ccs_node(char *node, int nodeid, int votes, int expected_votes)
-{
- /* Update node entry */
- add_new_node(node, nodeid, votes, expected_votes, NODESTATE_DEAD);
-}
-
-void add_ais_node(int nodeid, uint64_t incar, int total_members)
-{
- struct cluster_node *node;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: add_ais_node ID=%d, incarnation = %" PRIu64 "\n",nodeid, incar);
-
- node = find_node_by_nodeid(nodeid);
- if (!node && total_members == 1) {
- node = us;
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: Adding AIS node for 'us'\n");
- }
-
- /* This really should exist!! */
- if (!node) {
- char tempname[256];
- log_printf(LOG_ERR, "Got node from AIS id %d with no config entry\n", nodeid);
-
- /* Emergency nodename */
- snprintf(tempname, sizeof(tempname) - 1, "Node%d", nodeid);
- node = add_new_node(tempname, nodeid, 1, total_members, NODESTATE_DEAD);
- if (!node) {
- log_printf(LOG_ERR, "Unable to add newnode!\n");
- return;
- }
- }
-
- if (node->state == NODESTATE_DEAD || node->state == NODESTATE_LEAVING) {
- gettimeofday(&node->join_time, NULL);
- node->incarnation = incar;
- node->leave_reason = 0;
- /* If a node rejoins before it completes a leave,
- * we should not increment cluster_members */
- if (node->state != NODESTATE_LEAVING)
- cluster_members++;
- node->state = NODESTATE_MEMBER;
- recalculate_quorum(0, 0);
- }
-}
-
-void del_ais_node(int nodeid)
-{
- struct cluster_node *node;
- time_t t;
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: del_ais_node %d\n", nodeid);
-
- node = find_node_by_nodeid(nodeid);
- if (!node)
- return;
-
- /* If the node was fenced while up (ie independantly of fenced) then
- * don't clear the fenced flag. There is a timeout associated with
- * this so if we get the node down more than 2 minutes after the
- * fence message then we still clear fenced just to be certain that
- * fenced will do the job too.
- */
- time(&t);
- if (!(node->flags & NODE_FLAGS_FENCEDWHILEUP) || (t - node->fence_time > 120))
- node->flags &= ~NODE_FLAGS_FENCED;
-
- node->flags &= ~NODE_FLAGS_FENCEDWHILEUP;
- node->flags |= NODE_FLAGS_BEENDOWN;
-
- switch (node->state) {
- case NODESTATE_MEMBER:
- node->state = NODESTATE_DEAD;
- memset(&node->port_bits, 0, sizeof(node->port_bits));
- cluster_members--;
- recalculate_quorum(0, 0);
- break;
-
- case NODESTATE_AISONLY:
- node->state = NODESTATE_DEAD;
- break;
-
- case NODESTATE_LEAVING:
- node->state = NODESTATE_DEAD;
- memset(&node->port_bits, 0, sizeof(node->port_bits));
- cluster_members--;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "memb: del_ais_node %s, leave_reason=%x\n", node->name, node->leave_reason);
- if (node->leave_reason == CLUSTER_LEAVEFLAG_REMOVED)
- recalculate_quorum(1, 1);
- else
- recalculate_quorum(0, 0);
- break;
-
- case NODESTATE_JOINING:
- case NODESTATE_DEAD:
- break;
- }
-}
-
-static int get_node_count()
-{
- int count = 0;
-
- struct cluster_node *node;
-
- list_iterate_items(node, &cluster_members_list) {
- count++;
- }
- return count;
-}
-
-static struct cluster_node *find_node_by_nodeid(int nodeid)
-{
- struct cluster_node *node;
-
- list_iterate_items(node, &cluster_members_list) {
- if (node->node_id == nodeid)
- return node;
- }
- return NULL;
-}
-
-
-static struct cluster_node *find_node_by_name(char *name)
-{
- struct cluster_node *node;
-
- list_iterate_items(node, &cluster_members_list) {
- if (node->name && strcmp(node->name, name) == 0)
- return node;
- }
- return NULL;
-}
-
-static const char *killmsg_reason(int reason)
-{
- static char msg[1024];
-
- switch (reason)
- {
- case CLUSTER_KILL_REJECTED:
- return "our membership application was rejected";
-
- case CLUSTER_KILL_CMANTOOL:
- return "we were killed by cman_tool or other application";
-
- case CLUSTER_KILL_REJOIN:
- return "we rejoined the cluster without a full restart";
-
- default:
- snprintf(msg, sizeof(msg) - 1, "we got kill message number %d", reason);
- return msg;
- }
-}
diff --git a/cman/daemon/commands.h b/cman/daemon/commands.h
deleted file mode 100644
index af0b17a..0000000
--- a/cman/daemon/commands.h
+++ /dev/null
@@ -1,37 +0,0 @@
-struct cluster_node;
-struct connection;
-extern void process_cnxman_message(char *data, char *addr, int addrlen,
- struct cluster_node *rem_node);
-
-extern int send_to_userport(unsigned char fromport, unsigned char toport,
- int nodeid, int tgtnodeid,
- const char *recv_buf, int len,
- int endian_conv);
-extern void clean_dead_listeners(void);
-extern void unbind_con(struct connection *con);
-extern void commands_init(void);
-extern int process_command(struct connection *con, int cmd, char *cmdbuf,
- char **retbuf, int *retlen, int retsize, int offset);
-extern void send_transition_msg(int last_memb_count, int first_trans);
-
-extern void add_ais_node(int nodeid, uint64_t incarnation, int total_members);
-extern void del_ais_node(int nodeid);
-extern void add_ccs_node(char *name, int nodeid, int votes, int expected_votes);
-extern void override_expected(int expected);
-extern void cman_send_confchg(const unsigned int *member_list, size_t member_list_entries,
- const unsigned int *left_list, size_t left_list_entries,
- const unsigned int *joined_list, size_t joined_list_entries);
-
-
-extern void clear_reread_flags(void);
-extern void remove_unread_nodes(void);
-
-/* Startup stuff called from cmanccs: */
-extern int cman_set_nodename(char *name);
-extern int cman_set_nodeid(int nodeid);
-extern int cman_join_cluster(struct corosync_api_v1 *api,
- char *name, unsigned short cluster_id, int two_node,
- int votes, int expected_votes);
-
-extern int cluster_members;
-extern uint32_t max_outstanding_messages;
diff --git a/cman/daemon/daemon.c b/cman/daemon/daemon.c
deleted file mode 100644
index b85557d..0000000
--- a/cman/daemon/daemon.c
+++ /dev/null
@@ -1,528 +0,0 @@
-#include <getopt.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/poll.h>
-#include <sys/socket.h>
-#include <sys/signal.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/errno.h>
-
-#include <corosync/corotypes.h>
-#include <corosync/coroipc_types.h>
-#include <corosync/coroipcc.h>
-#include <corosync/corodefs.h>
-#include <corosync/mar_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-#include <corosync/totem/coropoll.h>
-
-#include "list.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "daemon.h"
-#include "commands.h"
-#include "barrier.h"
-#include "ais.h"
-#include "cman.h"
-
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME);
-
-struct queued_reply
-{
- struct list list;
- int offset;
- char buf[1];
-};
-
-/* We need to keep these in a list so we can notify of
- cluster events */
-static LIST_INIT(client_list);
-
-/* Things to wake up for */
-volatile sig_atomic_t quit_threads=0;
-
-int num_connections = 0;
-hdb_handle_t cs_poll_handle;
-uint32_t max_outstanding_messages = DEFAULT_MAX_QUEUED;
-
-static int process_client(hdb_handle_t handle, int fd, int revent, void *data);
-static void remove_client(hdb_handle_t handle, struct connection *con);
-
-/* Send it, or queue it for later if the socket is busy */
-static int send_reply_message(struct connection *con, struct sock_header *msg)
-{
- int ret;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: sending reply %x to fd %d\n", msg->command, con->fd);
-
- /* If there are already queued messages then don't send this one
- out of order */
- if (!list_empty(&con->write_msgs)) {
- ret = -1;
- errno = EAGAIN;
- }
- else {
- ret = send(con->fd, (char *)msg, msg->length, MSG_DONTWAIT);
- }
-
- if ((ret > 0 && ret != msg->length) ||
- (ret == -1 && errno == EAGAIN)) {
- struct queued_reply *qm;
-
- /* Have we exceeded the allowed number of queued messages ? */
- if (con->num_write_msgs > max_outstanding_messages) {
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: Disconnecting. client has more that %d replies outstanding (%d)\n", max_outstanding_messages, con->num_write_msgs);
- remove_client(cs_poll_handle, con);
- return -1;
- }
-
- /* Queue it */
- qm = malloc(sizeof(struct queued_reply) + msg->length);
- if (!qm)
- {
- perror("Error allocating queued message");
- return -1;
- }
- memcpy(qm->buf, msg, msg->length);
- if (ret > 0)
- qm->offset = ret;
- else
- qm->offset = 0;
- list_add(&con->write_msgs, &qm->list);
- con->num_write_msgs++;
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: queued last message, count is %d\n", con->num_write_msgs);
- poll_dispatch_modify(cs_poll_handle, con->fd, POLLIN | POLLOUT, process_client);
- }
- return 0;
-}
-
-static void remove_client(hdb_handle_t handle, struct connection *con)
-{
- struct list *tmp, *qmh;
- struct queued_reply *qm;
- int msgs=0;
-
- poll_dispatch_delete(handle, con->fd);
- close(con->fd);
- if (con->type == CON_CLIENT)
- list_del(&con->list);
-
- unbind_con(con);
- remove_barriers(con);
-
- list_iterate_safe(qmh, tmp, &con->write_msgs) {
- qm = list_item(qmh, struct queued_reply);
-
- list_del(&qm->list);
- free(qm);
- msgs++;
- }
-
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: Freed %d queued messages\n", msgs);
- free(con);
- num_connections--;
-}
-
-/* Send as many as we can */
-static void send_queued_reply(struct connection *con)
-{
- struct queued_reply *qm;
- struct sock_header *msg;
- struct list *tmp, *qmh;
- int ret;
-
- list_iterate_safe(qmh, tmp, &con->write_msgs) {
- qm = list_item(qmh, struct queued_reply);
- msg = (struct sock_header *)qm->buf;
- ret = send(con->fd, qm->buf + qm->offset, msg->length - qm->offset, MSG_DONTWAIT);
- if (ret == msg->length - qm->offset)
- {
- list_del(&qm->list);
- free(qm);
- con->num_write_msgs--;
- }
- else
- {
- if (ret > 0)
- qm->offset += ret;
- break;
- }
- }
- if (list_empty(&con->write_msgs)) {
- /* Remove POLLOUT callback */
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: Removing POLLOUT from fd %d\n", con->fd);
- poll_dispatch_modify(cs_poll_handle, con->fd, POLLIN, process_client);
- }
-}
-
-/* Dispatch a request from a CLIENT or ADMIN socket */
-static int process_client(hdb_handle_t handle, int fd, int revent, void *data)
-{
- struct connection *con = data;
-
- if (revent == POLLOUT) {
- send_queued_reply(con);
- } else {
- char buf[MAX_CLUSTER_MESSAGE + sizeof(struct sock_header)];
- struct sock_header *msg = (struct sock_header *)buf;
- int len;
- int totallen = 0;
-
- memset(buf, 0, (MAX_CLUSTER_MESSAGE + sizeof(struct sock_header)));
-
- len = read(fd, buf, sizeof(struct sock_header));
-
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: read %d bytes from fd %d\n", len, fd);
-
- if (len == 0) {
- remove_client(handle, con);
- return -1;
- }
-
- if (len < 0 &&
- (errno == EINTR || errno == EAGAIN))
- return 0;
-
- if (len < 0) {
- remove_client(handle, con);
- return 0;
- }
-
- if (msg->magic != CMAN_MAGIC) {
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: bad magic in client command %x\n", msg->magic);
- send_status_return(con, msg->command, -EINVAL);
- return 0;
- }
- if (msg->version != CMAN_VERSION) {
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: bad version in client command. msg = 0x%x, us = 0x%x\n", msg->version, CMAN_VERSION);
- send_status_return(con, msg->command, -EINVAL);
- return 0;
- }
- if ((msg->length-len) > MAX_CLUSTER_MESSAGE) {
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: message on socket is too big\n");
- send_status_return(con, msg->command, -EINVAL);
- return 0;
- }
-
- totallen = len;
-
- /* Read the rest */
- while (totallen != msg->length) {
- len = read(fd, buf+len, msg->length-len);
- if (len == 0)
- return -1;
-
- if (len < 0 &&
- (errno == EINTR || errno == EAGAIN))
- return 0;
-
- if (len < 0) {
- remove_client(handle, con);
- return -1;
- }
- totallen += len;
- }
-
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: client command is %x\n", msg->command);
-
- /* Privileged functions can only be done on ADMIN sockets */
- if (msg->command & CMAN_CMDFLAG_PRIV && con->type != CON_ADMIN) {
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: command disallowed from non-admin client\n");
- send_status_return(con, msg->command, -EPERM);
- return 0;
- }
-
- /* Slightly arbitrary this one, don't allow ADMIN sockets to
- send/receive data. The main loop doesn't keep a backlog queue
- of messages for ADMIN sockets
- */
- if ((msg->command == CMAN_CMD_DATA || msg->command == CMAN_CMD_BIND ||
- msg->command == CMAN_CMD_NOTIFY) && con->type == CON_ADMIN) {
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: can't send data down an admin socket, sorry\n");
- send_status_return(con, msg->command, -EINVAL);
- return 0;
- }
-
- if (msg->command == CMAN_CMD_DATA) {
- char *databuf = (char *)msg;
- int ret;
- uint8_t port;
- struct sock_data_header *dmsg = (struct sock_data_header *)msg;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: sending %lu bytes of data to node %d, port %d\n",
- (unsigned long)(msg->length - sizeof(struct sock_data_header)), dmsg->nodeid, dmsg->port);
-
- databuf += sizeof(struct sock_data_header);
-
- if (dmsg->port > 255) {
- send_status_return(con, msg->command, -EINVAL);
- return 0;
- }
-
- if (dmsg->port)
- port = dmsg->port;
- else
- port = con->port;
-
- ret = comms_send_message(databuf, msg->length - sizeof(struct sock_data_header),
- port, con->port,
- dmsg->nodeid,
- msg->flags);
- if (ret) {
- send_status_return(con, msg->command, -EIO);
- }
- }
- else {
- char *cmdbuf = (char *)msg;
- char small_retbuf[1024]; /* Enough for most needs */
- char *retbuf = small_retbuf;
- struct sock_reply_header *reply;
- int ret;
- int retlen = 0;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: About to process command\n");
-
- cmdbuf += sizeof(struct sock_header);
-
- ret = process_command(con, msg->command, cmdbuf,
- &retbuf, &retlen, sizeof(small_retbuf),
- sizeof(struct sock_reply_header));
-
- /* Reply message will come later on */
- if (ret == -EWOULDBLOCK)
- return 0;
-
- reply = (struct sock_reply_header *)retbuf;
-
- reply->header.magic = CMAN_MAGIC;
- reply->header.flags = 0;
- reply->header.command = msg->command | CMAN_CMDFLAG_REPLY;
- reply->header.length = retlen + sizeof(struct sock_reply_header);
- reply->status = ret;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: Returning command data. length = %d\n", retlen);
- send_reply_message(con, (struct sock_header *)reply);
-
- if (retbuf != small_retbuf)
- free(retbuf);
- }
- }
- return 0;
-}
-
-
-/* Both client and admin rendezvous sockets use this */
-static int process_rendezvous(hdb_handle_t handle, int fd, int revent, void *data)
-{
- struct sockaddr_un socka;
- struct connection *con = data;
- socklen_t sl = sizeof(socka);
- int client_fd;
-
- client_fd = accept(fd, (struct sockaddr *) &socka, &sl);
- if (client_fd >= 0) {
- struct connection *newcon = malloc(sizeof(struct connection));
- if (!newcon) {
- close(client_fd);
- return 0; /* returning -1 will remove us */
- }
-
- newcon->fd = client_fd;
- newcon->type = con->type;
- newcon->port = 0;
- newcon->events = 0;
- newcon->num_write_msgs = 0;
- list_init(&newcon->write_msgs);
- fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL, 0) | O_NONBLOCK);
-
- poll_dispatch_add(handle, client_fd, POLLIN, newcon, process_client);
- num_connections++;
- if (newcon->type == CON_CLIENT)
- list_add(&client_list, &newcon->list);
- }
- return 0;
-}
-
-static int open_local_sock(const char *name, int name_len, mode_t mode, hdb_handle_t handle, con_type_t type)
-{
- int local_socket;
- struct sockaddr_un sockaddr;
- struct connection *con;
-
- /* Open local socket */
- if (name[0] != '\0')
- unlink(name);
- local_socket = socket(PF_UNIX, SOCK_STREAM, 0);
- if (local_socket < 0) {
- log_printf(LOG_ERR, "Can't create local socket %s: %s\n", name, strerror(errno));
- write_cman_pipe("Can't create local cman socket");
- return -1;
- }
- /* Set Close-on-exec */
- fcntl(local_socket, F_SETFD, 1);
- fcntl(local_socket, F_SETFL, fcntl(local_socket, F_GETFL, 0) | O_NONBLOCK);
-
- memset(&sockaddr, 0, sizeof(sockaddr));
- memcpy(sockaddr.sun_path, name, name_len);
- sockaddr.sun_family = AF_UNIX;
- if (bind(local_socket, (struct sockaddr *) &sockaddr, sizeof(sockaddr))) {
- log_printf(LOG_ERR, "can't bind local socket to %s: %s\n", name, strerror(errno));
- write_cman_pipe("Can't bind to local cman socket");
- close(local_socket);
- return -1;
- }
- if (listen(local_socket, 1) != 0) {
- log_printf(LOG_ERR, "listen on %s failed: %s\n", name, strerror(errno));
- write_cman_pipe("listen failed on local cman socket");
- close(local_socket);
- return -1;
- }
- if (name[0] != '\0')
- chmod(name, mode);
-
-
- con = malloc(sizeof(struct connection));
- if (!con) {
- log_printf(LOG_ERR, "Can't allocate space for local connection: %s\n", strerror(errno));
- write_cman_pipe("malloc failed for connection info");
- close(local_socket);
- return -1;
- }
- con->type = type;
- con->fd = local_socket;
- con->num_write_msgs = 0;
-
- poll_dispatch_add(handle, con->fd, POLLIN, con, process_rendezvous);
-
- return 0;
-}
-
-
-
-/* Send a simple return - usually just a failure status */
-int send_status_return(struct connection *con, uint32_t cmd, int status)
-{
- struct sock_reply_header msg;
-
- log_printf(LOGSYS_LEVEL_DEBUG, "daemon: send status return: %d\n", status);
- msg.header.magic = CMAN_MAGIC;
- msg.header.command = cmd | CMAN_CMDFLAG_REPLY;
- msg.header.length = sizeof(msg);
- msg.header.flags = 0;
- msg.status = status;
-
- return send_reply_message(con, (struct sock_header *)&msg);
-}
-
-int send_data_reply(struct connection *con, int nodeid, int port, const char *data, int len)
-{
- char buf[len + sizeof(struct sock_data_header)];
- struct sock_data_header *msg = (struct sock_data_header *)buf;
-
- msg->header.magic = CMAN_MAGIC;
- msg->header.command = CMAN_CMD_DATA | CMAN_CMDFLAG_REPLY;
- msg->header.length = sizeof(*msg)+len;
- msg->header.flags = 0;
- msg->nodeid = nodeid;
- msg->port = port;
-
- memcpy(buf+sizeof(struct sock_data_header), data, len);
- return send_reply_message(con, (struct sock_header *)msg);
-}
-
-/* This can be called by the membership thread as well as the daemon thread. */
-void notify_listeners(struct connection *con, int event, int arg)
-{
- struct sock_event_message msg;
- struct connection *thiscon;
-
- msg.header.magic = CMAN_MAGIC;
- msg.header.command = CMAN_CMD_EVENT;
- msg.header.length = sizeof(msg);
- msg.header.flags = 0;
- msg.reason = event;
- msg.arg = arg;
-
- /* Unicast message */
- if (con) {
- send_reply_message(con, (struct sock_header *)&msg);
- return;
- }
-
- /* Broadcast message */
- list_iterate_items(thiscon, &client_list) {
- if (thiscon->events)
- send_reply_message(thiscon, (struct sock_header *)&msg);
- }
-}
-
-void notify_confchg(struct sock_header *message)
-{
- struct connection *thiscon;
-
- list_iterate_items(thiscon, &client_list) {
- if (thiscon->confchg)
- send_reply_message(thiscon, message);
- }
-}
-
-int num_listeners(void)
-{
- int count = 0;
- struct connection *thiscon;
-
- list_iterate_items(thiscon, &client_list) {
- thiscon->shutdown_reply = SHUTDOWN_REPLY_UNK; /* Clear out for new shutdown request */
- if (thiscon->events)
- count++;
- }
- return count;
-}
-
-int cman_init(struct corosync_api_v1 *api)
-{
- int fd;
- struct sigaction sa;
-
- cs_poll_handle = api->poll_handle_get();
- barrier_init();
-
- log_printf(LOG_INFO, "CMAN %s (built %s %s) started\n",
- RELEASE_VERSION, __DATE__, __TIME__);
-
- fd = open_local_sock(CLIENT_SOCKNAME, sizeof(CLIENT_SOCKNAME), 0660, cs_poll_handle, CON_CLIENT);
- if (fd < 0)
- return -2;
-
- fd = open_local_sock(ADMIN_SOCKNAME, sizeof(ADMIN_SOCKNAME), 0600, cs_poll_handle, CON_ADMIN);
- if (fd < 0)
- return -2;
-
- /* Shutdown trap */
- sa.sa_handler = SIG_IGN;
- sigaction(SIGPIPE, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
-
- return 0;
-}
-
-int cman_finish()
-{
- /* Stop */
- unlink(CLIENT_SOCKNAME);
- unlink(ADMIN_SOCKNAME);
-
- return 0;
-}
-
diff --git a/cman/daemon/daemon.h b/cman/daemon/daemon.h
deleted file mode 100644
index 49611b1..0000000
--- a/cman/daemon/daemon.h
+++ /dev/null
@@ -1,12 +0,0 @@
-extern int send_status_return(struct connection *con, uint32_t cmd, int status);
-extern int send_data_reply(struct connection *con, int nodeid, int port, const char *data, int len);
-extern void set_cman_timeout(int secs);
-extern void notify_listeners(struct connection *con, int reason, int arg);
-extern int num_listeners(void);
-extern void cman_set_realtime(void);
-extern int cman_init(struct corosync_api_v1 *api);
-extern int cman_finish(void);
-extern void notify_confchg(struct sock_header *message);
-
-extern volatile sig_atomic_t quit_threads;
-extern int num_connections;
diff --git a/cman/daemon/fnvhash.c b/cman/daemon/fnvhash.c
deleted file mode 100644
index 47e221a..0000000
--- a/cman/daemon/fnvhash.c
+++ /dev/null
@@ -1,93 +0,0 @@
-#include <stdint.h>
-#include "fnvhash.h"
-
-/***
- *
- * Fowler/Noll/Vo hash
- *
- * The basis of this hash algorithm was taken from an idea sent
- * as reviewer comments to the IEEE POSIX P1003.2 committee by:
- *
- * Phong Vo (http://www.research.att.com/info/kpv/)
- * Glenn Fowler (http://www.research.att.com/~gsf/)
- *
- * In a subsequent ballot round:
- *
- * Landon Curt Noll (http://www.isthe.com/chongo/)
- *
- * improved on their algorithm. Some people tried this hash
- * and found that it worked rather well. In an EMail message
- * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
- *
- * FNV hashes are designed to be fast while maintaining a low
- * collision rate. The FNV speed allows one to quickly hash lots
- * of data while maintaining a reasonable collision rate. See:
- *
- * http://www.isthe.com/chongo/tech/comp/fnv/index.html
- *
- * for more details as well as other forms of the FNV hash.
- ***
- *
- * To use the recommended 32 bit FNV-1a hash, pass FNV1_32A_INIT as the
- * Fnv32_t hashval argument to fnv_32a_buf() or fnv_32a_str().
- *
- ***
- *
- * Please do not copyright this code. This code is in the public domain.
- *
- * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
- * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * By:
- * chongo <Landon Curt Noll> /\oo/\
- * http://www.isthe.com/chongo/
- *
- * Share and Enjoy! :-)
- */
-
-/*
- * Modified to be a little more simple to understand and to provide a 16 bit
- * value rather then 32 bit for cluster id generation
- *
- * sdake(a)redhat.com
- */
-
-/* 32 bit magic FNV-1a prime */
-#define FNV_32_PRIME ((uint32_t)0x01000193)
-
-/* Default initialization for FNV-1a */
-#define FNV_32_INIT ((uint32_t)0x811c9dc5)
-
-uint16_t fnv_hash(char *str)
-{
- unsigned char *s = (unsigned char *)str;
- uint32_t hval = FNV_32_INIT;
- uint32_t ret;
-
- /*
- * FNV-1a hash each octet in the buffer
- */
- while (*s) {
- /*
- * xor the bottom with the current octet
- */
- hval ^= (uint32_t)*s++;
- /*
- * multiply by the 32 bit FNV magic prime mod 2^32
- */
- hval *= FNV_32_PRIME;
- }
-
- /*
- * Use XOR folding as recommended by authors of algorithm
- * to create a different hash size that is a power of two
- */
- ret = (hval >> 16) ^ (hval & 0xFFFF);
-
- return (ret);
-}
diff --git a/cman/daemon/fnvhash.h b/cman/daemon/fnvhash.h
deleted file mode 100644
index 65e9c11..0000000
--- a/cman/daemon/fnvhash.h
+++ /dev/null
@@ -1 +0,0 @@
-uint16_t fnv_hash(char *str);
diff --git a/cman/daemon/list.h b/cman/daemon/list.h
deleted file mode 100644
index aaee167..0000000
--- a/cman/daemon/list.h
+++ /dev/null
@@ -1,97 +0,0 @@
-#ifndef _LVM_LIST_H
-#define _LVM_LIST_H
-
-#include <assert.h>
-
-struct list {
- struct list *n, *p;
-};
-
-#define LIST_INIT(name) struct list name = { &(name), &(name) }
-
-static inline void list_init(struct list *head)
-{
- head->n = head->p = head;
-}
-
-static inline void list_add(struct list *head, struct list *elem)
-{
- assert(head->n);
-
- elem->n = head;
- elem->p = head->p;
-
- head->p->n = elem;
- head->p = elem;
-}
-
-static inline void list_add_h(struct list *head, struct list *elem)
-{
- assert(head->n);
-
- elem->n = head->n;
- elem->p = head;
-
- head->n->p = elem;
- head->n = elem;
-}
-
-static inline void list_del(struct list *elem)
-{
- elem->n->p = elem->p;
- elem->p->n = elem->n;
-}
-
-static inline int list_empty(struct list *head)
-{
- return head->n == head;
-}
-
-static inline int list_end(struct list *head, struct list *elem)
-{
- return elem->n == head;
-}
-
-static inline struct list *list_next(struct list *head, struct list *elem)
-{
- return (list_end(head, elem) ? NULL : elem->n);
-}
-
-#define list_item(v, t) \
- ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
-
-#define list_struct_base(v, t, h) \
- ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->h))
-
-/* Given a known element in a known structure, locate another */
-#define struct_field(v, t, e, f) \
- (((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
-
-/* Given a known element in a known structure, locate the list head */
-#define list_head(v, t, e) struct_field(v, t, e, list)
-
-#define list_iterate(v, head) \
- for (v = (head)->n; v != head; v = v->n)
-
-#define list_uniterate(v, head, start) \
- for (v = (start)->p; v != head; v = v->p)
-
-#define list_iterate_safe(v, t, head) \
- for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
-
-#define list_iterate_items(v, head) \
- for (v = list_item((head)->n, typeof(*v)); &v->list != (head); \
- v = list_item(v->list.n, typeof(*v)))
-
-static inline unsigned int list_size(const struct list *head)
-{
- unsigned int s = 0;
- const struct list *v;
-
- list_iterate(v, head)
- s++;
-
- return s;
-}
-
-#endif
diff --git a/cman/daemon/nodelist.h b/cman/daemon/nodelist.h
deleted file mode 100644
index 4851387..0000000
--- a/cman/daemon/nodelist.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* These just make the access a little neater */
-static inline int objdb_get_string(OBJDB_API *corosync, hdb_handle_t object_service_handle,
- const char *key, char **value)
-{
- *value = NULL;
- if ( !(corosync->object_key_get(object_service_handle,
- key,
- strlen(key),
- (void *)value,
- NULL))) {
- if (*value)
- return 0;
- }
- return -1;
-}
-
-static inline void objdb_get_int(OBJDB_API *corosync, hdb_handle_t object_service_handle,
- const char *key, unsigned int *intvalue, unsigned int default_value)
-{
- char *value = NULL;
-
- *intvalue = default_value;
-
- if (!corosync->object_key_get(object_service_handle, key, strlen(key),
- (void *)&value, NULL)) {
- if (value) {
- *intvalue = atoi(value);
- }
- }
-}
-
-
-/* Helper functions for navigating the nodes list */
-static inline hdb_handle_t nodeslist_init(OBJDB_API *corosync,
- hdb_handle_t cluster_parent_handle,
- hdb_handle_t *find_handle)
-{
- hdb_handle_t object_handle;
- hdb_handle_t find_handle1;
- hdb_handle_t find_handle2;
-
- corosync->object_find_create(cluster_parent_handle,"clusternodes", strlen("clusternodes"), &find_handle1);
- if (corosync->object_find_next(find_handle1, &object_handle) == 0)
- {
- hdb_handle_t nodes_handle;
- corosync->object_find_destroy(find_handle1);
-
- corosync->object_find_create(object_handle,"clusternode", strlen("clusternode"), &find_handle2);
-
- if (corosync->object_find_next(find_handle2, &nodes_handle) == 0)
- {
- *find_handle = find_handle2;
- return nodes_handle;
- }
- }
- return 0;
-}
-
-static inline hdb_handle_t nodeslist_next(OBJDB_API *corosync, hdb_handle_t find_handle)
-{
- hdb_handle_t nodes_handle;
-
- if (corosync->object_find_next(find_handle, &nodes_handle) == 0)
- return nodes_handle;
- else
- return 0;
-}
-
-static inline hdb_handle_t nodelist_byname(OBJDB_API *corosync,
- hdb_handle_t cluster_parent_handle,
- char *name)
-{
- char *nodename;
- hdb_handle_t nodes_handle;
- hdb_handle_t find_handle = 0;
-
- nodes_handle = nodeslist_init(corosync, cluster_parent_handle, &find_handle);
- while (nodes_handle) {
- if (objdb_get_string(corosync, nodes_handle, "name", &nodename)) {
- nodes_handle = nodeslist_next(corosync, find_handle);
- continue;
- }
- if (strcmp(nodename, name) == 0)
- return nodes_handle;
-
- nodes_handle = nodeslist_next(corosync, find_handle);
- }
- corosync->object_find_destroy(find_handle);
-
- return 0;
-}
diff --git a/cman/init.d/Makefile b/cman/init.d/Makefile
deleted file mode 100644
index 1ce42d6..0000000
--- a/cman/init.d/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-TARGET=cman cman.init.defaults
-
-INITDT=cman
-
-all: $(TARGET)
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-%: $(S)/%.in
- cat $^ | sed \
- -e 's#@SBINDIR@#${sbindir}#g' \
- -e 's#@INITDDIR@#${initddir}#g' \
- -e 's#@NOTIFYDDIR@#${notifyddir}#g' \
- -e 's#@CONFDIR@#${CONFDIR}#g' \
- -e 's#@CONFFILE@#${CONFFILE}#g' \
- > $@
-
-clean: generalclean
diff --git a/cman/init.d/cman.in b/cman/init.d/cman.in
deleted file mode 100644
index eb3c2d1..0000000
--- a/cman/init.d/cman.in
+++ /dev/null
@@ -1,1038 +0,0 @@
-#!/bin/bash
-#
-# cman - Cluster Manager init script
-#
-# chkconfig: - 21 79
-# description: Starts and stops cman
-#
-#
-### BEGIN INIT INFO
-# Provides: cman
-# Required-Start: $network $time fence_sanlockd
-# Required-Stop: $network $time fence_sanlockd
-# Default-Start:
-# Default-Stop:
-# Short-Description: Starts and stops cman
-# Description: Starts and stops the Cluster Manager set of daemons
-### END INIT INFO
-
-# set secure PATH
-PATH="/bin:/usr/bin:/sbin:/usr/sbin:@SBINDIR@"
-
-chkconfig2()
-{
- case "$1" in
- --levels)
- ls /etc/rc${2}.d/S*${3} > /dev/null 2>/dev/null
- return $?
- ;;
- *)
- ls /etc/rc*.d/S*${1} > /dev/null 2>/dev/null
- return $?
- ;;
- esac
-}
-
-success()
-{
- echo -ne "[ OK ]\r"
-}
-
-failure()
-{
- echo -ne "[FAILED]\r"
-}
-
-status()
-{
- pid=$(pidof $1 2>/dev/null)
- statusrtrn=$?
- if [ $statusrtrn -ne 0 ]; then
- echo "$1 is stopped"
- else
- echo "$1 (pid $pid) is running..."
- fi
- return $statusrtrn
-}
-
-# rpm based distros
-if [ -d /etc/sysconfig ]; then
- [ -f @INITDDIR@/functions ] && . @INITDDIR@/functions
- [ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
- [ -f /etc/sysconfig/cman ] && . /etc/sysconfig/cman
- [ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/subsys/cman"
- netmanager=NetworkManager
-fi
-
-# deb based distros
-if [ ! -d /etc/sysconfig ]; then
- [ -f /etc/default/cluster ] && . /etc/default/cluster
- [ -f /etc/default/cman ] && . /etc/default/cman
- [ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/cman"
- netmanager=network-manager
-fi
-
-# CMAN_CLUSTER_TIMEOUT -- amount of time to wait for joinging a cluster
-# before giving up. If CMAN_CLUSTER_TIMEOUT is positive, then we will
-# wait CMAN_CLUSTER_TIMEOUT seconds before giving up and failing when
-# a cluster is not joined. If CMAN_CLUSTER_TIMEOUT is zero, then
-# wait indefinately for a cluster join. If CMAN_CLUSTER_TIMEOUT is
-# negative, do not check to see that the cluster has been joined
-[ -z "$CMAN_CLUSTER_TIMEOUT" ] && CMAN_CLUSTER_TIMEOUT=60
-
-# CMAN_QUORUM_TIMEOUT -- amount of time to wait for a quorate cluster on
-# startup quorum is needed by many other applications, so we may as
-# well wait here. If CMAN_QUORUM_TIMEOUT is zero, quorum will
-# be ignored.
-[ -z "$CMAN_QUORUM_TIMEOUT" ] && CMAN_QUORUM_TIMEOUT=45
-
-# CMAN_SHUTDOWN_TIMEOUT -- amount of time to wait for cman to become a
-# cluster member before calling cman_tool leave during shutdown.
-# The default is 60 seconds
-[ -z "$CMAN_SHUTDOWN_TIMEOUT" ] && CMAN_SHUTDOWN_TIMEOUT=60
-
-# CMAN_NOTIFYD_START - control the startup behaviour for cmannotifyd
-# the variable can take 3 values:
-# yes | will always start cmannotifyd
-# no | will never start cmannotifyd
-# conditional (default) | will start cmannotifyd only if scriptlets
-# are found in @NOTIFYDDIR@
-[ -z "$CMAN_NOTIFYD_START" ] && CMAN_NOTIFYD_START=conditional
-
-# CMAN_SSHD_START - control sshd startup behaviour
-# the variable can take 2 values:
-# yes | cman will start sshd as early as possible
-# no (default) | cman will not start sshd
-[ -z "$CMAN_SSHD_START" ] && CMAN_SSHD_START=no
-
-# CMAN_DAEMONS_START -- Set to "no" to disable {dlm,gfs,ocfs2}-controld daemons
-# execution from within cman init script
-# (Can be useful for some pacemaker-based setups).
-# values:
-# no | cman init will NOT start the daemons
-# empty or any other value (default) | cman init will start the daemons
-#CMAN_DAEMONS_START=
-
-# DLM_CONTROLD_OPTS -- allow extra options to be passed to dlm_controld daemon.
-[ -z "$DLM_CONTROLD_OPTS" ] && DLM_CONTROLD_OPTS=""
-
-# Allow tuning of DLM kernel config.
-# do NOT change unless instructed to do so.
-[ -z "$DLM_LKBTBL_SIZE" ] && DLM_LKBTBL_SIZE=""
-[ -z "$DLM_RSBTBL_SIZE" ] && DLM_RSBTBL_SIZE=""
-[ -z "$DLM_DIRTBL_SIZE" ] && DLM_DIRTBL_SIZE=""
-[ -z "$DLM_TCP_PORT" ] && DLM_TCP_PORT=""
-
-# FENCE_JOIN_TIMEOUT -- seconds to wait for fence domain join to
-# complete. If the join hasn't completed in this time, fence_tool join
-# exits with an error, and this script exits with an error. To wait
-# indefinitely set the value to -1.
-[ -z "$FENCE_JOIN_TIMEOUT" ] && FENCE_JOIN_TIMEOUT=20
-
-# FENCED_MEMBER_DELAY -- amount of time to delay fence_tool join to allow
-# all nodes in cluster.conf to become cluster members. In seconds.
-[ -z "$FENCED_MEMBER_DELAY" ] && FENCED_MEMBER_DELAY=45
-
-# FENCE_JOIN -- boolean value used to control whether or not this node
-# should join the fence domain. If FENCE_JOIN is set to "no", then
-# the script will not attempt to the fence domain. If FENCE_JOIN is
-# set to "yes", then the script will attempt to join the fence domain.
-# If FENCE_JOIN is set to any other value, the default behavior is
-# to join the fence domain (equivalent to "yes").
-# When setting FENCE_JOIN to "no", it is important to also set
-# DLM_CONTROLD_OPTS="-f0" (at least) for correct operation.
-# Please note that clusters without fencing are not
-# supported by Red Hat except for MRG installations.
-[ -z "$FENCE_JOIN" ] && FENCE_JOIN="yes"
-
-# FENCED_OPTS -- allow extra options to be passed to fence daemon.
-[ -z "$FENCED_OPTS" ] && FENCED_OPTS=""
-
-# NETWORK_BRIDGE_SCRIPT -- script to use for xen network bridging.
-# This script must exist in the /etc/xen/scripts directory.
-# The default script is "network-bridge".
-[ -z "$NETWORK_BRIDGE_SCRIPT" ] && NETWORK_BRIDGE_SCRIPT="network-bridge"
-
-# CMAN_JOIN_OPTS -- allows extra options to be passed to cman_tool when join
-# operation is performed.
-# NOTES:
-# $CLUSTERNAME automatically appends "-c $CLUSTERNAME"
-# $NODENAME automatically appends "-n $NODENAME"
-# $CONFIG_LOADER automatically appends "-C $CONFIG_LOADER"
-
-[ -n "$CMAN_JOIN_OPTS" ] && cman_join_opts="$CMAN_JOIN_OPTS"
-
-[ -n "$CLUSTERNAME" ] && cman_join_opts+="-c $CLUSTERNAME"
-
-[ -n "$NODENAME" ] && cman_join_opts+=" -n $NODENAME"
-
-# CONFIG_LOADER -- select default config parser.
-# This can be:
-# xmlconfig - read directly from cluster.conf and use ricci as default
-# config propagation method. (default)
-# ldapconfig - read configuration from an ldap server.
-# Requires: COROSYNC_LDAP_URL or/and COROSYNC_LDAP_BASEDN
-# envvar to be set.
-# LDAP_BINDDN and LDAP_BINDPWD have to be either both set
-# or both unset.
-# corosync_parser - use internal corosync config file parser.
-# openaisparser - use internal openais config file parser.
-[ -n "$CONFIG_LOADER" ] && cman_join_opts+=" -C $CONFIG_LOADER"
-
-# CONFIG_VALIDATION -- select default config validation behaviour
-# This can be:
-# FAIL - Use a very strict checking. The config will not be loaded if there
-# for any kind of warnings/errors.
-# WARN - Same as FAIL, but will allow the config to load (this is temporary
-# the default behaviour)
-# NONE - Disable config validation. Highly discouraged.
-[ -z "$CONFIG_VALIDATION" ] && CONFIG_VALIDATION=WARN
-cman_join_opts+=" -D$CONFIG_VALIDATION"
-
-# CMAN_LEAVE_OPTS -- allows extra options to be passed to cman_tool when leave
-# operation is performed.
-[ -n "$CMAN_LEAVE_OPTS" ] && cman_leave_opts="$CMAN_LEAVE_OPTS"
-
-# INITLOGLEVEL -- select how verbose the init script should be
-# possible values:
-# quiet - only one line notification for start/stop operations
-# terse (default) - show only required activity
-# full - show everything
-[ -z "$INITLOGLEVEL" ] && INITLOGLEVEL=terse
-
-# INITBREAKPOINT -- select cman init break point during startup
-# possible values:
-# setup - exit before executing cman
-# join - exit after executing cman
-# notify - exit after starting up notifyd (if enabled) and before quorum
-# quorum - exit after start qdiskd (if enabled) and wait for quorum
-# daemons - exit after starting all other daemons (if enabled)
-# all (default) - start all the stack
-#
-# invoking cman init with /etc/init.d/cman start <selected_breakpoint>
-# overrides configured breakpoint from default settings
-[ -z "$INITBREAKPOINT" ] && INITBREAKPOINT=""
-
-### generic wrapper functions
-
-ok() {
- if [ "$INITLOGLEVEL" != "quiet" ]; then
- success
- echo
- fi
-}
-
-nok() {
- echo -e "$errmsg"
- failure
- echo
- if [ "$currentaction" = "start" ]; then
- stop && rm -f $LOCK_FILE
- fi
- exit 1
-}
-
-none()
-{
- return 0
-}
-
-runwrap()
-{
- function=$1
- shift
- conditional=$1
- shift
- message="$@"
-
- if ! $conditional; then
- if [ "$INITLOGLEVEL" = "full" ]; then
- echo " $message... action not required"
- fi
- return 0
- fi
-
- if [ "$INITLOGLEVEL" != "quiet" ]; then
- echo -n " $message... "
- fi
- if $function; then
- ok
- else
- nok
- fi
-}
-
-check_exec()
-{
- exec=$1
-
- realexec="$(type -p $exec)"
- if [ -z "$realexec" ]; then
- errmsg="Unable to find $exec in PATH"
- return 1
- fi
- if [ ! -x "$realexec" ]; then
- errmsg="$realexec not executable"
- return 1
- fi
- return 0
-}
-
-start_daemon()
-{
- daemon=$1
- shift
- args="$@"
-
- check_exec $daemon || return $?
- status $daemon > /dev/null 2>&1 && return 0
- errmsg=$( $daemon $args 2>&1 )
-}
-
-check_sleep()
-{
- if ! sleep 0.01 > /dev/null 2>&1; then
- return 1
- fi
-}
-
-stop_daemon()
-{
- daemon=$1
- shift
- retryforsec=$1
-
- [ -z "$retryforsec" ] && retryforsec=30
- retries=0
-
- if check_sleep; then
- sleepfor=0.25
- retryforsec=$(($retryforsec * 4))
- else
- sleepfor=1
- fi
-
- while status $daemon > /dev/null 2>&1 && \
- [ $retries -lt $retryforsec ]; do
-
- errmsg=$( pkill -TERM $daemon ) || return 1
- sleep $sleepfor
- ((retries++))
- done
-
- ! status $daemon > /dev/null 2>&1
-}
-
-### check functions (enable/disable) (on/off)
-
-sshd_enabled()
-{
- case "$CMAN_SSHD_START" in
- yes)
- return 0
- ;;
- esac
- return 1
-}
-
-control_daemons_enabled()
-{
- [ "$CMAN_DAEMONS_START" = "no" ] && return 1
- return 0
-}
-
-dlm_controld_enabled()
-{
- control_daemons_enabled
- return $?
-}
-
-gfs_controld_enabled()
-{
- ! control_daemons_enabled && return 1
-
- if [ -f @INITDDIR@/gfs2-cluster ] && ! chkconfig2 gfs2-cluster; then
- return 0
- fi
- return 1
-}
-
-cluster_disabled_at_boot()
-{
- if grep -q nocluster /proc/cmdline && \
- [ "$(tty)" = "/dev/console" ]; then
- errmsg="not configured to run at boot"
- return 1
- fi
- return 0
-}
-
-network_manager_enabled()
-{
- if status $netmanager > /dev/null 2>&1 || \
- chkconfig2 $netmanager; then
- errmsg="\nNetwork Manager is either running or configured to run. Please disable it in the cluster."
- return 1
- fi
- return 0
-}
-
-mtab_configfs()
-{
- awk '{ print $2 }' /etc/mtab | \
- grep '^/sys/kernel/config$' > /dev/null 2>&1 && \
- awk '{ print $3 }' /etc/mtab | \
- grep '^configfs$' > /dev/null 2>&1
-}
-
-cman_running()
-{
- cman_tool status > /dev/null 2>&1
-}
-
-# NOTE: this could probably grow a bit to do config sanity checks
-cman_checkconfig()
-{
- case "$CONFIG_LOADER" in
- ldapconfig)
- if [ -n "$COROSYNC_LDAP_URL" ] || [ -n "$COROSYNC_LDAP_BASEDN" ]; then
- if [ -n "$COROSYNC_LDAP_BINDDN" ]; then
- if [ -z "$LDAP_BINDPWD" ]; then
- errmsg="ldapconfig has been selected \
- but LDAP_BINDPWD is not set"
- return 1
- fi
- fi
- if [ -n "$LDAP_BINDPWD" ]; then
- if [ -z "$COROSYNC_LDAP_BINDDN" ]; then
- errmsg="ldapconfig has been selected \
- but LDAP_BINDDN is not set"
- return 1
- fi
- fi
- else
- errmsg="ldapconfig has been selected but neither \
- COROSYNC_LDAP_URL or COROSYNC_LDAP_BASEDN have been set"
- return 1
- fi
- ;;
- xmlconfig|"")
- configfile=@CONFDIR@/@CONFFILE@
- [ -n "$COROSYNC_CLUSTER_CONFIG_FILE" ] && \
- configfile=$COROSYNC_CLUSTER_CONFIG_FILE
-
- if [ ! -f $configfile ]; then
- errmsg="xmlconfig cannot find $configfile"
- return 1
- fi
- ;;
- esac
-}
-
-xend_bridged_net_enabled() {
- # Not a xen kernel
- [ -d /proc/xen ] || return 1
-
- # uanble to determine current runlevel
- current_runlevel=$( runlevel 2>/dev/null | \
- awk '{ print $2 }' 2>/dev/null )
- [ -z "$current_runlevel" ] && return 1
-
- # xend doesn't start at this runlevel.
- ! chkconfig2 --levels "$current_runlevel" xend 2>/dev/null && return 1
-
- # xend isn't configured to use bridged networking.
- [ ! -f /etc/xen/xend-config.sxp ] && return 1
-
- # xend isn't configured to use bridged networking.
- ! egrep \
- "^[[:blank:]]*\([[:blank:]]*network-script[[:blank:]]+(')?[[:blank:]]*${NETWORK_BRIDGE_SCRIPT}([[:blank:]]*\)|[[:blank:]]+)" \
- /etc/xen/xend-config.sxp >&/dev/null && return 1
-}
-
-qdiskd_enabled()
-{
- ccs_tool query /cluster/quorumd >/dev/null 2>&1
-}
-
-groupd_enabled()
-{
- groupd_compat="$(ccs_tool query /cluster/group/@groupd_compat \
- 2>/dev/null || true)"
-
- [ -z "$groupd_compat" ] && return 1
- [ "$groupd_compat" = 0 ] && return 1
- return 0
-}
-
-ocfs2_enabled()
-{
- ! control_daemons_enabled && return 1
- ocfs2_cluster="$(cat /sys/fs/ocfs2/cluster_stack 2>/dev/null || true)"
- [ "$ocfs2_cluster" != cman ] && return 1
- return 0
-}
-
-cmannotifyd_enabled()
-{
- case "$CMAN_NOTIFYD_START" in
- yes)
- return 0
- ;;
- conditional)
- if [ -n "$(ls -1 @NOTIFYDDIR@ 2>/dev/null)" ]; then
- return 0
- fi
- ;;
- esac
- return 1
-}
-
-fence_join_enabled()
-{
- #
- # Check the value of FENCE_JOIN.
- # If FENCE_JOIN is set to "no", we will not attempt to join
- # the fence domain. If FENCE_JOIN is set to any other value,
- # we will attempt to join the fence domain (default).
- #
- if [ "$FENCE_JOIN" = "no" ]; then
- return 1
- fi
-}
-
-### the real stuff starts here
-
-start_global()
-{
- ## global bits
- # guarantee enough limits
- ulimit -c unlimited
- # required for distributions that use tmpfs for /var/run
- mkdir -p /var/run/cluster
-}
-
-xend_bridged_net_start() {
- if [ ! -x /etc/xen/scripts/${NETWORK_BRIDGE_SCRIPT} ]; then
- if [ -f /etc/xen/scripts/${NETWORK_BRIDGE_SCRIPT} ]; then
- errmsg="The xend bridged network script cannot be run"
- else
- errmsg="The xend bridged network script is missing"
- fi
- return 1
- fi
-
- modprobe netbk >& /dev/null || true
- modprobe netloop >& /dev/null || true
-
- bridge_parms=$( egrep -m 1 \
- "^[[:blank:]]*\([[:blank:]]*network-script[[:blank:]]+(')?[[:blank:]]*${NETWORK_BRIDGE_SCRIPT}([[:blank:]]*\)|[[:blank:]]+)" \
- /etc/xen/xend-config.sxp | \
- sed -r \
- "s/^[[:blank:]]*\([[:blank:]]*network-script[[:blank:]]+'?[[:blank:]]*${NETWORK_BRIDGE_SCRIPT}[[:blank:]]*//; s/'?[[:blank:]]*\).*//" )
-
- errmsg=$( /etc/xen/scripts/${NETWORK_BRIDGE_SCRIPT} \
- start $bridge_parms 2>&1 )
-}
-
-load_kernel_modules()
-{
- errmsg=$( modprobe configfs 2>&1 ) || return 1
- errmsg=$( modprobe dlm 2>&1 ) || return 1
-}
-
-unload_kernel_modules()
-{
- modprobe -r dlm > /dev/null 2>&1 || true
-}
-
-start_configfs()
-{
- mtab_configfs && return 0
- errmsg=$( mount -t configfs none /sys/kernel/config 2>&1 )
-}
-
-stop_configfs()
-{
- if mtab_configfs && \
- [ -z "$(ls -1 /sys/kernel/config)" ] && \
- [ -z "$(lsof -l +D /sys/kernel/config 2>/dev/null)" ]; then
- errmsg=$( umount /sys/kernel/config 2>&1 ) || return 1
- modprobe -r configfs > /dev/null 2>&1 || true
- fi
-}
-
-corosync_running()
-{
- [ -f /var/run/corosync.pid ] || return 1
-
- read corosync_pid foo < /var/run/corosync.pid
- if [ "$(pidof corosync)" == "$corosync_pid" ];then
- errmsg="Corosync Cluster Engine is already running"
- return 0
- fi
-
- return 1
-}
-
-start_cman()
-{
- check_exec cman_tool || return $?
- cman_running && return 0
- cman_checkconfig || return 1
- corosync_running && return 1
-
- tmpfile=$(mktemp -t cmanstartup.XXXXXXXXXX)
- if [ -z "$tmpfile" ]; then
- errmsg="Unable to create temporary file"
- return 1
- fi
-
- cman_tool -z -t $CMAN_CLUSTER_TIMEOUT -w join $cman_join_opts > $tmpfile 2>&1 &
-
- while status cman_tool >/dev/null 2>&1; do
- sleep 0.2
- done
-
- sleep 2
-
- if ! cman_running; then
- errmsg="$(cat $tmpfile) Check cluster logs for details"
- ret=1
- else
- if [ "$CONFIG_VALIDATION" = "WARN" ] && \
- [ -s $tmpfile ] && \
- grep -q Relax-NG $tmpfile ; then
- cat $tmpfile >&2
- fi
- pidof /usr/sbin/corosync > /var/run/cman.pid
- ret=0
- fi
-
- rm -f $tmpfile
- return $ret
-}
-
-wait_for_quorum()
-{
- if [ $CMAN_QUORUM_TIMEOUT -gt 0 ]; then
- errmsg=$( cman_tool -t $CMAN_QUORUM_TIMEOUT \
- -q wait 2>&1 ) || return 1
- fi
-}
-
-stop_cman()
-{
- if cman_running; then
- errmsg=$( cman_tool $cman_leave_opts -t $CMAN_SHUTDOWN_TIMEOUT \
- -w leave $cmanremove 2>&1 ) || return 1
- ok
- echo -n " Waiting for corosync to shutdown:"
- while status corosync > /dev/null 2>&1; do
- sleep 1
- echo -n "."
- done
- rm -f /var/run/cman.pid
- fi
- return 0
-}
-
-start_qdiskd()
-{
- start_daemon qdiskd "-Q" || return 1
-
- if [ "$INITLOGLEVEL" = "full" ]; then
- ok
- echo -n " Waiting for qdiskd to be active: "
- fi
- retries=0
- while ! cman_tool status |grep -q "Quorum device" && \
- status qdiskd > /dev/null 2>&1 && \
- [ $retries -lt 10 ]; do
- sleep 2
- if [ "$INITLOGLEVEL" = "full" ]; then
- echo -n "$retries "
- fi
- ((retries++))
- done
- status qdiskd > /dev/null 2>&1
-}
-
-stop_qdiskd()
-{
- stop_daemon qdiskd
-}
-
-start_groupd()
-{
- start_daemon groupd || return 1
-
- if [ "$INITLOGLEVEL" = "full" ]; then
- ok
- echo -n " Waiting groupd protocol negotiation: "
- fi
- retries=0
- while group_tool ls | \
- grep -q pending && [ $retries -lt 10 ]; do
- sleep 1
- if [ "$INITLOGLEVEL" = "full" ]; then
- echo -n "$retries "
- fi
- ((retries++))
- done
- return 0
-}
-
-stop_groupd()
-{
- stop_daemon groupd
-}
-
-start_fenced()
-{
- start_daemon fenced "$FENCED_OPTS"
-}
-
-stop_fenced()
-{
- stop_daemon fenced
-}
-
-start_dlm_controld()
-{
- start_daemon dlm_controld "$DLM_CONTROLD_OPTS" || return 1
-
- if [ "$INITLOGLEVEL" = "full" ]; then
- ok
- echo -n " Waiting dlm_controld to complete initialization: "
- fi
-
- retries=0
- while ! dlm_tool ls >/dev/null 2>&1 && [ $retries -lt 10 ]; do
- sleep 1
- if [ "$INITLOGLEVEL" = "full" ]; then
- echo -n "$retries "
- fi
- ((retries++))
- done
-
- return 0
-}
-
-stop_dlm_controld()
-{
- stop_daemon dlm_controld
-}
-
-start_ocfs2_controld()
-{
- start_daemon ocfs2_controld.cman
-}
-
-start_cmannotifyd()
-{
- start_daemon cmannotifyd
-}
-
-stop_cmannotifyd()
-{
- stop_daemon cmannotifyd
-}
-
-fence_sanlock_check()
-{
- service fence_sanlockd status > /dev/null 2>&1 &&
- echo " fence_sanlockd detected. Unfencing might take several minutes!"
- return 0
-}
-
-unfence_self()
-{
- # fence_node returns 0 on success, 1 on failure, 2 if unconfigured
- # 0 and 2 are ok. Everything else should report error.
- fence_err=$(fence_node -U 2>&1)
- case $? in
- 0|2)
- return 0
- ;;
- esac
- errmsg="$fence_err"
- return 1
-}
-
-join_fence_domain()
-{
- if ! cman_tool status | grep Flags | grep 2node \
- > /dev/null 2>&1; then
- errmsg=$( fence_tool join -w $FENCE_JOIN_TIMEOUT \
- 2>&1 ) || return 1
- else
- errmsg=$( fence_tool join -w $FENCE_JOIN_TIMEOUT \
- -m $FENCED_MEMBER_DELAY join \
- 2>&1 ) || return 1
- fi
-}
-
-leave_fence_domain()
-{
- if status fenced > /dev/null 2>&1; then
- errmsg=$( fence_tool leave -w 30 2>&1 )
- return $?
- fi
-}
-
-tune_dlm_config()
-{
- dlmdir="/sys/kernel/config/dlm/cluster"
-
- [ -n "$DLM_LKBTBL_SIZE" ] && [ -f $dlmdir/lkbtbl_size ] && \
- echo $DLM_LKBTBL_SIZE > $dlmdir/lkbtbl_size
-
- [ -n "$DLM_RSBTBL_SIZE" ] && [ -f $dlmdir/rsbtbl_size ] && \
- echo $DLM_RSBTBL_SIZE > $dlmdir/rsbtbl_size
-
- [ -n "$DLM_DIRTBL_SIZE" ] && [ -f $dlmdir/dirtbl_size ] && \
- echo $DLM_DIRTBL_SIZE > $dlmdir/dirtbl_size
-
- [ -n "$DLM_TCP_PORT" ] && [ -f $dlmdir/tcp_port ] && \
- echo $DLM_TCP_PORT > $dlmdir/tcp_port
-
- return 0
-}
-
-start()
-{
- currentaction="start"
- [ -n "$INITBREAKPOINT" ] && breakpoint="$INITBREAKPOINT"
- [ -n "$1" ] && breakpoint="$1"
-
- sshd_enabled && cd @INITDDIR@ && ./sshd start
-
- if [ "$INITLOGLEVEL" = "quiet" ]; then
- echoarg="-n"
- fi
-
- echo $echoarg "Starting cluster: "
-
- runwrap cluster_disabled_at_boot \
- none \
- "Checking if cluster has been disabled at boot"
-
- runwrap network_manager_enabled \
- none \
- "Checking Network Manager"
-
- runwrap start_global \
- none \
- "Global setup"
-
- runwrap xend_bridged_net_start \
- xend_bridged_net_enabled \
- "Enable Xend bridge net workaround"
-
- runwrap load_kernel_modules \
- none \
- "Loading kernel modules"
-
- runwrap start_configfs \
- none \
- "Mounting configfs"
-
- [ "$breakpoint" = "setup" ] && return 0
-
- runwrap start_cman \
- none \
- "Starting cman"
-
- [ "$breakpoint" = "join" ] && return 0
-
- runwrap start_cmannotifyd \
- cmannotifyd_enabled \
- "Starting cmannotifyd"
-
- [ "$breakpoint" = "notify" ] && return 0
-
- runwrap start_qdiskd \
- qdiskd_enabled \
- "Starting qdiskd"
-
- runwrap wait_for_quorum \
- none \
- "Waiting for quorum"
-
- [ "$breakpoint" = "quorum" ] && return 0
-
- runwrap start_groupd \
- groupd_enabled \
- "Starting groupd"
-
- runwrap start_fenced \
- none \
- "Starting fenced"
-
- runwrap start_dlm_controld \
- dlm_controld_enabled \
- "Starting dlm_controld"
-
- runwrap tune_dlm_config \
- none \
- "Tuning DLM kernel config"
-
- gfs_controld_enabled && cd @INITDDIR@ && ./gfs2-cluster start
-
- runwrap start_ocfs2_controld \
- ocfs2_enabled \
- "Starting ocfs2_controld"
-
- [ "$breakpoint" = "daemons" ] && return 0
-
- fence_sanlock_check
-
- runwrap unfence_self \
- none \
- "Unfencing self"
-
- runwrap join_fence_domain \
- fence_join_enabled \
- "Joining fence domain"
-}
-
-stop()
-{
- if [ "$INITLOGLEVEL" = "quiet" ]; then
- echoarg="-n"
- fi
-
- echo $echoarg "Stopping cluster: "
-
- runwrap leave_fence_domain \
- fence_join_enabled \
- "Leaving fence domain"
-
- gfs_controld_enabled && cd @INITDDIR@ && ./gfs2-cluster stop
-
- runwrap stop_dlm_controld \
- dlm_controld_enabled \
- "Stopping dlm_controld"
-
- runwrap stop_fenced \
- none \
- "Stopping fenced"
-
- runwrap stop_groupd \
- groupd_enabled \
- "Stopping groupd"
-
- runwrap stop_qdiskd \
- qdiskd_enabled \
- "Stopping qdiskd"
-
- runwrap stop_cman \
- none \
- "Stopping cman"
-
- runwrap stop_cmannotifyd \
- cmannotifyd_enabled \
- "Stopping cmannotifyd"
-
- runwrap unload_kernel_modules \
- none \
- "Unloading kernel modules"
-
- runwrap stop_configfs \
- none \
- "Unmounting configfs"
-}
-
-cmanstatus()
-{
- errmsg=$( status corosync 2>&1 )
- ret=$?
- if [ "$ret" != "0" ]; then
- if [ -f /var/run/cman.pid ]; then
- errmsg="Found stale pid file"
- return 1
- fi
- if [ -f $LOCK_FILE ]; then
- errmsg="Found stale lock file"
- return 2
- fi
- return $ret
- fi
-
- if ! cman_running; then
- errmsg="cman is not running"
- return 3
- fi
-
- if qdiskd_enabled; then
- errmsg=$( status qdiskd 2>&1 ) || return $?
- fi
-
- if groupd_enabled; then
- errmsg=$( status groupd 2>&1 ) || return $?
- fi
-
- errmsg=$( status fenced 2>&1 ) || return $?
- errmsg=$( status dlm_controld 2>&1 ) || return $?
-
- if cmannotifyd_enabled; then
- errmsg=$( status cmannotifyd 2>&1 ) || return $?
- fi
-}
-
-rtrn=0
-
-if [ "$EUID" != "0" ]; then
- echo "Only root can execute $0 script"
- exit 4
-fi
-
-# See how we were called.
-case "$1" in
-start)
- start "$2" && touch $LOCK_FILE
- if [ "$INITLOGLEVEL" = "quiet" ]; then
- success
- echo
- fi
-;;
-stop)
- cmanremove=""
- if [ -n "$2" ] && [ "$2" = "remove" ]; then
- cmanremove=remove
- fi
- stop && rm -f $LOCK_FILE
- if [ "$INITLOGLEVEL" = "quiet" ]; then
- success
- echo
- fi
-;;
-restart|reload|force-reload)
- cmanremove=remove
- stop && rm -f $LOCK_FILE
- start && touch $LOCK_FILE
-;;
-condrestart|try-restart)
- if cmanstatus; then
- cmanremove=remove
- stop && rm -f $LOCK_FILE
- start && touch $LOCK_FILE
- fi
-;;
-status)
- cmanstatus
- rtrn=$?
- if [ "$rtrn" = 0 ]; then
- echo "cluster is running."
- else
- echo -e "$errmsg"
- fi
-;;
-*)
- echo "Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
- rtrn=2
-;;
-esac
-
-exit $rtrn
diff --git a/cman/init.d/cman.init.defaults.in b/cman/init.d/cman.init.defaults.in
deleted file mode 100644
index e94f676..0000000
--- a/cman/init.d/cman.init.defaults.in
+++ /dev/null
@@ -1,132 +0,0 @@
-# CMAN_CLUSTER_TIMEOUT -- amount of time to wait for joinging a cluster
-# before giving up. If CMAN_CLUSTER_TIMEOUT is positive, then we will
-# wait CMAN_CLUSTER_TIMEOUT seconds before giving up and failing when
-# a cluster is not joined. If CMAN_CLUSTER_TIMEOUT is zero, then
-# wait indefinately for a cluster join. If CMAN_CLUSTER_TIMEOUT is
-# negative, do not check to see that the cluster has been joined
-#CMAN_CLUSTER_TIMEOUT=60
-
-# CMAN_QUORUM_TIMEOUT -- amount of time to wait for a quorate cluster on
-# startup quorum is needed by many other applications, so we may as
-# well wait here. If CMAN_QUORUM_TIMEOUT is zero, quorum will
-# be ignored.
-#CMAN_QUORUM_TIMEOUT=45
-
-# CMAN_SHUTDOWN_TIMEOUT -- amount of time to wait for cman to become a
-# cluster member before calling cman_tool leave during shutdown.
-# The default is 60 seconds
-#CMAN_SHUTDOWN_TIMEOUT=60
-
-# CMAN_NOTIFYD_START - control the startup behaviour for cmannotifyd
-# the variable can take 3 values:
-# yes | will always start cmannotifyd
-# no | will never start cmannotifyd
-# conditional (default) | will start cmannotifyd only if scriptlets
-# are found in @NOTIFYDDIR@
-#CMAN_NOTIFYD_START=conditional
-
-# CMAN_SSHD_START - control sshd startup behaviour
-# the variable can take 2 values:
-# yes | cman will start sshd as early as possible
-# no (default) | cman will not start sshd
-#CMAN_SSHD_START=no
-
-# CMAN_DAEMONS_START -- Set to "no" to disable {dlm,gfs,ocfs2}-controld daemons
-# execution from within cman init script
-# (Can be useful for some pacemaker-based setups).
-# values:
-# no | cman init will NOT start the daemons
-# empty or any other value (default) | cman init will start the daemons
-#CMAN_DAEMONS_START=
-
-# DLM_CONTROLD_OPTS -- allow extra options to be passed to dlm_controld daemon.
-#DLM_CONTROLD_OPTS=""
-
-# Allow tuning of DLM kernel config.
-# do NOT change unless instructed to do so.
-#DLM_LKBTBL_SIZE=""
-#DLM_RSBTBL_SIZE=""
-#DLM_DIRTBL_SIZE=""
-#DLM_TCP_PORT=""
-
-# FENCE_JOIN_TIMEOUT -- seconds to wait for fence domain join to
-# complete. If the join hasn't completed in this time, fence_tool join
-# exits with an error, and this script exits with an error. To wait
-# indefinitely set the value to -1.
-#FENCE_JOIN_TIMEOUT=20
-
-# FENCED_MEMBER_DELAY -- amount of time to delay fence_tool join to allow
-# all nodes in cluster.conf to become cluster members. In seconds.
-#FENCED_MEMBER_DELAY=45
-
-# FENCE_JOIN -- boolean value used to control whether or not this node
-# should join the fence domain. If FENCE_JOIN is set to "no", then
-# the script will not attempt to the fence domain. If FENCE_JOIN is
-# set to "yes", then the script will attempt to join the fence domain.
-# If FENCE_JOIN is set to any other value, the default behavior is
-# to join the fence domain (equivalent to "yes").
-# When setting FENCE_JOIN to "no", it is important to also set
-# DLM_CONTROLD_OPTS="-f0" (at least) for correct operation.
-# Please note that clusters without fencing are not
-# supported by Red Hat except for MRG installations.
-#FENCE_JOIN="yes"
-
-# FENCED_OPTS -- allow extra options to be passed to fence daemon.
-#FENCED_OPTS=""
-
-# NETWORK_BRIDGE_SCRIPT -- script to use for xen network bridging.
-# This script must exist in the /etc/xen/scripts directory.
-# The default script is "network-bridge".
-#NETWORK_BRIDGE_SCRIPT="network-bridge"
-
-# CLUSTERNAME -- override clustername as specified in cluster.conf
-#CLUSTERNAME=""
-
-# NODENAME -- specify the nodename of this node. Default autodetected
-#NODENAME=""
-
-# CONFIG_LOADER -- select default config parser.
-# This can be:
-# xmlconfig - read directly from cluster.conf and use ricci as default
-# config propagation method. (default)
-# ldapconfig - read configuration from an ldap server.
-# Requires: COROSYNC_LDAP_URL or/and COROSYNC_LDAP_BASEDN
-# envvar to be set.
-# LDAP_BINDDN and LDAP_BINDPWD have to be either both set
-# or both unset.
-# corosync_parser - use internal corosync config file parser.
-# openaisparser - use internal openais config file parser.
-#CONFIG_LOADER=xmlconfig
-
-# CONFIG_VALIDATION -- select default config validation behaviour
-# This can be:
-# FAIL - Use a very strict checking. The config will not be loaded if there
-# for any kind of warnings/errors.
-# WARN - Same as FAIL, but will allow the config to load (this is temporary
-# the default behaviour)
-# NONE - Disable config validation. Highly discouraged.
-#CONFIG_VALIDATION=WARN
-
-# CMAN_LEAVE_OPTS -- allows extra options to be passed to cman_tool when leave
-# operation is performed.
-#CMAN_LEAVE_OPTS=""
-
-# INITLOGLEVEL -- select how verbose the init script should be
-# possible values:
-# quiet - only one line notification for start/stop operations
-# terse (default) - show only required activity
-# full - show everything
-#INITLOGLEVEL=terse
-
-# INITBREAKPOINT -- select cman init break point during startup
-# possible values:
-# setup - exit before executing cman
-# join - exit after executing cman
-# notify - exit after starting up notifyd (if enabled) and before quorum
-# quorum - exit after start qdiskd (if enabled) and wait for quorum
-# daemons - exit after starting all other daemons (if enabled)
-# all (default) - start all the stack
-#
-# invoking cman init with /etc/init.d/cman start <selected_breakpoint>
-# overrides configured breakpoint from default settings
-#INITBREAKPOINT="all"
diff --git a/cman/lib/Makefile b/cman/lib/Makefile
deleted file mode 100644
index da32992..0000000
--- a/cman/lib/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-TARGET= libcman
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/libs.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -I${cmanincdir} -I$(S)/../daemon
-CFLAGS += -I${incdir}
diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c
deleted file mode 100644
index 367129c..0000000
--- a/cman/lib/libcman.c
+++ /dev/null
@@ -1,1145 +0,0 @@
-#include <sys/types.h>
-#include <sys/un.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include "cnxman-socket.h"
-#include "libcman.h"
-
-/* List of saved messages */
-struct saved_message
-{
- struct sock_header *msg;
- struct saved_message *next;
-};
-
-struct cman_handle
-{
- int magic;
- int fd;
- int zero_fd;
- void *privdata;
- int want_reply;
- cman_callback_t event_callback;
- cman_datacallback_t data_callback;
- cman_confchgcallback_t confchg_callback;
-
- void *reply_buffer;
- int reply_buflen;
- int reply_status;
-
- struct saved_message *saved_data_msg;
- struct saved_message *saved_event_msg;
- struct saved_message *saved_reply_msg;
-};
-
-#define VALIDATE_HANDLE(h) do {if (!(h) || (h)->magic != CMAN_MAGIC) {errno = EINVAL; return -1;}} while (0)
-
-/*
- * Wait for an command/request reply.
- * Data/event messages will be queued.
- *
- */
-static int wait_for_reply(struct cman_handle *h, void *msg, int max_len)
-{
- int ret;
-
- h->want_reply = 1;
- h->reply_buffer = msg;
- h->reply_buflen = max_len;
-
- do
- {
- ret = cman_dispatch(h, CMAN_DISPATCH_BLOCKING | CMAN_DISPATCH_IGNORE_EVENT | CMAN_DISPATCH_IGNORE_DATA);
-
- } while (h->want_reply == 1 && ret >= 0);
-
- h->reply_buffer = NULL;
- h->reply_buflen = 0;
-
- /* Error in local comms */
- if (ret < 0) {
- return -1;
- }
- /* cnxman daemon returns -ve errno values on error */
- if (h->reply_status < 0) {
- errno = -h->reply_status;
- return -1;
- }
- else {
- return h->reply_status;
- }
-}
-
-
-static void copy_node(cman_node_t *unode, struct cl_cluster_node *knode)
-{
- unode->cn_nodeid = knode->node_id;
- unode->cn_member = knode->state == NODESTATE_MEMBER?1:0;
- strncpy(unode->cn_name, knode->name, sizeof(unode->cn_name) - 1);
- unode->cn_incarnation = knode->incarnation;
- unode->cn_jointime = knode->jointime;
-
- memset(&unode->cn_address, 0, sizeof(unode->cn_address));
- memcpy(&unode->cn_address.cna_address, knode->addr, knode->addrlen);
- unode->cn_address.cna_addrlen = knode->addrlen;
-}
-
-/* Add to a list. saved_message *m is the head of the list in the cman_handle */
-static void add_to_waitlist(struct saved_message **m, struct sock_header *msg)
-{
- struct saved_message *next = *m;
- struct saved_message *last = *m;
- struct saved_message *this;
-
- this = malloc(sizeof(struct saved_message));
- if (!this)
- return;
-
- this->msg = malloc(msg->length);
- if (!this->msg)
- {
- free(this);
- return;
- }
-
- memcpy(this->msg, msg, msg->length);
- this->next = NULL;
-
- if (!next)
- {
- *m = this;
- return;
- }
-
- for (; next; next = next->next)
- {
- last = next;
- }
- last->next = this;
-}
-
-static int process_cman_message(struct cman_handle *h, int flags, struct sock_header *msg)
-{
- /* Data for us */
- if ((msg->command & CMAN_CMDMASK_CMD) == CMAN_CMD_DATA)
- {
- struct sock_data_header *dmsg = (struct sock_data_header *)msg;
- char *buf = (char *)msg;
-
- if (flags & CMAN_DISPATCH_IGNORE_DATA)
- {
- add_to_waitlist(&h->saved_data_msg, msg);
- }
- else
- {
- if (h->data_callback)
- h->data_callback(h, h->privdata,
- buf+sizeof(*dmsg), msg->length-sizeof(*dmsg),
- dmsg->port, dmsg->nodeid);
- }
- return 0;
- }
-
- /* Got a reply to a previous information request */
- if ((msg->command & CMAN_CMDFLAG_REPLY) && h->want_reply)
- {
- char *replybuf = (char *)msg;
- int replylen = msg->length - sizeof(struct sock_reply_header);
- struct sock_reply_header *reply = (struct sock_reply_header *)msg;
-
- if (flags & CMAN_DISPATCH_IGNORE_REPLY)
- {
- add_to_waitlist(&h->saved_reply_msg, msg);
- return 0;
- }
-
- replybuf += sizeof(struct sock_reply_header);
- if (replylen <= h->reply_buflen)
- {
- memcpy(h->reply_buffer, replybuf, replylen);
- }
- h->want_reply = 0;
- h->reply_status = reply->status;
-
- return 1;
- }
-
- /* OOB event */
- if (msg->command == CMAN_CMD_EVENT || msg->command == CMAN_CMD_CONFCHG)
- {
- if (flags & CMAN_DISPATCH_IGNORE_EVENT)
- {
- add_to_waitlist(&h->saved_event_msg, msg);
- }
- else
- {
- if (msg->command == CMAN_CMD_EVENT && h->event_callback) {
- struct sock_event_message *emsg = (struct sock_event_message *)msg;
- h->event_callback(h, h->privdata, emsg->reason, emsg->arg);
- }
-
- if (msg->command == CMAN_CMD_CONFCHG && h->confchg_callback)
- {
- struct sock_confchg_message *cmsg = (struct sock_confchg_message *)msg;
-
- h->confchg_callback(h, h->privdata,
- cmsg->entries,cmsg->member_entries,
- &cmsg->entries[cmsg->member_entries], cmsg->left_entries,
- &cmsg->entries[cmsg->member_entries+cmsg->left_entries], cmsg->joined_entries);
- }
- }
- }
-
- return 0;
-}
-
-static int loopy_writev(int fd, struct iovec *iovptr, size_t iovlen)
-{
- size_t byte_cnt=0;
- int len;
- struct msghdr msg;
-
- msg.msg_name = NULL;
- msg.msg_namelen = 0;
- msg.msg_control = NULL;
- msg.msg_controllen = 0;
-
- while (iovlen > 0)
- {
- msg.msg_iov = iovptr;
- msg.msg_iovlen = iovlen;
-
- len = sendmsg(fd, &msg, MSG_NOSIGNAL);
- if (len <= 0)
- return len;
-
- byte_cnt += len;
- while (len >= iovptr->iov_len)
- {
- len -= iovptr->iov_len;
- iovptr++;
- iovlen--;
- }
-
- if ((ssize_t)iovlen <=0 )
- break;
-
- iovptr->iov_base = (char *)iovptr->iov_base + len;
- iovptr->iov_len -= len;
- }
- return byte_cnt;
-}
-
-
-static int send_message(struct cman_handle *h, int msgtype, const void *inbuf, int inlen)
-{
- struct sock_header header;
- int len;
- struct iovec iov[2];
- size_t iovlen = 1;
-
- header.magic = CMAN_MAGIC;
- header.version = CMAN_VERSION;
- header.command = msgtype;
- header.flags = 0;
- header.length = sizeof(header) + inlen;
-
- iov[0].iov_len = sizeof(header);
- iov[0].iov_base = &header;
- if (inbuf)
- {
- iov[1].iov_len = inlen;
- iov[1].iov_base = (void *) inbuf;
- iovlen++;
- }
-
- len = loopy_writev(h->fd, iov, iovlen);
- if (len < 0)
- return len;
- return 0;
-}
-
-/* Does something similar to the ioctl calls */
-static int info_call(struct cman_handle *h, int msgtype, const void *inbuf, int inlen, void *outbuf, int outlen)
-{
- if (send_message(h, msgtype, inbuf, inlen))
- return -1;
-
- return wait_for_reply(h, outbuf, outlen);
-}
-
-static cman_handle_t open_socket(const char *name, int namelen, void *privdata)
-{
- struct cman_handle *h;
- struct sockaddr_un sockaddr;
-
- h = malloc(sizeof(struct cman_handle));
- if (!h)
- return NULL;
-
- h->magic = CMAN_MAGIC;
- h->privdata = privdata;
- h->event_callback = NULL;
- h->data_callback = NULL;
- h->confchg_callback = NULL;
- h->want_reply = 0;
- h->saved_data_msg = NULL;
- h->saved_event_msg = NULL;
- h->saved_reply_msg = NULL;
-
- h->fd = socket(PF_UNIX, SOCK_STREAM, 0);
- if (h->fd == -1)
- {
- int saved_errno = errno;
- free(h);
- errno = saved_errno;
- return NULL;
- }
-
- fcntl(h->fd, F_SETFD, FD_CLOEXEC); /* Set close-on-exec */
- memset(&sockaddr, 0, sizeof(sockaddr));
- memcpy(sockaddr.sun_path, name, namelen);
- sockaddr.sun_family = AF_UNIX;
-
- if (connect(h->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr)) < 0)
- {
- int saved_errno = errno;
- close(h->fd);
- free(h);
- errno = saved_errno;
- return NULL;
- }
-
- /* Get a handle on /dev/zero too. This is always active so we
- can return it from cman_get_fd() if we have cached messages */
- h->zero_fd = open("/dev/zero", O_RDONLY);
- if (h->zero_fd < 0)
- {
- int saved_errno = errno;
- close(h->fd);
- free(h);
- h = NULL;
- errno = saved_errno;
- } else
- fcntl(h->zero_fd, F_SETFD, FD_CLOEXEC); /* Set close-on-exec */
-
- return (cman_handle_t)h;
-}
-
-cman_handle_t cman_admin_init(void *privdata)
-{
- return open_socket(ADMIN_SOCKNAME, sizeof(ADMIN_SOCKNAME), privdata);
-}
-
-cman_handle_t cman_init(void *privdata)
-{
- return open_socket(CLIENT_SOCKNAME, sizeof(CLIENT_SOCKNAME), privdata);
-}
-
-int cman_finish(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- h->magic = 0;
- close(h->fd);
- close(h->zero_fd);
- free(h);
-
- return 0;
-}
-
-int cman_setprivdata(cman_handle_t handle, void *privdata)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- h->privdata = privdata;
- return 0;
-}
-
-int cman_getprivdata(cman_handle_t handle, void **privdata)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- *privdata = h->privdata;
-
- return 0;
-}
-
-
-int cman_start_notification(cman_handle_t handle, cman_callback_t callback)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (!callback)
- {
- errno = EINVAL;
- return -1;
- }
- if (info_call(h, CMAN_CMD_NOTIFY, NULL, 0, NULL, 0))
- return -1;
- h->event_callback = callback;
-
- return 0;
-}
-
-int cman_stop_notification(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (info_call(h, CMAN_CMD_REMOVENOTIFY, NULL, 0, NULL, 0))
- return -1;
- h->event_callback = NULL;
-
- return 0;
-}
-
-int cman_start_confchg(cman_handle_t handle, cman_confchgcallback_t callback)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (!callback)
- {
- errno = EINVAL;
- return -1;
- }
- if (info_call(h, CMAN_CMD_START_CONFCHG, NULL, 0, NULL, 0))
- return -1;
- h->confchg_callback = callback;
-
- return 0;
-}
-
-int cman_stop_confchg(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (info_call(h, CMAN_CMD_STOP_CONFCHG, NULL, 0, NULL, 0))
- return -1;
- h->confchg_callback = NULL;
-
- return 0;
-}
-
-
-int cman_get_fd(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- /* If we have saved messages then return an FD to /dev/zero which
- will always be readable */
- if (h->saved_data_msg || h->saved_event_msg || h->saved_reply_msg)
- return h->zero_fd;
- else
- return h->fd;
-}
-
-int cman_dispatch(cman_handle_t handle, int flags)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- int len;
- int offset;
- int recv_flags = 0;
- char buf[PIPE_BUF];
- VALIDATE_HANDLE(h);
-
- if (!(flags & CMAN_DISPATCH_BLOCKING))
- recv_flags |= MSG_DONTWAIT;
-
- do
- {
- int res;
- char *bufptr = buf;
- struct sock_header *header = (struct sock_header *)buf;
-
- /* First, drain any waiting queues */
- if (h->saved_reply_msg && !(flags & CMAN_DISPATCH_IGNORE_REPLY))
- {
- struct saved_message *smsg = h->saved_reply_msg;
-
- res = process_cman_message(h, flags, smsg->msg);
- h->saved_reply_msg = smsg->next;
- len = smsg->msg->length;
- free(smsg->msg);
- free(smsg);
- if (res || (flags & CMAN_DISPATCH_TYPE_MASK) == CMAN_DISPATCH_ONE)
- break;
- else
- continue;
- }
- if (h->saved_data_msg && !(flags & CMAN_DISPATCH_IGNORE_DATA))
- {
- struct saved_message *smsg = h->saved_data_msg;
-
- res = process_cman_message(h, flags, smsg->msg);
- h->saved_data_msg = smsg->next;
- len = smsg->msg->length;
- free(smsg->msg);
- free(smsg);
- if (res || (flags & CMAN_DISPATCH_TYPE_MASK) == CMAN_DISPATCH_ONE)
- break;
- else
- continue;
- }
- if (h->saved_event_msg && !(flags & CMAN_DISPATCH_IGNORE_EVENT))
- {
- struct saved_message *smsg = h->saved_event_msg;
-
- res = process_cman_message(h, flags, smsg->msg);
- h->saved_event_msg = smsg->next;
- len = smsg->msg->length;
- free(smsg->msg);
- free(smsg);
- if (res || (flags & CMAN_DISPATCH_TYPE_MASK) == CMAN_DISPATCH_ONE)
- break;
- else
- continue;
- }
-
- /* Now look for new messages */
- len = recv(h->fd, buf, sizeof(struct sock_header), recv_flags);
-
- if (len == 0) {
- errno = EHOSTDOWN;
- return -1;
- }
-
- if (len < 0 &&
- (errno == EINTR || errno == EAGAIN))
- return 0;
-
- if (len < 0)
- return -1;
-
- offset = len;
-
- /* It's too big! */
- if (header->length > sizeof(buf))
- {
- bufptr = malloc(header->length);
- if (!bufptr)
- return -1;
- memcpy(bufptr, buf, sizeof(*header));
- header = (struct sock_header *)bufptr;
- }
-
- /* Read the rest */
- while (offset < header->length)
- {
- len = read(h->fd, bufptr+offset, header->length-offset);
- if (len == 0) {
- if (bufptr != buf)
- free(bufptr);
- errno = EHOSTDOWN;
- return -1;
- }
-
- if (len < 0 &&
- (errno == EINTR || errno == EAGAIN)) {
- if (bufptr != buf)
- free(bufptr);
- return 0;
- }
-
- if (len < 0) {
- if (bufptr != buf)
- free(bufptr);
- return -1;
- }
- offset += len;
- }
-
- res = process_cman_message(h, flags, header);
- if (bufptr != buf)
- free(bufptr);
-
- if (res)
- break;
-
- } while ( flags & CMAN_DISPATCH_ALL &&
- !(len < 0 && errno == EAGAIN) );
-
- return len;
-}
-
-/* GET_ALLMEMBERS returns the number of nodes as status */
-int cman_get_node_count(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_GETALLMEMBERS, NULL, 0, NULL, 0);
-}
-
-int cman_get_nodes(cman_handle_t handle, int maxnodes, int *retnodes, cman_node_t *nodes)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_cluster_node *cman_nodes;
- int status;
- int buflen;
- int count = 0;
- VALIDATE_HANDLE(h);
-
- if (!retnodes || !nodes || maxnodes < 1)
- {
- errno = EINVAL;
- return -1;
- }
-
- buflen = sizeof(struct cl_cluster_node) * maxnodes;
- cman_nodes = malloc(buflen);
- if (!cman_nodes)
- return -1;
-
- status = info_call(h, CMAN_CMD_GETALLMEMBERS, NULL, 0, cman_nodes, buflen);
- if (status < 0)
- {
- int saved_errno = errno;
- free(cman_nodes);
- errno = saved_errno;
- return -1;
- }
-
- if (cman_nodes[0].size != sizeof(struct cl_cluster_node))
- {
- free(cman_nodes);
- errno = EINVAL;
- return -1;
- }
-
- if (status > maxnodes)
- status = maxnodes;
-
- for (count = 0; count < status; count++)
- {
- copy_node(&nodes[count], &cman_nodes[count]);
- }
- free(cman_nodes);
- *retnodes = status;
- return 0;
-}
-
-int cman_get_disallowed_nodes(cman_handle_t handle, int maxnodes, int *retnodes, cman_node_t *nodes)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_cluster_node *cman_nodes;
- int status;
- int buflen;
- int count = 0;
- int out_count = 0;
- VALIDATE_HANDLE(h);
-
- if (!retnodes || !nodes || maxnodes < 1)
- {
- errno = EINVAL;
- return -1;
- }
-
- buflen = sizeof(struct cl_cluster_node) * maxnodes;
- cman_nodes = malloc(buflen);
- if (!cman_nodes)
- return -1;
-
- status = info_call(h, CMAN_CMD_GETALLMEMBERS, NULL, 0, cman_nodes, buflen);
- if (status < 0)
- {
- int saved_errno = errno;
- free(cman_nodes);
- errno = saved_errno;
- return -1;
- }
-
- if (cman_nodes[0].size != sizeof(struct cl_cluster_node))
- {
- free(cman_nodes);
- errno = EINVAL;
- return -1;
- }
-
- for (count = 0; count < status; count++)
- {
- if (cman_nodes[count].state == NODESTATE_AISONLY && out_count < maxnodes)
- copy_node(&nodes[out_count++], &cman_nodes[count]);
- }
- free(cman_nodes);
- *retnodes = out_count;
- return 0;
-}
-
-int cman_get_node(cman_handle_t handle, int nodeid, cman_node_t *node)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_cluster_node cman_node;
- int status;
- VALIDATE_HANDLE(h);
-
- if (!node || strlen(node->cn_name) >= sizeof(cman_node.name))
- {
- errno = EINVAL;
- return -1;
- }
-
- cman_node.node_id = nodeid;
- strncpy(cman_node.name, node->cn_name, sizeof(cman_node.name) - 1);
- status = info_call(h, CMAN_CMD_GETNODE, &cman_node, sizeof(struct cl_cluster_node),
- &cman_node, sizeof(struct cl_cluster_node));
- if (status < 0)
- return -1;
-
- copy_node(node, &cman_node);
-
- return 0;
-}
-
-int cman_get_node_extra(cman_handle_t handle, int nodeid, cman_node_extra_t *node)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- int status;
- VALIDATE_HANDLE(h);
-
- status = info_call(h, CMAN_CMD_GETNODE_EXTRA, &nodeid, sizeof(int),
- node, sizeof(cman_node_extra_t));
- if (status < 0)
- return -1;
-
- return 0;
-}
-
-int cman_get_subsys_count(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_GET_JOINCOUNT, NULL,0, NULL, 0);
-}
-
-int cman_is_active(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_ISACTIVE, NULL, 0, NULL, 0);
-}
-
-int cman_is_listening(cman_handle_t handle, int nodeid, uint8_t port)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_listen_request req;
- VALIDATE_HANDLE(h);
-
- req.port = port;
- req.nodeid = nodeid;
- return info_call(h, CMAN_CMD_ISLISTENING, &req, sizeof(struct cl_listen_request), NULL, 0);
-}
-
-int cman_is_quorate(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_ISQUORATE, NULL, 0, NULL, 0);
-}
-
-
-int cman_get_version(cman_handle_t handle, cman_version_t *version)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (!version)
- {
- errno = EINVAL;
- return -1;
- }
- return info_call(h, CMAN_CMD_GET_VERSION, NULL, 0, version, sizeof(cman_version_t));
-}
-
-int cman_set_version(cman_handle_t handle, const cman_version_t *version)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (!version)
- {
- errno = EINVAL;
- return -1;
- }
- return info_call(h, CMAN_CMD_SET_VERSION, version, sizeof(cman_version_t), NULL, 0);
-}
-
-int cman_kill_node(cman_handle_t handle, int nodeid)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (!nodeid)
- {
- errno = EINVAL;
- return -1;
- }
- return info_call(h, CMAN_CMD_KILLNODE, &nodeid, sizeof(nodeid), NULL, 0);
-}
-
-int cman_set_votes(cman_handle_t handle, int votes, int nodeid)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_set_votes newv;
- VALIDATE_HANDLE(h);
-
- if (!votes)
- {
- errno = EINVAL;
- return -1;
- }
- newv.nodeid = nodeid;
- newv.newvotes = votes;
- return info_call(h, CMAN_CMD_SET_VOTES, &newv, sizeof(newv), NULL, 0);
-}
-
-int cman_set_expected_votes(cman_handle_t handle, int evotes)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (!evotes)
- {
- errno = EINVAL;
- return -1;
- }
- return info_call(h, CMAN_CMD_SETEXPECTED_VOTES, &evotes, sizeof(evotes), NULL, 0);
-}
-
-int cman_leave_cluster(cman_handle_t handle, int reason)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_LEAVE_CLUSTER, &reason, sizeof(reason), NULL, 0);
-}
-
-int cman_get_cluster(cman_handle_t handle, cman_cluster_t *clinfo)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (!clinfo)
- {
- errno = EINVAL;
- return -1;
- }
- return info_call(h, CMAN_CMD_GETCLUSTER, NULL, 0, clinfo, sizeof(cman_cluster_t));
-}
-
-int cman_get_extra_info(cman_handle_t handle, cman_extra_info_t *info, int maxlen)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- if (!info || maxlen < sizeof(cman_extra_info_t))
- {
- errno = EINVAL;
- return -1;
- }
- return info_call(h, CMAN_CMD_GETEXTRAINFO, NULL, 0, info, maxlen);
-}
-
-int cman_send_data(cman_handle_t handle, const void *buf, int len, int flags, uint8_t port, int nodeid)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct iovec iov[2];
- struct sock_data_header header;
- VALIDATE_HANDLE(h);
-
- header.header.magic = CMAN_MAGIC;
- header.header.version = CMAN_VERSION;
- header.header.command = CMAN_CMD_DATA;
- header.header.flags = flags;
- header.header.length = len + sizeof(header);
- header.nodeid = nodeid;
- header.port = port;
-
- iov[0].iov_len = sizeof(header);
- iov[0].iov_base = &header;
- iov[1].iov_len = len;
- iov[1].iov_base = (void *) buf;
-
- return loopy_writev(h->fd, iov, 2);
-}
-
-
-int cman_start_recv_data(cman_handle_t handle, cman_datacallback_t callback, uint8_t port)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- int portparam;
- int status;
- VALIDATE_HANDLE(h);
-
-/* Do a "bind" */
- portparam = port;
- status = info_call(h, CMAN_CMD_BIND, &portparam, sizeof(portparam), NULL, 0);
-
- if (status == 0)
- h->data_callback = callback;
-
- return status;
-}
-
-int cman_end_recv_data(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- h->data_callback = NULL;
- return 0;
-}
-
-
-int cman_barrier_register(cman_handle_t handle, const char *name, int flags, int nodes)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_barrier_info binfo;
- VALIDATE_HANDLE(h);
-
- if (strlen(name) >= MAX_BARRIER_NAME_LEN)
- {
- errno = EINVAL;
- return -1;
- }
-
- binfo.cmd = BARRIER_CMD_REGISTER;
- strncpy(binfo.name, name, sizeof(binfo.name) - 1);
- binfo.arg = nodes;
- binfo.flags = flags;
-
- return info_call(h, CMAN_CMD_BARRIER, &binfo, sizeof(binfo), NULL, 0);
-}
-
-
-int cman_barrier_change(cman_handle_t handle, const char *name, int flags, int arg)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_barrier_info binfo;
- VALIDATE_HANDLE(h);
-
- if (strlen(name) >= MAX_BARRIER_NAME_LEN)
- {
- errno = EINVAL;
- return -1;
- }
-
- binfo.cmd = BARRIER_CMD_CHANGE;
- strncpy(binfo.name, name, sizeof(binfo.name) - 1);
- binfo.arg = arg;
- binfo.flags = flags;
-
- return info_call(h, CMAN_CMD_BARRIER, &binfo, sizeof(binfo), NULL, 0);
-
-}
-
-int cman_barrier_wait(cman_handle_t handle, const char *name)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_barrier_info binfo;
- VALIDATE_HANDLE(h);
-
- if (strlen(name) >= MAX_BARRIER_NAME_LEN)
- {
- errno = EINVAL;
- return -1;
- }
-
- binfo.cmd = BARRIER_CMD_WAIT;
- strncpy(binfo.name, name, sizeof(binfo.name) - 1);
-
- return info_call(h, CMAN_CMD_BARRIER, &binfo, sizeof(binfo), NULL, 0);
-}
-
-int cman_barrier_delete(cman_handle_t handle, const char *name)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_barrier_info binfo;
- VALIDATE_HANDLE(h);
-
- if (strlen(name) >= MAX_BARRIER_NAME_LEN)
- {
- errno = EINVAL;
- return -1;
- }
-
- binfo.cmd = BARRIER_CMD_DELETE;
- strncpy(binfo.name, name, sizeof(binfo.name) - 1);
-
- return info_call(h, CMAN_CMD_BARRIER, &binfo, sizeof(binfo), NULL, 0);
-}
-
-int cman_shutdown(cman_handle_t handle, int flags)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_TRY_SHUTDOWN, &flags, sizeof(int), NULL, 0);
-}
-
-int cman_set_dirty(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_SET_DIRTY, NULL, 0, NULL, 0);
-}
-
-int cman_set_debuglog(cman_handle_t handle, int subsystems)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_SET_DEBUGLOG, &subsystems, sizeof(int), NULL, 0);
-}
-
-int cman_replyto_shutdown(cman_handle_t handle, int yesno)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- send_message(h, CMAN_CMD_SHUTDOWN_REPLY, &yesno, sizeof(int));
- return 0;
-}
-
-static int cman_set_quorum_device(cman_handle_t handle,
- int ops,
- char *name, int votes)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- char buf[strlen(name)+1 + sizeof(int)];
- VALIDATE_HANDLE(h);
-
- memcpy(buf, &votes, sizeof(int));
- strncpy(buf+sizeof(int), name, strlen(name)+1 + sizeof(int) - 1);
- return info_call(h, ops, buf, strlen(name)+1+sizeof(int), NULL, 0);
-}
-
-int cman_register_quorum_device(cman_handle_t handle, char *name, int votes)
-{
- if ((!name) || (strlen(name) > MAX_CLUSTER_MEMBER_NAME_LEN) || (votes < 0))
- {
- errno = EINVAL;
- return -1;
- }
- return cman_set_quorum_device(handle, CMAN_CMD_REG_QUORUMDEV, name, votes);
-}
-
-int cman_unregister_quorum_device(cman_handle_t handle)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_UNREG_QUORUMDEV, NULL, 0, NULL, 0);
-}
-
-int cman_poll_quorum_device(cman_handle_t handle, int isavailable)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- VALIDATE_HANDLE(h);
-
- return info_call(h, CMAN_CMD_POLL_QUORUMDEV, &isavailable, sizeof(int), NULL, 0);
-}
-
-int cman_get_quorum_device(cman_handle_t handle, struct cman_qdev_info *info)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- int ret;
- struct cl_cluster_node cman_node;
- VALIDATE_HANDLE(h);
-
- cman_node.node_id = CLUSTER_GETNODE_QUORUMDEV;
- ret = info_call(h, CMAN_CMD_GETNODE, &cman_node, sizeof(cman_node), &cman_node, sizeof(cman_node));
- if (!ret) {
- strncpy(info->qi_name, cman_node.name, sizeof(info->qi_name) - 1);
- info->qi_state = cman_node.state;
- info->qi_votes = cman_node.votes;
- }
- return ret;
-}
-
-int cman_update_quorum_device(cman_handle_t handle, char *name, int votes)
-{
- if ((!name) || (strlen(name) > MAX_CLUSTER_MEMBER_NAME_LEN) || (votes < 0))
- {
- errno = EINVAL;
- return -1;
- }
- return cman_set_quorum_device(handle, CMAN_CMD_UPDATE_QUORUMDEV, name, votes);
-}
-
-int cman_get_fenceinfo(cman_handle_t handle, int nodeid, uint64_t *time, int *fenced, char *agent)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- int ret;
- struct cl_fence_info f;
- VALIDATE_HANDLE(h);
-
- ret = info_call(h, CMAN_CMD_GET_FENCE_INFO, &nodeid, sizeof(int), &f, sizeof(f));
- if (!ret) {
- *time = f.fence_time;
- if (agent)
- strncpy(agent, f.fence_agent, sizeof(f.fence_agent) - 1);
- *fenced = ((f.flags & FENCE_FLAGS_FENCED) != 0);
- }
- return ret;
-}
-
-int cman_get_node_addrs(cman_handle_t handle, int nodeid, int max_addrs, int *num_addrs, struct cman_node_address *addrs)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- int ret;
- char buf[sizeof(struct cl_get_node_addrs) + sizeof(struct cl_node_addrs)*max_addrs];
- struct cl_get_node_addrs *outbuf = (struct cl_get_node_addrs *)buf;
- VALIDATE_HANDLE(h);
-
- ret = info_call(h, CMAN_CMD_GET_NODEADDRS, &nodeid, sizeof(int), buf, sizeof(buf));
- if (!ret) {
- int i;
-
- *num_addrs = outbuf->numaddrs;
-
- if (outbuf->numaddrs > max_addrs)
- outbuf->numaddrs = max_addrs;
-
- for (i=0; i < outbuf->numaddrs; i++) {
- memcpy(&addrs[i].cna_address, &outbuf->addrs[i].addr, outbuf->addrs[i].addrlen);
- addrs[i].cna_addrlen = outbuf->addrs[i].addrlen;
- }
- }
- return ret;
-}
-
-int cman_node_fenced(cman_handle_t handle, int nodeid, uint64_t time, char *agent)
-{
- struct cman_handle *h = (struct cman_handle *)handle;
- struct cl_fence_info f;
- VALIDATE_HANDLE(h);
-
- if (strlen(agent) >= MAX_FENCE_AGENT_NAME_LEN) {
- errno = EINVAL;
- return -1;
- }
-
- f.nodeid = nodeid;
- f.fence_time = time;
- strncpy(f.fence_agent, agent, sizeof(f.fence_agent) - 1);
- return info_call(h, CMAN_CMD_UPDATE_FENCE_INFO, &f, sizeof(f), NULL, 0);
-}
diff --git a/cman/lib/libcman.h b/cman/lib/libcman.h
deleted file mode 100644
index 9f97875..0000000
--- a/cman/lib/libcman.h
+++ /dev/null
@@ -1,457 +0,0 @@
-#ifndef _LIBCMAN_H_
-#define _LIBCMAN_H_
-
-#include <netinet/in.h>
-
-#define LIBCMAN_VERSION 3
-
-/*
- * Some maxima
- */
-#define CMAN_MAX_ADDR_LEN sizeof(struct sockaddr_in6)
-#define CMAN_MAX_NODENAME_LEN 255
-#define MAX_CLUSTER_NAME_LEN 16
-#define CMAN_MAX_FENCE_AGENT_NAME_LEN 255
-
-/*
- * Pass this into cman_get_node() as the nodeid to get local node information
- */
-#define CMAN_NODEID_US 0
-
-/*
- * Pass this into cman_get_node() as the nodeid to get quorum device information
- */
-#define CMAN_NODEID_QDISK -1
-
-
-/* Pass this into cman_send_data to send a message to all nodes */
-#define CMAN_NODEID_ALL 0
-
-/*
- * Hang onto this, it's your key into the library. get one from cman_init() or
- * cman_admin_init()
- */
-typedef void *cman_handle_t;
-
-/*
- * Reasons we get an event callback.
- * PORTOPENED & TRY_SHUTDOWN only exist when LIBCMAN_VERSION >= 2
- *
- * The 'arg' parameter varies depending on the callback type.
- * for PORTCLOSED/PORTOPENED arg == the port opened/closed
- * for STATECHANGE arg is quorum state (1=quorate, 0=not)
- * for TRY_SHUTDOWN arg == 1 for ANYWAY, otherwise 0 (ie if arg == 1
- * then cman WILL shutdown regardless
- * of your response, think of this as advance warning)
- * for CONFIG_UPDATE arg will be the new config version
- */
-typedef enum {CMAN_REASON_PORTCLOSED,
- CMAN_REASON_STATECHANGE,
- CMAN_REASON_PORTOPENED,
- CMAN_REASON_TRY_SHUTDOWN,
- CMAN_REASON_CONFIG_UPDATE} cman_call_reason_t;
-
-/*
- * Reason flags for cman_leave
- */
-#define CMAN_LEAVEFLAG_DOWN 0
-#define CMAN_LEAVEFLAG_REMOVED 3
-#define CMAN_LEAVEFLAG_FORCE 0x10
-
-/*
- * Flags for cman_shutdown
- * ANYWAY - cman will shutdown regardless of clients' responses (but they
- * will still get told)
- * REMOVED - the rest of the cluster will adjust quorum to stay quorate
- */
-#define CMAN_SHUTDOWN_ANYWAY 1
-#define CMAN_SHUTDOWN_REMOVED 2
-
-/*
- * Flags passed to cman_dispatch():
- * CMAN_DISPATCH_ONE dispatches a single message then returns,
- * CMAN_DISPATCH_ALL dispatches all outstanding messages (ie till EAGAIN) then
- * returns,
- * CMAN_DISPATCH_BLOCKING forces it to wait for a message (clears MSG_DONTWAIT
- * in recvmsg)
- * CMAN_DISPATCH_IGNORE_* allows the caller to select which messages to process.
- */
-#define CMAN_DISPATCH_ONE 0
-#define CMAN_DISPATCH_ALL 1
-#define CMAN_DISPATCH_BLOCKING 2
-#define CMAN_DISPATCH_IGNORE_REPLY 4
-#define CMAN_DISPATCH_IGNORE_DATA 8
-#define CMAN_DISPATCH_IGNORE_EVENT 16
-#define CMAN_DISPATCH_TYPE_MASK 3
-#define CMAN_DISPATCH_IGNORE_MASK 46
-
-/*
- * A node address. This is a complete sockaddr_in[6]
- * To explain:
- * If you cast cna_address to a 'struct sockaddr', the sa_family field
- * will be AF_INET or AF_INET6. Armed with that knowledge you can then
- * cast it to a sockaddr_in or sockaddr_in6 and pull out the address.
- * No other sockaddr fields are valid.
- * Also, you must ignore any part of the sockaddr beyond the length supplied
- */
-typedef struct cman_node_address
-{
- int cna_addrlen;
- char cna_address[CMAN_MAX_ADDR_LEN];
-} cman_node_address_t;
-
-/*
- * Return from cman_get_node()
- */
-typedef struct cman_node
-{
- int cn_nodeid;
- cman_node_address_t cn_address;
- char cn_name[CMAN_MAX_NODENAME_LEN+1];
- int cn_member;
- int cn_incarnation;
- struct timeval cn_jointime;
-} cman_node_t;
-
-/*
- * Return from cman_get_node_extra()
- */
-typedef struct cman_node_extra
-{
- int cnx_nodeid;
- int cnx_state;
- int cnx_votes;
- int cnx_expected_votes;
- int cnx_leave_reason;
-} cman_node_extra_t;
-
-#define CLUSTER_LEAVEREASON_DOWN 0 /* Normal shutdown */
-#define CLUSTER_LEAVEREASON_KILLED 1 /* probably buy cman_tool */
-#define CLUSTER_LEAVEREASON_PANIC 2 /* Just disappeared */
-#define CLUSTER_LEAVEREASON_REMOVED 3 /* This one can reduce quorum */
-#define CLUSTER_LEAVEREASON_REJECTED 4 /* Not allowed into the cluster in the first place */
-#define CLUSTER_LEAVEREASON_INCONSISTENT 5 /* Our view of the cluster is in a minority */
-#define CLUSTER_LEAVEREASON_DEAD 6 /* Discovered to be dead */
-#define CLUSTER_LEAVEREASON_NORESPONSE 7 /* Didn't ACK message */
-
-#define CLUSTER_NODESTATE_JOINING 1
-#define CLUSTER_NODESTATE_MEMBER 2
-#define CLUSTER_NODESTATE_DEAD 3
-#define CLUSTER_NODESTATE_LEAVING 4
-#define CLUSTER_NODESTATE_DISALLOWED 5
-
-
-/*
- * Returned from cman_get_version(),
- * input to cman_set_version(), though only cv_config can be changed
- */
-typedef struct cman_version
-{
- unsigned int cv_major;
- unsigned int cv_minor;
- unsigned int cv_patch;
- unsigned int cv_config;
-} cman_version_t;
-
-/*
- * Return from cman_get_cluster()
- */
-typedef struct cman_cluster
-{
- char ci_name[MAX_CLUSTER_NAME_LEN+1];
- uint16_t ci_number;
- uint32_t ci_generation;
-} cman_cluster_t;
-
-/*
- * This is returned from cman_get_extra_info - it's really
- * only for use by cman_tool, don't depend on this not changing
- */
-
-/* Flags in ei_flags */
-#define CMAN_EXTRA_FLAG_2NODE 1
-#define CMAN_EXTRA_FLAG_ERROR 2
-#define CMAN_EXTRA_FLAG_SHUTDOWN 4
-#define CMAN_EXTRA_FLAG_DISALLOWED 8
-#define CMAN_EXTRA_FLAG_DIRTY 16
-#define CMAN_EXTRA_FLAG_DISALLOWED_ENABLED 32
-
-typedef struct cman_extra_info {
- int ei_node_state;
- int ei_flags;
- int ei_node_votes;
- int ei_total_votes;
- int ei_expected_votes;
- int ei_quorum;
- int ei_members;
- char ei_ports[32];
- int ei_num_addresses;
- char ei_addresses[1]; /* Array of num_addresses*sockaddr_storage*2
- First batch is the multicast address list */
-} cman_extra_info_t;
-
-/* Quorum device info, returned from cman_get_quorum_device() */
-typedef struct cman_qdev_info {
- char qi_name[CMAN_MAX_NODENAME_LEN+1];
- int qi_state;
- int qi_votes;
-} cman_qdev_info_t;
-
-/*
- * NOTE: Apart from cman_replyto_shutdown(), you must not
- * call other cman_* functions while in these two callbacks:
- */
-
-/* Callback routine for a membership or other event */
-typedef void (*cman_callback_t)(cman_handle_t handle, void *privdata, int reason, int arg);
-
-/* Callback routine for data received */
-typedef void (*cman_datacallback_t)(cman_handle_t handle, void *privdata,
- char *buf, int len, uint8_t port, int nodeid);
-
-/* Callback for nodes joining/leaving */
-typedef void (*cman_confchgcallback_t)(cman_handle_t handle, void *privdata,
- unsigned int *member_list, int member_list_entries,
- unsigned int *left_list, int left_list_entries,
- unsigned int *joined_list, int joined_list_entries);
-
-/*
- * cman_init returns the handle you need to pass to the other API calls.
- * cman_admin_init opens admin socket for privileged operations.
- * cman_finish destroys that handle.
- *
- * Note that admin sockets can't send data messages or receive callbacks.
- */
-cman_handle_t cman_init(void *privdata);
-cman_handle_t cman_admin_init(void *privdata);
-int cman_finish(cman_handle_t handle);
-
-/* Update/retrieve the private data */
-int cman_setprivdata(cman_handle_t h, void *privdata);
-int cman_getprivdata(cman_handle_t h, void **privdata);
-
-/*
- * Notification of membership change events. Note that these are sent after
- * a transition, so multiple nodes may have left or joined the cluster.
- */
-int cman_start_notification(cman_handle_t handle, cman_callback_t callback);
-int cman_stop_notification(cman_handle_t handle);
-
-/*
- * Start/stop AIS-style confchg callbacks. These are less racy than the
- * old cman callbacks in that the caller will get one for each AIS
- * confchg message and it will contain all of the nodes that joined &
- * left in that transition.
- */
-int cman_start_confchg(cman_handle_t handle, cman_confchgcallback_t callback);
-int cman_stop_confchg(cman_handle_t handle);
-
-/* Call this if you get a TRY_SHUTDOWN event to signal whether you
- * will let cman shutdown or not.
- * Note that getting this callback does not mean that cman WILL shutdown,
- * only that it might. To detect a cman shutdown see cman_dispatch() below.
- */
-int cman_replyto_shutdown(cman_handle_t, int yesno);
-
-
-/*
- * Get the internal CMAN fd so you can pass it into poll() or select().
- * When it's active then call cman_dispatch() on the handle to process the event
- * NOTE: This fd can change between calls to cman_dispatch() so always call this
- * routine to get the latest one. (This is mainly due to message caching).
- * One upshot of this is that you must never read or write this FD (it may on
- * occasion point to /dev/zero if you have messages cached!)
- */
-int cman_get_fd(cman_handle_t handle);
-
-/*
- * cman_dispatch() will return -1 with errno == EHOSTDOWN if the cluster is
- * shut down, 0 if nothing was read, or a positive number if something was
- * dispatched.
- */
-
-int cman_dispatch(cman_handle_t handle, int flags);
-
-
-/*
- * -----------------------------------------------------------------------------
- * Get info calls.
- */
-
-/* Return the number of nodes we know about. This will normally
- * be the number of nodes in CCS
- */
-int cman_get_node_count(cman_handle_t handle);
-
-/* Returns the number of connected clients. This isn't as useful as a it used to
- * be as a count >1 does not automatically mean cman won't shut down. Subsystems
- * can decide for themselves whether a clean shutdown is possible.
- */
-int cman_get_subsys_count(cman_handle_t handle);
-
-/* Returns an array of node info structures. Call cman_get_node_count() first
- * to determine how big your array needs to be
- */
-int cman_get_nodes(cman_handle_t handle, int maxnodes, int *retnodes, cman_node_t *nodes);
-
-/* Returns a list of nodes that are known to AIS but blocked from joining the
- * CMAN cluster because they rejoined with cluster without a cman_tool join
- */
-int cman_get_disallowed_nodes(cman_handle_t handle, int maxnodes, int *retnodes, cman_node_t *nodes);
-
-/*
- * cman_get_node() can get node info by nodeid OR by name. If the first
- * char of node->cn_name is zero then the nodeid will be used, otherwise
- * the name will be used. I'll say this differently: If you want to look
- * up a node by nodeid, you MUST clear out the cman_node_t structure passed
- * into cman_get_node(). nodeid can be CMAN_NODEID_US.
- */
-int cman_get_node(cman_handle_t handle, int nodeid, cman_node_t *node);
-
-/*
- * This always gets info by nodeid.
- */
-int cman_get_node_extra(cman_handle_t handle, int nodeid, cman_node_extra_t *node);
-
-/* cman_get_node() only returns the first address of a node (whatever /that/
- * may mean). If you want to know all of them you need to call this.
- * max_addrs is the size of the 'addrs' array. num_addrs will be filled in by
- * the number of addresses the node has, regardless of the size of max_addrs.
- * So if you don't allocate enough space for the first call, you should know how
- * much is needed for a second!
- */
-int cman_get_node_addrs(cman_handle_t handle, int nodeid, int max_addrs, int *num_addrs, struct cman_node_address *addrs);
-
-/* Returns 1 if cman has completed initialisation and aisexec is running */
-int cman_is_active(cman_handle_t handle);
-
-/*
- * Returns 1 if a client is registered for data callbacks on a particular
- * port on a particular node. if cman returns -1 (errno==EBUSY) then it
- * doesn't currently know the status but has requested it, so try again
- * later or wait for a PORTOPENED notification.
- * nodeid can be CMAN_NODEID_US
- */
-int cman_is_listening(cman_handle_t handle, int nodeid, uint8_t port);
-
-/* Do we have quorum? */
-int cman_is_quorate(cman_handle_t handle);
-
-/* Return software & config (cluster.conf file) version */
-int cman_get_version(cman_handle_t handle, cman_version_t *version);
-
-/* Get cluster name and number */
-int cman_get_cluster(cman_handle_t handle, cman_cluster_t *clinfo);
-
-/*
- * These two fencing-related API calls are DEPRECATED from cluster3.
- * libfenced should be used instead.
- */
-int cman_get_fenceinfo(cman_handle_t handle, int nodeid, uint64_t *fence_time, int *fenced, char *agent);
-int cman_node_fenced(cman_handle_t handle, int nodeid, uint64_t fence_time, char *agent);
-
-
-
-/* Get stuff for cman_tool. Nobody else should use this */
-int cman_get_extra_info(cman_handle_t handle, cman_extra_info_t *info, int maxlen);
-
-/*
- * -----------------------------------------------------------------------------
- * Admin functions. You will need privileges and have a handle created by
- * cman_admin_init() to use them.
- */
-
-/* Change the config file version. This should be needed much less now, as
- * cman will re-read the config file if a new node joins with a new config
- * version */
-int cman_set_version(cman_handle_t handle, const cman_version_t *version);
-
-/* Deprecated in favour of cman_shutdown(). Use cman_tool anyway please. */
-int cman_leave_cluster(cman_handle_t handle, int reason);
-
-/* Change the number of votes for this node. NOTE: a CCS update will
- overwrite this, so make sure you change both. Or, better, change CCS
- and call set_version() */
-int cman_set_votes(cman_handle_t handle, int votes, int nodeid);
-
-/* As above, for expected_votes */
-int cman_set_expected_votes(cman_handle_t handle, int expected_votes);
-
-/* Tell a particular node to leave the cluster NOW */
-int cman_kill_node(cman_handle_t handle, int nodeid);
-
-/*
- * cman_shutdown() will send a REASON_TRY_SHUTDOWN event to all
- * clients registered for notifications. They should respond by calling
- * cman_replyto_shutdown() to indicate whether they will allow
- * cman to close down or not. If cman gets >=1 "no" (0) replies or the
- * request times out (default 5 seconds) then shutdown will be
- * cancelled and cman_shutdown() will return -1 with errno == EBUSY.
- *
- * Set flags to CMAN_SHUTDOWN_ANYWAY to force shutdown. Clients will still
- * be notified /and/ they will know you want a forced shutdown.
- *
- * Setting flags to CMAN_SHUTDOWN_REMOVED will tell the rest of the
- * cluster to adjust quorum to keep running with this node has left
- */
-int cman_shutdown(cman_handle_t, int flags);
-
-/* -----------------------------------------------------------------------------
- * Data transmission API. Uses the same FD as the rest of the calls.
- * If the nodeid passed to cman_send_data() is zero then it will be
- * broadcast to all nodes in the cluster.
- * cman_start_recv_data() is like a bind(), and marks the port
- * as "listening". See cman_is_listening() above.
- */
-int cman_send_data(cman_handle_t handle, const void *buf, int len, int flags, uint8_t port, int nodeid);
-int cman_start_recv_data(cman_handle_t handle, cman_datacallback_t, uint8_t port);
-int cman_end_recv_data(cman_handle_t handle);
-
-/*
- * Barrier API.
- * Here for backwards compatibility. Most of the things you would achieve
- * with this can now be better done using openAIS services or just messaging.
- */
-int cman_barrier_register(cman_handle_t handle, const char *name, int flags, int nodes);
-int cman_barrier_change(cman_handle_t handle, const char *name, int flags, int arg);
-int cman_barrier_wait(cman_handle_t handle, const char *name);
-int cman_barrier_delete(cman_handle_t handle, const char *name);
-
-/*
- * Add your own quorum device here, needs an admin socket
- *
- * register_quorum and update_quorum arguments are mandatory.
- * name has to be a valid null-terminated string and votes >= 0.
- *
- * After creating a quorum device you will need to call 'poll_quorum_device'
- * at least once every (default) 10 seconds (this can be changed in CCS)
- * otherwise it will time-out and the cluster will lose its vote.
- */
-int cman_register_quorum_device(cman_handle_t handle, char *name, int votes);
-int cman_unregister_quorum_device(cman_handle_t handle);
-int cman_poll_quorum_device(cman_handle_t handle, int isavailable);
-int cman_get_quorum_device(cman_handle_t handle, struct cman_qdev_info *info);
-int cman_update_quorum_device(cman_handle_t handle, char *name, int votes);
-
-/*
- * Sets the dirty bit inside cman. This indicates that the node has
- * some internal 'state' (eg in a daemon, filesystem or lock manager)
- * and cannot merge with another cluster that already has state.
- * This needs an admin socket. It cannot be reset.
- */
-int cman_set_dirty(cman_handle_t handle);
-
-
-/*
- * Changes the debug logging level inside cman.
- * subsystems is a bitmask of:
- */
-#define CMAN_DEBUGLOG_NONE 0
-#define CMAN_DEBUGLOG_BARRIER 2
-#define CMAN_DEBUGLOG_MEMBERSHIP 4
-#define CMAN_DEBUGLOG_DAEMON 8
-#define CMAN_DEBUGLOG_AIS 16
-
-int cman_set_debuglog(cman_handle_t handle, int subsystems);
-
-#endif
diff --git a/cman/lib/libcman.pc.in b/cman/lib/libcman.pc.in
deleted file mode 100644
index 6084efd..0000000
--- a/cman/lib/libcman.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@PREFIX@
-exec_prefix=${prefix}
-libdir=@LIBDIR@
-includedir=@INCDIR@
-
-Name: libcman
-Version: @VERSION@
-Description: Cluster Manager library
-Requires:
-Libs: -L${libdir} -lcman
-Cflags: -I${includedir}
diff --git a/cman/man/Makefile b/cman/man/Makefile
deleted file mode 100644
index f7fbebf..0000000
--- a/cman/man/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-MANTARGET= \
- cman.5 \
- qdisk.5 \
- cman_tool.8 \
- qdiskd.8 \
- mkqdisk.8 \
- cmannotifyd.8 \
- cman_notify.8 \
- checkquorum.8
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-all:
-
-clean:
diff --git a/cman/man/checkquorum.8 b/cman/man/checkquorum.8
deleted file mode 100644
index 96f61f0..0000000
--- a/cman/man/checkquorum.8
+++ /dev/null
@@ -1,29 +0,0 @@
-.TH "checkquorum" "8" "February 2011" "" "Check Quorum Watchdog Script"
-.SH "NAME"
-checkquorum \- Check Quorum Watchdog Script
-.SH "SYNOPSIS"
-\fBcheckquorum
-.SH "DESCRIPTION"
-.PP
-The \fBcheckquorum\fP watchdog script, when copied to the
-.IR /etc/watchdog.d
-directory and after enabling/starting the watchdog daemon causes the node to reboot if quorum is
-lost and not regained within a user configurable amount of time (default: 60 seconds).
-.SH "OPTIONS"
-The checkquorum script includes several options which can be set by editing
-the script with a text editor.
-.TP
-.BR $wait_time
-Amount of time in seconds to wait after quorum is lost before trigger a reboot
-(Default: 60 seconds).
-.TP
-.BR $hardreboot
-Instantly reboot the machine without cleanly shutting down the system.
-Useful when the machine may hang on reboot. Set to 1 to hard reboot the
-system, 0 to do a normal reboot.
-.SH "NOTES"
-\fBcheckquorum\fP should never be called outside of watchdog except for
-debugging purposes.
-
-.SH "SEE ALSO"
-watchdog(8)
diff --git a/cman/man/cman.5 b/cman/man/cman.5
deleted file mode 100644
index 0311412..0000000
--- a/cman/man/cman.5
+++ /dev/null
@@ -1,211 +0,0 @@
-.\" groff -t -e -mandoc -Tlatin1 cman.5 | less
-
-.TH "cman" "5" "" "" "cluster.conf cman configuration section"
-
-.SH "NAME"
-cman \- cluster.conf cman configuration section
-
-.SH "DESCRIPTION"
-
-.in +7
-Cman configuration values are placed in the <cman> </cman> section of
-\fBcluster.conf\fP. Per-node configuration related to cman is placed
-in the standard <clusternode> </clusternode> sections. All cman
-configuration settings are optional; usually none are used. The <cman>
-section is placed under the <cluster> section in cluster.conf.
-
- <cluster>
- <cman>
- </cman>
- ...
- </cluster>
-.in -7
-
-
-\fIUDP port\fR
-.in +7
-By default, cman will use UDP port 5405/5404 for internode communication. This can
-be changed by setting a port number as follows:
-
- <cman port="6809">
- </cman>
-
-This will cause cman to use ports 6809 and 6808 for cluster communications.
-
-.in -7
-
-
-\fIExpected votes\fR
-.in +7
-The expected votes value is used by cman to determine quorum. The cluster is
-quorate if the sum of votes of existing members is over half of the expected
-votes value. By default, cman sets the expected votes value to be the sum
-of votes of all nodes listed in cluster.conf. This can be overridden by setting
-an explicit expected_votes value as follows:
-
- <cman expected_votes="3">
- </cman>
-
-If the cluster becomes partitioned, improper use of this option can result
-in more than one partition gaining quorum. In that event, nodes in each
-partition will enable cluster services.
-.in -7
-
-
-\fITwo node clusters\fR
-.in +7
-Ordinarily, the loss of quorum after one out of two nodes fails will prevent
-the remaining node from continuing (if both nodes have one vote.) Special
-configuration options can be set to allow the one remaining node to continue
-operating if the other fails. To do this only two nodes, each with one vote,
-can be defined in cluster.conf. The two_node and expected_votes values must
-then be set to 1 in the cman section as follows.
-
- <cman two_node="1" expected_votes="1">
- </cman>
-.in -7
-
-
-\fINode votes\fR
-.in +7
-By default, a node is given one vote toward the calculation of quorum.
-This can be changed by giving a node a specific number of votes as
-follows:
-
- <clusternode name="nd1" votes="2">
- </clusternode>
-.in -7
-
-
-\fINode ID\fR
-.in +7
-
-All nodes must have a unique node ID. This is a single integer that identifies
-it to the cluster.
-A node's application to join the cluster may be rejected if you try to set
-the nodeid to one that is already used.
-
- <clusternode name="nd1" nodeid="1">
- </clusternode>
-
-.in -7
-\fIMulti-home configuration\fR
-.in +7
-It is quite common to use multiple ethernet adapters for cluster nodes, so
-they will tolerate the failure of one link. A common way to do this is to use
-ethernet bonding. Alternatively you can get corosync to run in redundant ring
-mode by specifying an 'altname' for the node. This is an alternative name by
-which the node is known, that resolves to another IP address used on the
-other ethernet adapter(s). You can optionally specify a different port and/or
-multicast address for each altname in use. Only one altname (2 interfaces
-in total) is valid for each node.
-
-Note that if you are using the DLM with cman/corosync then you MUST tell it
-to use SCTP as it's communications protocol as TCP does not support multihoming.
-
- <clusternode name="nd1" nodeid="1">
- <altname name="nd1a" port="6809" mcast="239.192.0.2"/>
- </clusternode>
-
- <dlm protocol="sctp"/>
-.in -7
-
-
-\fIMulticast network configuration\fR
-.in +7
-cman uses multicast UDP packets to communicate with other nodes in the cluster.
-By default it will generate a multicast address using 239.192.x.x where x.x is
-the 16bit cluster ID number split into bytes. This, in turn is generated from a
-hash of the cluster name though it can be specified explicitly. The purpose
-of this is to allow multiple clusters to share the same subnet - they will each
-use a different multicast address. You might also/instead want to isolate
-clusters using the port number as shown above.
-
-It is possible to override the multicast address by specifying it in cluster.conf
-as shown:
-
- <cman>
- <multicast addr="239.192.0.1"/>
- </cman>
-
-.in -7
-
-\fICluster ID\fR
-.in +7
-The cluster ID number is used to isolate clusters in the same subnet. Usually it
-is generated from a hash of the cluster name, but it can be overridden here if
-you feel the need. Sometimes cluster names can hash to the same ID.
-
- <cman cluster_id="669">
- </cman>
-
-.in -7
-
-\fIcorosync security key\fR
-.in +7
-All traffic sent out by cman/corosync is encrypted. By default the security key
-used is simply the cluster name. If you need more security you can specify a
-key file that contains the key used to encrypt cluster communications.
-Of course, the contents of the key file must be the same on all nodes in the
-cluster. It is up to you to securely copy the file to the nodes.
-
- <cman keyfile="/etc/cluster/corosync.key">
- </cman>
-
-Note that this only applies to cluster communication. The DLM does not encrypt
-traffic.
-.in -7
-
-
-\fIOther corosync parameters\fR
-.in +7
-When corosync is started by cman (cman_tool runs corosync), the corosync.conf
-file is not used. Many of the configuration parameters listed in
-corosync.conf can be set in cluster.conf instead. Cman will read
-corosync parameters from the following sections in cluster.conf and load
-them into corosync:
-
- <cluster>
- <totem />
- <event />
- <aisexec />
- <group />
- </cluster>
-
-See the
-.B corosync.conf(5)
-man page for more information on keys that are valid for these sections.
-Note that settings in the <clusternodes> section will override settings in
-the sections above, and options on the cman_tool command line will
-override both. In particular, settings like bindnetaddr, mcastaddr,
-mcastport and nodeid will always be replaced by values in <clusternodes>.
-
-Cman uses different defaults for some of the corosync parameters listed in
-corosync.conf(5). If you wish to use a non-default setting, they can be
-configured in cluster.conf as shown above. Cman uses the following
-default values:
-
- <totem
- vsftype="none"
- token="10000"
- token_retransmits_before_loss_const="20"
- join="60"
- consensus="4800"
- rrp_mode="none"
- <!-- or rrp_mode="active" if altname is present >
- />
- <aisexec user="root" group="root" />
-
-Here's how to set the token timeout to five seconds:
-
- <totem token="5000"/>
-
-.in -7
-
-
-.sp
-
-.SH "SEE ALSO"
-
-cluster.conf(5), corosync.conf(5), cman_tool(8)
-
diff --git a/cman/man/cman_notify.8 b/cman/man/cman_notify.8
deleted file mode 100644
index 446bf12..0000000
--- a/cman/man/cman_notify.8
+++ /dev/null
@@ -1,17 +0,0 @@
-.TH "cman_notify" "8" "November 2008" "" "CMAN Notification Daemon"
-.SH "NAME"
-cman_notify \- CMAN Notification Daemon run-part alike script
-.SH "SYNOPSIS"
-\fBcman_notify
-.SH "DESCRIPTION"
-.PP
-The \fBcmannotifyd\fP daemon talks to CMAN and provides a mechanism to notify
-external entities about cluster changes.
-\fBcman_notify\fP script is in charge to execute all notification scripts
-in a run-part alike way.
-.SH "NOTES"
-\fBcman_notify\fP should never be called standalone except for debugging
-purposes.
-
-.SH "SEE ALSO"
-cmannotifyd(8)
diff --git a/cman/man/cman_tool.8 b/cman/man/cman_tool.8
deleted file mode 100644
index 2f402a6..0000000
--- a/cman/man/cman_tool.8
+++ /dev/null
@@ -1,442 +0,0 @@
-.TH CMAN_TOOL 8 "Nov 8 2007" "Cluster utilities"
-
-.SH NAME
-cman_tool \- Cluster Management Tool
-.SH SYNOPSIS
-.B cman_tool join | leave | kill | expected | votes | version | wait | status | nodes | services | debug [options]
-.br
-.SH DESCRIPTION
-.PP
-.B cman_tool
-is a program that manages the cluster management subsystem CMAN. cman_tool
-can be used to join the node to a cluster, leave the cluster, kill another
-cluster node or change the value of expected votes of a cluster.
-.br
-Be careful that you understand the consequences of the commands issued via cman_tool
-as they can affect all nodes in your cluster. Most of the time the cman_tool
-will only be invoked from your startup and shutdown scripts.
-.br
-.SH SUBCOMMANDS
-.TP
-.I join
-This is the main use of cman_tool. It instructs the cluster manager to attempt
-to join an existing cluster or (if no existing cluster exists) then to form
-a new one on its own.
-.br
-If no options are given to this command then it will take the cluster
-configuration information from cluster.conf. However, it is possible to provide
-all the information on the command-line or to override cluster.conf values by using
-the command line.
-
-.TP
-.I leave
-Tells CMAN to leave the cluster. You cannot do this if there are subsystems
-(eg DLM, GFS) active. You should dismount all GFS filesystems,
-shutdown CLVM, fenced and anything else using the cluster manager before
-using
-.B cman_tool leave.
-Look at 'cman_tool status' and group_tool to see how many (and which)
-subsystems are active.
-.br
-When a node leaves the cluster, the remaining nodes recalculate quorum and this
-may block cluster activity if the required number of votes is not present.
-If this node is to be down for an extended period of time and you need to
-keep the cluster running, add the
-.B remove
-option, and the remaining nodes will recalculate quorum such that activity
-can continue.
-
-.TP
-.I kill
-Tells CMAN to kill another node in the cluster. This will cause the local
-node to send a "KILL" message to that node and it will shut down. Recovery
-will occur for the killed node as if it had failed. This is a sort of remote
-version of "leave force" so only use if if you really know what you are doing.
-
-.TP
-.I expected
-Tells CMAN a new value of expected votes and instructs it to recalculate
-quorum based on this value.
-.br
-The recalculation takes into account the number of currently
-active nodes, so this option should not be used in an attempt to
-artificially lower the quorum value in advance of a planned shutdown of
-cluster nodes. Instead, the 'cman_tool leave remove' command should be
-used (see the 'leave' subcommand above).
-.br
-Use this option if your cluster has lost quorum due to nodes failing and
-you need to get it running again in a hurry.
-
-.TP
-.I version
-Used alone this will report the major, minor, patch and config versions
-used by CMAN (also displayed in 'cman_tool status'). It can also be used
-with -r to tell cluster members to update the cluster configuration.
-.br
-If -r is specified, cman will read the configuration file,
-validate it, distribute it around the cluster (if necessary) an
-activate it. See the VERSION OPTIONS section below for additional
-options to the \fBversion\fP command.
-
-.TP
-.I wait
-Waits until the node is a member of the cluster and then returns.
-
-.TP
-.I status
-Displays the local view of the cluster status.
-
-.TP
-.I nodes
-Displays the local view of the cluster nodes.
-
-.TP
-.I services
-Displays the local view of subsystems using cman (deprecated, group_tool
-should be used instead).
-
-.TP
-.I debug
-Sets the debug level of the running cman daemon. Debug output will be
-sent to syslog level LOG_DEBUG. the
-.B -d
-switch specifies the new logging level. This is the same bitmask used
-for cman_tool join -d
-.br
-.SH "LEAVE" OPTIONS
-.TP
-.I -w
-Normally, "cman_tool leave" will fail if the cluster is in transition (ie
-another node is joining or leaving the cluster). By adding the -w flag,
-cman_tool will wait and retry the leave operation repeatedly until it succeeds
-or a more serious error occurs.
-.TP
-.I -t <seconds>
-If -w is also specified then -t dictates the maximum amount of time cman_tool
-is prepared to wait. If the operation times out then a status of 2 is returned.
-.TP
-.I force
-Shuts down the cluster manager without first telling any of the subsystems
-to close down. Use this option with extreme care as it could easily cause data
-loss.
-.TP
-.I remove
-Tells the rest of the cluster to recalculate quorum such that activity can
-continue without this node.
-
-.SH "EXPECTED" OPTIONS
-.TP
-.I -e <expected-votes>
-The new value of expected votes to use. This will usually be enough
-to bring the cluster back to life. Values that would cause incorrect
-quorum will be rejected.
-
-.SH "KILL" OPTIONS
-.TP
-.I -n <nodename>
-The node name of the node to be killed. This should be the unqualified node
-name as it appears in 'cman_tool nodes'.
-
-.SH "VERSION" OPTIONS
-.TP
-.I -r
-Update config version. You don't need to use this when adding a new node,
-the new cman node will tell the rest of the cluster to read the latest
-version of the config file automatically. The version present in the
-new configuration must be higher than the one currently in use by cman.
-.br
-
-cman_tool version on its own will always show the current version
-and not the one being looked for. So be aware that the display
-will possibly not update immediately after you have run
-cman_tool version -r.
-.TP
-.I -D<option>
-see "JOIN" options
-.TP
-.I -S
-By default cman_tool version will try to distribute the new cluster.conf
-file using ccs_sync and ricci. If you have distributed the file yourself
-and/or do not have ricci installed then the -S option will skip this step.
-NOTE: it is still important that all nodes in the cluster have the
-same version of the file. Make sure that this is the case before using
-this option.
-.SH "WAIT" OPTIONS
-.TP
-.I -q
-Waits until the cluster is quorate before returning.
-.I -t <seconds>
-Dictates the maximum amount of time cman_tool is prepared to wait.
-If the operation times out then a status of 2 is returned.
-
-.br
-.SH "JOIN" OPTIONS
-.TP
-.I -c <clustername>
-Provides a text name for the cluster. You can have several clusters on one
-LAN and they are distinguished by this name. Note that the name is hashed to
-provide a unique number which is what actually distinguishes the cluster, so
-it is possible that two different names can clash. If this happens, the node
-will not be allowed into the existing cluster and you will have to pick
-another name or use different port number for cluster communication.
-.TP
-.I -p <port>
-UDP port number used for cluster communication. This defaults to 5405.
-.TP
-.I -v <votes>
-Number of votes this node has in the cluster. Defaults to 1.
-.TP
-.I -e <expected votes>
-Number of expected votes for the whole cluster. If different nodes
-provide different values then the highest is used. The cluster will
-only operate when quorum is reached - that is more than half the
-available votes are available to the cluster. The default for
-this value is the total number of votes for all nodes in the configuration file.
-.TP
-.I -2
-Sets the cluster up for a special "two node only" mode. Because of the
-quorum requirements mentioned above, a two-node cluster cannot be valid.
-This option tells the cluster manager that there will only ever be two
-nodes in the cluster and relies on fencing to ensure cluster integrity.
-If you specify this you cannot add more nodes without taking down the
-existing cluster and reconfiguring it. Expected votes should be set to
-1 for a two-node cluster.
-.TP
-.I -n <nodename>
-Overrides the node name. By default the unqualified hostname is used. This
-option is also used to specify which interface is used for cluster
-communication.
-.TP
-.I -N <nodeid>
-Overrides the node ID for this node. Normally, nodes are assigned a
-node id in cluster.conf. If you specify an incorrect node ID here, the
-node might not be allowed to join the cluster. Setting node IDs in the
-configuration is a far better way to do this.
-.BR
-Note that the node's application to join the cluster may be rejected if you
-try to set the nodeid to one that has already been used, or if the node
-was previously a member of the cluster but with a different nodeid.
-.TP
-.I -o <nodename>
-Override the name this node will have in the cluster. This will
-normally be the hostname or the first name specified by -n.
-Note how this differs from -n: -n tells cman_tool how to find
-the host address and/or the entry in the configuration file. -o simply
-changes the name the node will have in the cluster and has no
-bearing on the actual name of the machine. Use this option
-will extreme caution.
-.BR
-.TP
-.I -m <multicast-address>
-Specifies a multicast address to use for cluster communication. This
-is required for IPv6 operation. You should also specify an ethernet
-interface to bind to this multicast address using the -i option.
-.TP
-.I -w
-Join and wait until the node is a cluster member.
-.TP
-.I -q
-Join and wait until the cluster is quorate.
-If the cluster join fails and -w (or -q) is specified, then it will be retried. Note that
-cman_tool cannot tell whether the cluster join was rejected by another node for a good reason
-or that it timed out for some benign reason; so it is strongly recommended that a timeout
-is also given with the wait options to join. If you don't want join to retry on failure but
-do want to wait, use the
-.B cman_tool join
-command without -w followed by
-.B cman_tool wait.
-.TP
-.I -k <keyfile>
-All traffic sent out by cman/corosync is encrypted. By default the security key
-used is simply the cluster name. If you need more security you can specify a
-key file that contains the key used to encrypt cluster communications.
-Of course, the contents of the key file must be the same on all nodes in the
-cluster. It is up to you to securely copy the file to the nodes.
-.TP
-.I -t <seconds>
-If -w or -q is also specified then -t dictates the maximum amount of time cman_tool
-is prepared to wait. If the operation times out then a status of 2 is returned.
-Note that just because cman_tool has given up, does not mean that cman itself
-has stopped trying to join a cluster.
-.TP
-.I -X
-Tells cman not to use the configuration file to get cluster information. If you use this option then cman will
-apply several defaults to the cluster to get it going. The cluster name will be
-"RHCluster", node IDs will default to the IP address of the node and remote node
-names will show up as Node<nodeid>. All of these, apart from the node names can
-be overridden on the cman_tool command-line if required.
-.br
-If you have to set up fence devices, services or anything else in cluster.conf then
-this option is probably not worthwhile to you - the extra readability of sensible node
-names and numbers will make it worth using cluster.conf for the cluster too. But for a simple
-failover cluster this might save you some effort.
-.br
-On each node using this configuration you will need to have the same authorization key
-installed. To create this key run
-.br
-corosync-keygen
-.br
-mv /etc/ais/authkey /etc/cluster/cman_authkey
-.br
-then copy that file to all nodes you want to join the cluster.
-.br
-.TP
-.I -C
-Overrides the default configuration module. Usually cman uses xmlconfig (cluster.conf) to load its
-configuration. If you have your configuration database held elsewhere (eg LDAP) and
-have a configuration plugin for it, then you should specify the name of the module
-(see the documentation for the module for the name of it - it's not necessarily the
-same as the filename) here.
-.br
-It is possible to chain configuration modules by separating them with colons. So to
-add two modules (eg) 'ldapconfig' and 'ldappreproc' to the chain start cman with
--C ldapconfig:ldappreproc
-.br
-The default value for this is 'xmlconfig'. Note that if the -X is on the command-line
-then -C will be ignored.
-.TP
-.I -A
-Don't load openais services. Normally cman_tool join will load the configuration
-module 'openaisserviceenablestable' which will load the services installed by openais.
-If you don't want to use these services or have not installed openais then
-this switch will disable them.
-.TP
-.I -D
-Tells cman_tool whether to validate the configuration before loading or reloading it.
-By default the configuration
-.B is
-validated, which is equivalent to -Dfail.
-.br
--Dwarn will validate the configuration and print any messages arising, but will attempt
-to use it regardless of its validity.
-.br
--Dnone (or just -D) will skip the validation completely.
-.br
-The -D switch does not take a space between -D and the parameter. so '-D fail' will cause
-an error. Use -Dfail.
-.SH "NODES" OPTIONS
-.TP
-.I -a
-Shows the IP address(es) the nodes are communicating on.
-.br
-.TP
-.I -n <nodename>
-Shows node information for a specific node. This should be the unqualified node
-name as it appears in 'cman_tool nodes'.
-.br
-.TP
-.I -F <format>
-Specify the format of the output. The format string may contain one or
-more format options, each separated by a comma. Valid format options
-include: id, name, type, and addr.
-.br
-.SH "DEBUG" OPTIONS
-.TP
-.I -d<value>
-The value is a bitmask of
-.br
-2 Barriers
-.br
-4 Membership messages
-.br
-8 Daemon operation, including command-line interaction
-.br
-16 Interaction with Corosync
-.br
-32 Startup debugging (cman_tool join operations only)
-.br
-.SH NOTES
-.br
-the
-.B nodes
-subcommand shows a list of nodes known to cman. the state is one of the following:
-.br
-M The node is a member of the cluster
-.br
-X The node is not a member of the cluster
-.br
-d The node is known to the cluster but disallowed access to it.
-.br
-.SH ENVIRONMENT VARIABLES
-cman_tool removes most environment variables before forking and running Corosync, as well as adding some of its own for setting up
-configuration parameters that were overridden on the command-line, the exception to this is that variable with names starting
-COROSYNC_ will be passed down intact as they are assumed to be used for configuring the daemon.
-
-.SH DISALLOWED NODES
-Occasionally (but very infrequently I hope) you may see nodes marked as "Disallowed" in cman_tool status or "d" in cman_tool nodes. This is a bit of a nasty hack to get around mismatch between what the upper layers expect of the cluster manager and corosync.
-.TP
-If a node experiences a momentary lack of connectivity, but one that is long enough to trigger the token timeouts, then it will be removed from the cluster. When connectivity is restored corosync will happily let it rejoin the cluster with no fuss. Sadly the upper layers don't like this very much. They may (indeed probably will have) have changed their internal state while the other node was away and there is no straightforward way to bring the rejoined node up-to-date with that state. When this happens the node is marked "Disallowed" and is not permitted to take part in cman operations.
-.P
-If the remainder of the cluster is quorate the the node will be sent a kill message and it will be forced to leave the cluster that way. Note that fencing should kick in to remove the node permanently anyway, but it may take longer than the network outage for this to complete.
-
-If the remainder of the cluster is inquorate then we have a problem. The likelihood is that we will have two (or more) partitioned clusters and we cannot decide which is the "right" one. In this case we need to defer to the system administrator to kill an appropriate selection of nodes to restore the cluster to sensible operation.
-
-The latter scenario should be very rare and may indicate a bug somewhere in the code. If the local network is very flaky or busy it may be necessary to increase some of the protocol timeouts for corosync. We are trying to think of better solutions to this problem.
-
-Recovering from this state can, unfortunately, be complicated. Fortunately, in the majority of cases, fencing will do the job for you, and the disallowed state will only be temporary. If it persists, the recommended approach it is to do a cman tool nodes on all systems in the cluster and determine the largest common subset of nodes that are valid members to each other. Then reboot the others and let them rejoin correctly. In the case of a single-node disconnection this should be straightforward, with a large cluster that has experienced a network partition it could get very complicated!
-
-Example:
-
-In this example we have a five node cluster that has experienced a network partition. Here is the output of cman_tool nodes from all systems:
-.nf
-Node Sts Inc Joined Name
- 1 M 2372 2007-11-05 02:58:55 node-01.example.com
- 2 d 2376 2007-11-05 02:58:56 node-02.example.com
- 3 d 2376 2007-11-05 02:58:56 node-03.example.com
- 4 M 2376 2007-11-05 02:58:56 node-04.example.com
- 5 M 2376 2007-11-05 02:58:56 node-05.example.com
-
-Node Sts Inc Joined Name
- 1 d 2372 2007-11-05 02:58:55 node-01.example.com
- 2 M 2376 2007-11-05 02:58:56 node-02.example.com
- 3 M 2376 2007-11-05 02:58:56 node-03.example.com
- 4 d 2376 2007-11-05 02:58:56 node-04.example.com
- 5 d 2376 2007-11-05 02:58:56 node-05.example.com
-
-Node Sts Inc Joined Name
- 1 d 2372 2007-11-05 02:58:55 node-01.example.com
- 2 M 2376 2007-11-05 02:58:56 node-02.example.com
- 3 M 2376 2007-11-05 02:58:56 node-03.example.com
- 4 d 2376 2007-11-05 02:58:56 node-04.example.com
- 5 d 2376 2007-11-05 02:58:56 node-05.example.com
-
-Node Sts Inc Joined Name
- 1 M 2372 2007-11-05 02:58:55 node-01.example.com
- 2 d 2376 2007-11-05 02:58:56 node-02.example.com
- 3 d 2376 2007-11-05 02:58:56 node-03.example.com
- 4 M 2376 2007-11-05 02:58:56 node-04.example.com
- 5 M 2376 2007-11-05 02:58:56 node-05.example.com
-
-Node Sts Inc Joined Name
- 1 M 2372 2007-11-05 02:58:55 node-01.example.com
- 2 d 2376 2007-11-05 02:58:56 node-02.example.com
- 3 d 2376 2007-11-05 02:58:56 node-03.example.com
- 4 M 2376 2007-11-05 02:58:56 node-04.example.com
- 5 M 2376 2007-11-05 02:58:56 node-05.example.com
-.fi
-In this scenario we should kill the node node-02 and node-03. Of course, the 3 node cluster of node-01, node-04 & node-05 should remain quorate and be able to fenced the two rejoined nodes anyway, but it is possible that the cluster has a qdisk setup that precludes this.
-
-.SH CONFIGURATION SYSTEMS
-This section details how the configuration systems work in cman. You might need to know this if you are using the -C option
-to cman_tool, or writing your own configuration subsystem.
-.br
-By default cman uses two configuration plugins to corosync. The first, 'xmlconfig', reads the configuration information
-stored in cluster.conf and stores it in an internal database, in the same schema as it finds in cluster.conf.
-The second plugin, 'cmanpreconfig', takes the information in that the database, adds several cman defaults, determines
-the corosync node name and nodeID
-and formats the information in a similar manner to corosync.conf(5). Corosync then reads those keys to start the cluster protocol.
-cmanpreconfig also reads several environment variables that might be set by cman_tool which can override information in the
-configuration.
-.br
-In the absence of xmlconfig, ie when 'cman_tool join' is run with -X switch (this removes xmlconfig from the module list),
-cmanpreconfig also generates several defaults so that the cluster can be got running without any configuration information - see above
-for the details.
-.br
-Note that cmanpreconfig will not overwrite corosync keys that are explicitly set in the configuration file, allowing you to provide
-custom values for token timeouts etc, even though cman has its own defaults for some of those values. The exception to this is the node
-name/address and multicast values, which are always taken from the cman configuration keys.
-.br
-Most of the extra keys that cmanpreconfig adds are outside of the /cluster/ tree and will only be seen if you dump the whole of
-corosync's object database. However it does add some keys into /cluster/cman that you would not normally see in a normal cluster.conf
-file. These are harmless, though could be confusing. The most obvious of these is the "nodename" option which is passed from
-cmanpreconfig to the name cman module, to save it recalculating the node name again.
diff --git a/cman/man/cmannotifyd.8 b/cman/man/cmannotifyd.8
deleted file mode 100644
index 56ad353..0000000
--- a/cman/man/cmannotifyd.8
+++ /dev/null
@@ -1,66 +0,0 @@
-.TH "cmannotifyd" "8" "November 2008" "" "CMAN Notification Daemon"
-.SH "NAME"
-cmannotifyd \- CMAN Notification Daemon
-.SH "SYNOPSIS"
-\fBcmannotifyd [\-f] [\-d]
-.SH "DESCRIPTION"
-.PP
-The \fBcmannotifyd\fP daemon talks to CMAN and provides a mechanism to notify
-external entities about cluster changes.
-
-CMAN dispatches 3 kind of notifications:
-
-\- CMAN_REASON_TRY_SHUTDOWN when cman requests to all clients if it is allowed
-to shutdown.
-
-\- CMAN_REASON_STATECHANGE when cman detects a node joining or leaving the
-cluster.
-
-\- CMAN_REASON_CONFIG_UPDATE when a configuration change event has been
-detected/requested.
-
-These notifications are then dispatched to the shell script
-.B cman_notify
-in the environment variable CMAN_NOTIFICATION.
-
-.B cman_notify
-will then execute all the scripts in the configured notification
-directory (default: /etc/cluster/cman-notify.d) passing a very minimal set of
-envvars including, of course, the CMAN_NOTIFICATION= type.
-The execution order is set by the filename as shown by "LC_ALL=C ls -las".
-
-.B cmannotifyd
-logs are stored in the default log file
-(/var/log/cluster/cmannotifyd.log).
-
-.B cman_notify
-logs are stored in the default log file
-(/var/log/cluster/cman_notify.log). By default the output from the scripts
-executed by
-.B cman_notify
-is redirected to /dev/null.
-Users can either set CMAN_NOTIFICATION_DEBUG=1 in their environment or
-set proper debug configuration in cluster.conf to redirect scripts output
-to the cman_notify log file.
-
-.SH "NOTES"
-cmannotifyd does not block on cman_notify nor check the exit
-status of the script.
-
-Notifications are dispatched in the same order as they
-arrive, one by one.
-
-CMAN_REASON_TRY_SHUTDOWN is passed to scripts for information only, they
-can not influence cman's decsion about whether or not to shut down.
-
-CMAN_REASON_STATECHANGE also implies CMAN_NOTIFICATION_QUORUM exported
-in the environment. CMAN_NOTIFICATION_QUORUM will be set to 1 (when the node
-is part of a quorate cluster) or 0 (otherwise).
-
-A template for cman_notify scripts can be found in the doc/ directory.
-
-.SH "OPTIONS"
-.IP "\-f"
-Run in the foreground (do not fork / daemonize).
-.IP "\-d"
-Enable debug output.
diff --git a/cman/man/mkqdisk.8 b/cman/man/mkqdisk.8
deleted file mode 100644
index a097680..0000000
--- a/cman/man/mkqdisk.8
+++ /dev/null
@@ -1,31 +0,0 @@
-.TH "mkqdisk" "8" "July 2006" "" "Quorum Disk Management"
-.SH "NAME"
-mkqdisk \- Cluster Quorum Disk Utility
-.SH "WARNING"
-Use of this command can cause the cluster to malfunction.
-.SH "SYNOPSIS"
-\fBmkqdisk [\-?|\-h] | [\-L] | [\-f \fPlabel\fB] [\-c \fPdevice \fB -l \fPlabel\fB] [-d [-d ...]]
-.SH "DESCRIPTION"
-.PP
-The \fBmkqdisk\fP command is used to create a new quorum disk or display
-existing quorum disks accessible from a given cluster node.
-.SH "OPTIONS"
-.IP "\-c device \-l label"
-Initialize a new cluster quorum disk. This will destroy all data on the given
-device. If a cluster is currently using that device as a quorum disk, the
-entire cluster will malfunction. Do not run this on an active cluster when
-qdiskd is running. Only one device on the SAN should ever have the given
-label; using multiple different devices is currently not supported (it is
-expected a RAID array is used for quorum disk redundancy). The label can be
-any textual string up to 127 characters - and is therefore enough space to hold
-a UUID created with uuidgen(1).
-.IP "\-f label"
-Find the cluster quorum disk with the given label and display information about it.
-.IP "\-L"
-Display information on all accessible cluster quorum disks.
-.IP "\-d"
-Increase debugging level. Specify multiple times for more information.
-Currently, specifying more than twice has no effect.
-
-.SH "SEE ALSO"
-qdisk(5), qdiskd(8), uuidgen(1)
diff --git a/cman/man/qdisk.5 b/cman/man/qdisk.5
deleted file mode 100644
index 938ed69..0000000
--- a/cman/man/qdisk.5
+++ /dev/null
@@ -1,530 +0,0 @@
-.TH "QDisk" "5" "12 Oct 2011" "" "Cluster Quorum Disk"
-.SH "NAME"
-qdisk \- a disk-based quorum daemon for CMAN / Linux-Cluster
-.SH "1. Overview"
-.SH "1.1 Problem"
-In some situations, it may be necessary or desirable to sustain
-a majority node failure of a cluster without introducing the need for
-asymmetric cluster configurations (e.g. client-server, or heavily-weighted
-voting nodes).
-
-.SH "1.2. Design Requirements"
-* Ability to sustain 1..(n-1)/n simultaneous node failures, without the
-danger of a simple network partition causing a split brain. That is, we
-need to be able to ensure that the majority failure case is not merely
-the result of a network partition.
-
-* Ability to use external reasons for deciding which partition is the
-the quorate partition in a partitioned cluster. For example, a user may
-have a service running on one node, and that node must always be the master
-in the event of a network partition. Or, a node might lose all network
-connectivity except the cluster communication path - in which case, a
-user may wish that node to be evicted from the cluster.
-
-* Integration with CMAN. We must not require CMAN to run with us (or
-without us). Linux-Cluster does not require a quorum disk normally -
-introducing new requirements on the base of how Linux-Cluster operates
-is not allowed.
-
-* Data integrity. In order to recover from a majority failure, fencing
-is required. The fencing subsystem is already provided by Linux-Cluster.
-
-* Non-reliance on hardware or protocol specific methods (i.e. SCSI
-reservations). This ensures the quorum disk algorithm can be used on the
-widest range of hardware configurations possible.
-
-* Little or no memory allocation after initialization. In critical paths
-during failover, we do not want to have to worry about being killed during
-a memory pressure situation because we request a page fault, and the Linux
-OOM killer responds...
-
-.SH "1.3. Hardware Considerations and Requirements"
-.SH "1.3.1. Concurrent, Synchronous, Read/Write Access"
-This quorum daemon requires a shared block device with concurrent read/write
-access from all nodes in the cluster. The shared block device can be
-a multi-port SCSI RAID array, a Fiber-Channel RAID SAN, a RAIDed iSCSI
-target, or even GNBD. The quorum daemon uses O_DIRECT to write to the
-device.
-
-.SH "1.3.2. Bargain-basement JBODs need not apply"
-There is a minimum performance requirement inherent when using disk-based
-cluster quorum algorithms, so design your cluster accordingly. Using a
-cheap JBOD with old SCSI2 disks on a multi-initiator bus will cause
-problems at the first load spike. Plan your loads accordingly; a node's
-inability to write to the quorum disk in a timely manner will cause the
-cluster to evict the node. Using host-RAID or multi-initiator parallel
-SCSI configurations with the qdisk daemon is unlikely to work, and will
-probably cause administrators a lot of frustration. That having been
-said, because the timeouts are configurable, most hardware should work
-if the timeouts are set high enough.
-
-.SH "1.3.3. Fencing is Required"
-In order to maintain data integrity under all failure scenarios, use of
-this quorum daemon requires adequate fencing, preferably power-based
-fencing. Watchdog timers and software-based solutions to reboot the node
-internally, while possibly sufficient, are not considered 'fencing' for
-the purposes of using the quorum disk.
-
-.SH "1.4. Limitations"
-* At this time, this daemon supports a maximum of 16 nodes. This is
-primarily a scalability issue: As we increase the node count, we increase
-the amount of synchronous I/O contention on the shared quorum disk.
-
-* Cluster node IDs must be statically configured in cluster.conf and
-must be numbered from 1..16 (there can be gaps, of course).
-
-* Cluster node votes must all be 1.
-
-* CMAN must be running before the qdisk program can operate in full
-capacity. If CMAN is not running, qdisk will wait for it.
-
-* CMAN's eviction timeout should be at least 2x the quorum daemon's
-to give the quorum daemon adequate time to converge on a master during a
-failure + load spike situation. See section 3.3.1 for specific
-details.
-
-* For 'all-but-one' failure operation, the total number of votes assigned
-to the quorum device should be equal to or greater than the total number
-of node-votes in the cluster. While it is possible to assign only one
-(or a few) votes to the quorum device, the effects of doing so have not
-been explored.
-
-* For 'tiebreaker' operation in a two-node cluster, unset CMAN's two_node
-flag (or set it to 0), set CMAN's expected votes to '3', set each node's
-vote to '1', and leave qdisk's vote count unset. This will allow
-the cluster to operate if either both nodes are online, or a single node &
-the heuristics.
-
-* Currently, the quorum disk daemon is difficult to use with CLVM if
-the quorum disk resides on a CLVM logical volume. CLVM requires a
-quorate cluster to correctly operate, which introduces a chicken-and-egg
-problem for starting the cluster: CLVM needs quorum, but the quorum daemon
-needs CLVM (if and only if the quorum device lies on CLVM-managed storage).
-One way to work around this is to *not* set the cluster's expected votes
-to include the quorum daemon's votes. Bring all nodes online, and start
-the quorum daemon *after* the whole cluster is running. This will allow
-the expected votes to increase naturally.
-
-.SH "2. Algorithms"
-.SH "2.1. Heartbeating & Liveliness Determination"
-Nodes update individual status blocks on the quorum disk at a user-
-defined rate. Each write of a status block alters the timestamp, which
-is what other nodes use to decide whether a node has hung or not. If,
-after a user-defined number of 'misses' (that is, failure to update a
-timestamp), a node is declared offline. After a certain number of 'hits'
-(changed timestamp + "i am alive" state), the node is declared online.
-
-The status block contains additional information, such as a bitmask of
-the nodes that node believes are online. Some of this information is
-used by the master - while some is just for performance recording, and
-may be used at a later time. The most important pieces of information
-a node writes to its status block are:
-
-.in 12
-- Timestamp
-.br
-- Internal state (available / not available)
-.br
-- Score
-.br
-- Known max score (may be used in the future to detect invalid configurations)
-.br
-- Vote/bid messages
-.br
-- Other nodes it thinks are online
-.in 0
-
-.SH "2.2. Scoring & Heuristics"
-The administrator can configure up to 10 purely arbitrary heuristics, and
-must exercise caution in doing so. At least one administrator-
-defined heuristic is required for operation, but it is generally a good
-idea to have more than one heuristic. By default, only nodes scoring over
-1/2 of the total maximum score will claim they are available via the
-quorum disk, and a node (master or otherwise) whose score drops too low
-will remove itself (usually, by rebooting).
-
-The heuristics themselves can be any command executable by 'sh -c'. For
-example, in early testing the following was used:
-
-.ti 12
-<\fBheuristic \fP\fIprogram\fP\fB="\fP[ -f /quorum ]\fB" \fP\fIscore\fP\fB="\fP10\fB" \fP\fIinterval\fP\fB="\fP2\fB"/>\fP
-
-This is a literal sh-ism which tests for the existence of a file called
-"/quorum". Without that file, the node would claim it was unavailable.
-This is an awful example, and should never, ever be used in production,
-but is provided as an example as to what one could do...
-
-Typically, the heuristics should be snippets of shell code or commands which
-help determine a node's usefulness to the cluster or clients. Ideally, you
-want to add traces for all of your network paths (e.g. check links, or
-ping routers), and methods to detect availability of shared storage.
-
-.SH "2.3. Master Election"
-Only one master is present at any one time in the cluster, regardless of
-how many partitions exist within the cluster itself. The master is
-elected by a simple voting scheme in which the lowest node which believes
-it is capable of running (i.e. scores high enough) bids for master status.
-If the other nodes agree, it becomes the master. This algorithm is
-run whenever no master is present.
-
-If another node comes online with a lower node ID while a node is still
-bidding for master status, it will rescind its bid and vote for the lower
-node ID. If a master dies or a bidding node dies, the voting algorithm
-is started over. The voting algorithm typically takes two passes to
-complete.
-
-Master deaths take marginally longer to recover from than non-master
-deaths, because a new master must be elected before the old master can
-be evicted & fenced.
-
-.SH "2.4. Master Duties"
-The master node decides who is or is not in the master partition, as
-well as handles eviction of dead nodes (both via the quorum disk and via
-the linux-cluster fencing system by using the cman_kill_node() API).
-
-.SH "2.5. How it All Ties Together"
-When a master is present, and if the master believes a node to be online,
-that node will advertise to CMAN that the quorum disk is available. The
-master will only grant a node membership if:
-
-.in 12
-(a) CMAN believes the node to be online, and
-.bi
-(b) that node has made enough consecutive, timely writes
-.in 16
-to the quorum disk, and
-.in 12
-(c) the node has a high enough score to consider itself online.
-.in 0
-
-.SH "3. Configuration"
-.SH "3.1. The <quorumd> tag"
-This tag is a child of the top-level <cluster> tag.
-
-.in 8
-\fB<quorumd\fP
-.in 9
-\fIinterval\fP\fB="\fP1\fB"\fP
-.in 12
-This is the frequency of read/write cycles, in seconds.
-
-.in 9
-\fItko\fP\fB="\fP10\fB"\fP
-.in 12
-This is the number of cycles a node must miss in order to be declared dead.
-The default for this number is dependent on the configured token timeout.
-
-.in 9
-\fItko_up\fP\fB="\fPX\fB"\fP
-.in 12
-This is the number of cycles a node must be seen in order to be declared
-online. Default is \fBfloor(tko/3)\fP.
-
-.in 9
-\fIupgrade_wait\fP\fB="\fP2\fB"\fP
-.in 12
-This is the number of cycles a node must wait before initiating a bid
-for master status after heuristic scoring becomes sufficient. The
-default is 2. This can not be set to 0, and should not exceed \fBtko\fP.
-
-.in 9
-\fImaster_wait\fP\fB="\fPX\fB"\fP
-.in 12
-This is the number of cycles a node must wait for votes before declaring
-itself master after making a bid. Default is \fBfloor(tko/2)\fP.
-This can not be less than 2, must be greater than tko_up, and should not
-exceed \fBtko\fP.
-
-.in 9
-\fIvotes\fP\fB="\fP3\fB"\fP
-.in 12
-This is the number of votes the quorum daemon advertises to CMAN when it
-has a high enough score. The default is the number of nodes in the cluster
-minus 1. For example, in a 4 node cluster, the default is 3. This value
-may change during normal operation, for example when adding or removing
-a node from the cluster.
-
-.in 9
-\fIlog_level\fP\fB="\fP4\fB"\fP
-.in 12
-This controls the verbosity of the quorum daemon in the system logs.
-0 = emergencies; 7 = debug. This option is deprecated.
-
-.in 9
-\fIlog_facility\fP\fB="\fPdaemon\fB"\fP
-.in 12
-This controls the syslog facility used by the quorum daemon when logging.
-For a complete list of available facilities, see \fBsyslog.conf(5)\fP.
-The default value for this is 'daemon'. This option is deprecated.
-
-.in 9
-\fIstatus_file\fP\fB="\fP/foo\fB"\fP
-.in 12
-Write internal states out to this file periodically ("-" = use stdout).
-This is primarily used for debugging. The default value for this
-attribute is undefined. This option can be changed while qdiskd is
-running.
-
-.in 9
-\fImin_score\fP\fB="\fP3\fB"\fP
-.in 12
-Absolute minimum score to be consider one's self "alive". If omitted,
-or set to 0, the default function "floor((n+1)/2)" is used, where \fIn\fP
-is the total of all of defined heuristics' \fIscore\fP attribute. This
-must never exceed the sum of the heuristic scores, or else the quorum
-disk will never be available.
-
-.in 9
-\fIreboot\fP\fB="\fP1\fB"\fP
-.in 12
-If set to 0 (off), qdiskd will *not* reboot after a negative transition
-as a result in a change in score (see section 2.2). The default for
-this value is 1 (on). This option can be changed while qdiskd is
-running.
-
-.in 9
-\fImaster_wins\fP\fB="\fP0\fB"\fP
-.in 12
-If set to 1 (on), only the qdiskd master will advertise its votes
-to CMAN. In a network partition, only the qdisk master will provide
-votes to CMAN. Consequently, that node will automatically "win" in
-a fence race.
-
-This option requires careful tuning of the CMAN timeout, the qdiskd
-timeout, and CMAN's quorum_dev_poll value. As a rule of thumb,
-CMAN's quorum_dev_poll value should be equal to Totem's token timeout
-and qdiskd's timeout (interval*tko) should be less than half of
-Totem's token timeout. See section 3.3.1 for more information.
-
-This option only takes effect if there are no heuristics
-configured and it is valid only for 2 node cluster.
-This option is automatically disabled if heuristics are
-defined or cluster has more than 2 nodes configured.
-
-In a two-node cluster with no heuristics and no defined vote
-count (see above), this mode is turned by default. If enabled in
-this way at startup and a node is later added to the cluster
-configuration or the vote count is set to a value other than 1, this
-mode will be disabled.
-
-.in 9
-\fIallow_kill\fP\fB="\fP1\fB"\fP
-.in 12
-If set to 0 (off), qdiskd will *not* instruct to kill nodes it thinks
-are dead (as a result of not writing to the quorum disk). The default
-for this value is 1 (on). This option can be changed while qdiskd
-is running.
-
-.in 9
-\fIparanoid\fP\fB="\fP0\fB"\fP
-.in 12
-If set to 1 (on), qdiskd will watch internal timers and reboot the node
-if it takes more than (interval * tko) seconds to complete a quorum disk
-pass. The default for this value is 0 (off). This option can be changed
-while qdiskd is running.
-
-.in 9
-\fIio_timeout\fP\fB="\fP0\fB"\fP
-.in 12
-If set to 1 (on), qdiskd will watch internal timers and reboot the node
-if qdisk is not able to write to disk after (interval * tko) seconds.
-The default for this value is 0 (off). If io_timeout is active
-max_error_cycles is overridden and set to off.
-
-.in 9
-\fIscheduler\fP\fB="\fPrr\fB"\fP
-.in 12
-Valid values are 'rr', 'fifo', and 'other'. Selects the scheduling queue
-in the Linux kernel for operation of the main & score threads (does not
-affect the heuristics; they are always run in the 'other' queue). Default
-is 'rr'. See sched_setscheduler(2) for more details.
-
-.in 9
-\fIpriority\fP\fB="\fP1\fB"\fP
-.in 12
-Valid values for 'rr' and 'fifo' are 1..100 inclusive. Valid values
-for 'other' are -20..20 inclusive. Sets the priority of the main & score
-threads. The default value is 1 (in the RR and FIFO queues, higher numbers
-denote higher priority; in OTHER, lower values denote higher priority).
-This option can be changed while qdiskd is running.
-
-.in 9
-\fIstop_cman\fP\fB="\fP0\fB"\fP
-.in 12
-Ordinarily, cluster membership is left up to CMAN, not qdisk.
-If this parameter is set to 1 (on), qdiskd will tell CMAN to leave the
-cluster if it is unable to initialize the quorum disk during startup. This
-can be used to prevent cluster participation by a node which has been
-disconnected from the SAN. The default for this value is 0 (off).
-This option can be changed while qdiskd is running.
-
-.in 9
-\fIuse_uptime\fP\fB="\fP1\fB"\fP
-.in 12
-If this parameter is set to 1 (on), qdiskd will use values from
-/proc/uptime for internal timings. This is a bit less precise
-than \fBgettimeofday(2)\fP, but the benefit is that changing the
-system clock will not affect qdiskd's behavior - even if \fBparanoid\fP
-is enabled. If set to 0, qdiskd will use \fBgettimeofday(2)\fP, which
-is more precise. The default for this value is 1 (on / use uptime).
-
-.in 9
-\fIdevice\fP\fB="\fP/dev/sda1\fB"\fP
-.in 12
-This is the device the quorum daemon will use. This device must be the
-same on all nodes.
-
-.in 9
-\fIlabel\fP\fB="\fPmylabel\fB"\fP
-.in 12
-This overrides the device field if present. If specified, the quorum
-daemon will read /proc/partitions and check for qdisk signatures
-on every block device found, comparing the label against the specified
-label. This is useful in configurations where the block device name
-differs on a per-node basis.
-
-.in 9
-\fIcman_label\fP\fB="\fPmylabel\fB"\fP
-.in 12
-This overrides the label advertised to CMAN if present. If specified,
-the quorum daemon will register with this name instead of the actual
-device name.
-
-.in 9
-\fImax_error_cycles\fP\fB="\fP0\fB"/>\fP
-.in 12
-If we receive an I/O error during a cycle, we do not poll CMAN and tell
-it we are alive. If specified, this value will cause qdiskd to exit
-after the specified number of consecutive cycles during which I/O errors
-occur. The default is 0 (no maximum). This option can be changed while
-qdiskd is running. This option is ignored if io_timeout is set to 1.
-
-.in 8
-\fB/>\fP
-.in 0
-
-.SH "3.3.1. Quorum Disk Timings"
-Qdiskd should not be used in environments requiring failure detection
-times of less than approximately 10 seconds.
-
-Qdiskd will attempt to automatically configure timings based on the
-totem timeout and the TKO. If configuring manually, Totem's token
-timeout \fBmust\fP be set to a value at least 1 interval greater than
-the the following function:
-
- interval * (tko + master_wait + upgrade_wait)
-
-So, if you have an interval of 2, a tko of 7, master_wait of 2 and
-upgrade_wait of 2, the token timeout should be at least 24 seconds
-(24000 msec).
-
-It is recommended to have at least 3 intervals to reduce the risk of
-quorum loss during heavy I/O load. As a rule of thumb, using a totem
-timeout more than 2x of qdiskd's timeout will result in good behavior.
-
-An improper timing configuration will cause CMAN to give up on qdiskd,
-causing a temporary loss of quorum during master transition.
-
-.SH "3.2. The <heuristic> tag"
-This tag is a child of the <quorumd> tag. Heuristics may not be changed
-while qdiskd is running.
-
-.in 8
-\fB<heuristic\fP
-.in 9
-\fIprogram\fP\fB="\fP/test.sh\fB"\fP
-.in 12
-This is the program used to determine if this heuristic is alive. This
-can be anything which may be executed by \fI/bin/sh -c\fP. A return
-value of zero indicates success; anything else indicates failure. This
-is required.
-
-.in 9
-\fIscore\fP\fB="\fP1\fB"\fP
-.in 12
-This is the weight of this heuristic. Be careful when determining scores
-for heuristics. The default score for each heuristic is 1.
-
-.in 9
-\fIinterval\fP\fB="\fP2\fB"\fP
-.in 12
-This is the frequency (in seconds) at which we poll the heuristic. The
-default interval is determined by the qdiskd timeout.
-.in 0
-
-.in 9
-\fItko\fP\fB="\fP1\fB"\fP
-.in 12
-After this many failed attempts to run the heuristic, it is considered DOWN,
-and its score is removed. The default tko for each heuristic is determined
-by the qdiskd timeout.
-.in 8
-\fB/>\fP
-.in 0
-
-
-.SH "3.3. Examples"
-.SH "3.3.1. 3 cluster nodes & 3 routers"
-.in 8
-<cman expected_votes="6" .../>
-.br
-<clusternodes>
-.in 12
-<clusternode name="node1" votes="1" ... />
-.br
-<clusternode name="node2" votes="1" ... />
-.br
-<clusternode name="node3" votes="1" ... />
-.in 8
-</clusternodes>
-.br
-<quorumd interval="1" tko="10" votes="3" label="testing">
-.in 12
-<heuristic program="ping A -c1 -w1" score="1" interval="2" tko="3"/>
-.br
-<heuristic program="ping B -c1 -w1" score="1" interval="2" tko="3"/>
-.br
-<heuristic program="ping C -c1 -w1" score="1" interval="2" tko="3"/>
-.br
-.in 8
-</quorumd>
-
-.SH "3.3.2. 2 cluster nodes & 1 IP tiebreaker"
-.in 8
-<cman two_node="0" expected_votes="3" .../>
-.br
-<clusternodes>
-.in 12
-<clusternode name="node1" votes="1" ... />
-.br
-<clusternode name="node2" votes="1" ... />
-.in 8
-</clusternodes>
-.br
-<quorumd interval="1" tko="10" votes="1" label="testing">
-.in 12
-<heuristic program="ping A -c1 -w1" score="1" interval="2" tko="3"/>
-.br
-.in 8
-</quorumd>
-.in 0
-
-
-.SH "3.4. Heuristic score considerations"
-* Heuristic timeouts should be set high enough to allow the previous run
-of a given heuristic to complete.
-
-* Heuristic scripts returning anything except 0 as their return code
-are considered failed.
-
-* The worst-case for improperly configured quorum heuristics is a race
-to fence where two partitions simultaneously try to kill each other.
-
-.SH "3.5. Creating a quorum disk partition"
-The mkqdisk utility can create and list currently configured quorum disks
-visible to the local node; see
-.B mkqdisk(8)
-for more details.
-
-.SH "SEE ALSO"
-mkqdisk(8), qdiskd(8), cman(5), syslog.conf(5), gettimeofday(2)
diff --git a/cman/man/qdiskd.8 b/cman/man/qdiskd.8
deleted file mode 100644
index 21bccbf..0000000
--- a/cman/man/qdiskd.8
+++ /dev/null
@@ -1,25 +0,0 @@
-.TH "qdiskd" "8" "July 2006" "" "Quorum Disk Management"
-.SH "NAME"
-qdiskd \- Cluster Quorum Disk Daemon
-.SH "SYNOPSIS"
-\fBqdiskd [\-f] [\-d]
-.SH "DESCRIPTION"
-.PP
-The \fBqdiskd\fP daemon talks to CMAN and provides a mechanism for determining
-node-fitness in a cluster environment. See
-.B
-qdisk(5)
-for configuration information.
-.SH "OPTIONS"
-.IP "\-f"
-Run in the foreground (do not fork / daemonize).
-.IP "\-d"
-Enable debug output.
-.IP "\-Q"
-Close stdin/out/err immediately before doing validations. This
-is primarily for use when being called from an init script. Using
-this option will stop all output, and can not be used with the -d
-option.
-
-.SH "SEE ALSO"
-mkqdisk(8), qdisk(5), cman(5)
diff --git a/cman/notifyd/Makefile b/cman/notifyd/Makefile
deleted file mode 100644
index 5676fe3..0000000
--- a/cman/notifyd/Makefile
+++ /dev/null
@@ -1,37 +0,0 @@
-TARGET1= cmannotifyd
-TARGET2= cman_notify
-
-SBINDIRT=${TARGET1} ${TARGET2}
-
-all: depends ${TARGET1} ${TARGET2}
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -D_GNU_SOURCE -DSBINDIR=\"${sbindir}\"
-CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${logtincdir}
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${cmanlibdir} -L${ccslibdir} -L${logtlibdir} -lcman -lccs -llogthread
-LDFLAGS += -L${libdir}
-
-OBJS1= main.o
-
-${TARGET1}: ${OBJS1}
- $(CC) -o $@ $^ $(LDFLAGS)
-
-${TARGET2}: $(S)/${TARGET2}.in
- cat $(S)/${TARGET2}.in | sed \
- -e 's#@NOTIFYDDIR@#${notifyddir}#g' \
- -e 's#@LOGDIR@#${logdir}#g' \
- > ${TARGET2}
-
-depends:
- $(MAKE) -C ../lib all
-
-clean: generalclean
-
--include $(OBJS1:.o=.Tpo)
diff --git a/cman/notifyd/cman_notify.in b/cman/notifyd/cman_notify.in
deleted file mode 100644
index 9e05bc0..0000000
--- a/cman/notifyd/cman_notify.in
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-
-# concept from Debian run-parts and similar from fedora crontabs
-
-# keep going when something fails
-set +e
-
-if [ ! -d "@NOTIFYDDIR@" ]; then
- exit 0
-fi
-
-LOGFILE="@LOGDIR@/cman_notify.log"
-
-if [ "$CMAN_NOTIFICATION_DEBUG" = "1" ]; then
- OUT="$LOGFILE"
-fi
-
-# Ignore *~ and *, scripts
-for i in $(LC_ALL=C; echo @NOTIFYDDIR@/*[^~,]); do
- [ -d $i ] && continue
- # skip know scripts
- [ "${i%.cfsaved}" != "${i}" ] && continue
- [ "${i%.rpmsave}" != "${i}" ] && continue
- [ "${i%.rpmorig}" != "${i}" ] && continue
- [ "${i%.rpmnew}" != "${i}" ] && continue
- [ "${i%.swp}" != "${i}" ] && continue
- [ "${i%,v}" != "${i}" ] && continue
- [ "${i%.dpkg-old}" != "${i}" ] && continue
- [ "${i%.dpkg-dist}" != "${i}" ] && continue
- [ "${i%.dpkg-new}" != "${i}" ] && continue
-
- if [ -x $i ]; then
- echo "starting $(basename $i)" >> $LOGFILE
- [ -n "$OUT" ] && $i >> $OUT
- [ -z "$OUT" ] && $i > /dev/null 2>&1
- echo "finished $(basename $i)" >> $LOGFILE
- fi
-done
-
-exit 0
diff --git a/cman/notifyd/main.c b/cman/notifyd/main.c
deleted file mode 100644
index 4a9f868..0000000
--- a/cman/notifyd/main.c
+++ /dev/null
@@ -1,430 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <limits.h>
-#include <sched.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/select.h>
-
-#include <libcman.h>
-#include <ccs.h>
-#include <liblogthread.h>
-
-#include "copyright.cf"
-
-int debug = 0;
-int daemonize = 1;
-int daemon_quit = 0;
-cman_handle_t cman_handle;
-int rr = 0;
-
-#define LOCKFILE_NAME "/var/run/cmannotifyd.pid"
-
-#define OPTION_STRING "hdfVr"
-
-#ifndef MAX_ARGS
-#define MAX_ARGS 128
-#endif
-
-static void print_usage(void)
-{
- printf("Usage:\n\n");
- printf("cmannotifyd [options]\n\n");
- printf("Options:\n\n");
- printf(" -f Do not fork in background\n");
- printf(" -d Enable debugging output\n");
- printf(" -r Run Real Time priority\n");
- printf(" -h This help\n");
- printf(" -V Print program version information\n");
- return;
-}
-
-static void read_arguments(int argc, char **argv)
-{
- int cont = 1;
- int optchar;
-
- while (cont) {
- optchar = getopt(argc, argv, OPTION_STRING);
-
- switch (optchar) {
-
- case 'd':
- debug = 1;
- break;
-
- case 'f':
- daemonize = 0;
- break;
-
- case 'r':
- rr = 1;
- break;
-
- case 'h':
- print_usage();
- exit(EXIT_SUCCESS);
- break;
-
- case 'V':
- printf("cmannotifyd %s (built %s %s)\n%s\n",
- RELEASE_VERSION, __DATE__, __TIME__,
- REDHAT_COPYRIGHT);
- exit(EXIT_SUCCESS);
- break;
-
- case EOF:
- cont = 0;
- break;
-
- default:
- fprintf(stderr, "unknown option: %c\n", optchar);
- print_usage();
- exit(EXIT_FAILURE);
- break;
-
- }
-
- }
-
- if (getenv("CMANNOTIFYD_DEBUG"))
- debug = 1;
-
-}
-
-static void remove_lockfile(void)
-{
- unlink(LOCKFILE_NAME);
-}
-
-static void lockfile(void)
-{
- int fd, error;
- struct flock lock;
- char buf[128];
-
- memset(buf, 0, 128);
-
- fd = open(LOCKFILE_NAME, O_CREAT | O_WRONLY,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (fd < 0) {
- fprintf(stderr, "cannot open/create lock file %s\n",
- LOCKFILE_NAME);
- exit(EXIT_FAILURE);
- }
-
- lock.l_type = F_WRLCK;
- lock.l_start = 0;
- lock.l_whence = SEEK_SET;
- lock.l_len = 0;
-
- error = fcntl(fd, F_SETLK, &lock);
- if (error) {
- fprintf(stderr, "cmannotifyd is already running\n");
- exit(EXIT_FAILURE);
- }
-
- error = ftruncate(fd, 0);
- if (error) {
- fprintf(stderr, "cannot clear lock file %s\n", LOCKFILE_NAME);
- exit(EXIT_FAILURE);
- }
-
- snprintf(buf, sizeof(buf) - 1, "%d\n", getpid());
-
- error = write(fd, buf, strlen(buf));
- if (error <= 0) {
- fprintf(stderr, "cannot write lock file %s\n", LOCKFILE_NAME);
- exit(EXIT_FAILURE);
- }
-
- atexit(remove_lockfile);
-}
-
-static void sigterm_handler(int sig)
-{
- daemon_quit = 1;
-}
-
-static void set_scheduler(void)
-{
- struct sched_param sched_param;
- int rv;
-
- rv = sched_get_priority_max(SCHED_RR);
- if (rv != -1) {
- sched_param.sched_priority = rv;
- rv = sched_setscheduler(0, SCHED_RR, &sched_param);
- if (rv == -1)
- logt_print(LOG_WARNING,
- "could not set SCHED_RR priority %d err %d",
- sched_param.sched_priority, errno);
- } else {
- logt_print(LOG_WARNING,
- "could not get maximum scheduler priority err %d",
- errno);
- }
-}
-
-static void init_logging(int reconf)
-{
- int ccs_handle;
- int mode = LOG_MODE_OUTPUT_FILE | LOG_MODE_OUTPUT_SYSLOG;
- int syslog_facility = SYSLOGFACILITY;
- int syslog_priority = SYSLOGLEVEL;
- char logfile[PATH_MAX];
- int logfile_priority = SYSLOGLEVEL;
-
- memset(logfile, 0, PATH_MAX);
- snprintf(logfile, sizeof(logfile) - 1, LOGDIR "/cmannotifyd.log");
-
- ccs_handle = ccs_connect();
- if (ccs_handle > 0) {
- ccs_read_logging(ccs_handle, "cmannotifyd", &debug, &mode,
- &syslog_facility, &syslog_priority, &logfile_priority, logfile);
- ccs_disconnect(ccs_handle);
- } else {
- if (debug) {
- logfile_priority = LOG_DEBUG;
- }
- }
-
- if (!daemonize)
- mode |= LOG_MODE_OUTPUT_STDERR;
-
- if (!reconf)
- logt_init("cmannotifyd", mode, syslog_facility, syslog_priority, logfile_priority, logfile);
- else
- logt_conf("cmannotifyd", mode, syslog_facility, syslog_priority, logfile_priority, logfile);
-}
-
-static void dispatch_notification(const char *str, int *quorum)
-{
- char *envp[MAX_ARGS];
- char *argv[MAX_ARGS];
- int envptr = 0;
- int argvptr = 0;
- char scratch[PATH_MAX];
- pid_t notify_pid, pid;
- int pidstatus;
- int err = 0;
-
- if (!str)
- return;
-
- /* pass notification type */
- snprintf(scratch, sizeof(scratch), "CMAN_NOTIFICATION=%s", str);
- envp[envptr++] = strdup(scratch);
-
- if (quorum) {
- snprintf(scratch, sizeof(scratch), "CMAN_NOTIFICATION_QUORUM=%d", *quorum);
- envp[envptr++] = strdup(scratch);
- }
-
- if (debug)
- envp[envptr++] = strdup("CMAN_NOTIFICATION_DEBUG=1");
-
- envp[envptr--] = NULL;
-
- argv[argvptr++] = strdup("cman_notify");
-
- argv[argvptr--] = NULL;
-
- switch ( (notify_pid = fork()) )
- {
- case -1:
- /* unable to fork */
- err = 1;
- goto out;
- break;
-
- case 0: /* child */
- execve(SBINDIR "/cman_notify", argv, envp);
- /* unable to execute cman_notify */
- err = 1;
- goto out;
- break;
-
- default: /* parent */
- pid = waitpid(notify_pid, &pidstatus, 0);
- if (pid < 0)
- logt_print(LOG_ERR, "Error waiting for " SBINDIR "/cman_notify execution\n");
-
- break;
- }
-
-out:
- while(envptr >= 0) {
- if (envp[envptr])
- free(envp[envptr]);
-
- envptr--;
- }
- while(argvptr >= 0) {
- if (argv[argvptr])
- free(argv[argvptr]);
-
- argvptr--;
- }
- if (err)
- exit(EXIT_FAILURE);
-}
-
-static void cman_callback(cman_handle_t ch, void *private, int reason, int arg)
-{
- const char *str = NULL;
-
- switch (reason) {
- case CMAN_REASON_TRY_SHUTDOWN:
- logt_print(LOG_DEBUG, "Received a cman shutdown request\n");
- cman_replyto_shutdown(ch, 1); /* allow cman to shutdown */
- str = "CMAN_REASON_TRY_SHUTDOWN";
- dispatch_notification(str, 0);
- break;
- case CMAN_REASON_STATECHANGE:
- logt_print(LOG_DEBUG,
- "Received a cman statechange notification\n");
- str = "CMAN_REASON_STATECHANGE";
- dispatch_notification(str, &arg);
- break;
- case CMAN_REASON_CONFIG_UPDATE:
- logt_print(LOG_DEBUG,
- "Received a cman config update notification\n");
- init_logging(1);
- str = "CMAN_REASON_CONFIG_UPDATE";
- dispatch_notification(str, 0);
- break;
- }
-}
-
-static void byebye_cman(void)
-{
- if (!cman_handle)
- return;
-
- cman_finish(cman_handle);
- cman_handle = NULL;
-}
-
-static void setup_cman(int forever)
-{
- int init = 0, active = 0;
- int quorate;
- const char *str = NULL;
-
-retry_init:
- cman_handle = cman_init(NULL);
- if (!cman_handle) {
- if ((init++ < 5) || (forever)) {
- if (daemon_quit)
- goto out;
-
- sleep(1);
- goto retry_init;
- }
- logt_print(LOG_CRIT, "cman_init error %d\n", errno);
- exit(EXIT_FAILURE);
- }
-
-retry_active:
- if (!cman_is_active(cman_handle)) {
- if ((active++ < 5) || (forever)) {
- if (daemon_quit)
- goto out;
-
- sleep(1);
- goto retry_active;
- }
- logt_print(LOG_CRIT, "cman_is_active error %d\n", errno);
- cman_finish(cman_handle);
- exit(EXIT_FAILURE);
- }
-
- if (cman_start_notification(cman_handle, cman_callback) < 0) {
- logt_print(LOG_CRIT, "cman_start_notification error %d\n", errno);
- cman_finish(cman_handle);
- exit(EXIT_FAILURE);
- }
-
- logt_print(LOG_DEBUG, "Dispatching first cluster status\n");
- init_logging(1);
- str = "CMAN_REASON_CONFIG_UPDATE";
- dispatch_notification(str, 0);
- str = "CMAN_REASON_STATECHANGE";
- quorate = cman_is_quorate(cman_handle);
- dispatch_notification(str, &quorate);
-
- return;
-
-out:
- byebye_cman();
- exit(EXIT_SUCCESS);
-}
-
-static void loop(void)
-{
- int cd_result, se_result;
- fd_set read_fds;
- int cman_fd;
-
- do {
- FD_ZERO (&read_fds);
- cman_fd = cman_get_fd(cman_handle);
- FD_SET (cman_fd, &read_fds);
- se_result = select((cman_fd + 1), &read_fds, 0, 0, 0);
-
- if (daemon_quit)
- goto out;
-
- if (se_result == -1) {
- logt_print(LOG_CRIT, "Unable to select on cman_fd: %s\n", strerror(errno));
- byebye_cman();
- exit(EXIT_FAILURE);
- }
-
- if (FD_ISSET(cman_fd, &read_fds)) {
- cd_result = 1;
- while (cd_result > 0) {
- cd_result = cman_dispatch(cman_handle, CMAN_DISPATCH_ONE);
- if (cd_result == -1 && errno == EHOSTDOWN) {
- byebye_cman();
- logt_print(LOG_DEBUG, "waiting for cman to reappear..\n");
- setup_cman(1);
- logt_print(LOG_DEBUG, "cman is back..\n");
- }
- }
- }
- } while (se_result && !daemon_quit);
-
-out:
- logt_print(LOG_DEBUG, "shutting down...\n");
- byebye_cman();
-}
-
-int main(int argc, char **argv)
-{
-
- read_arguments(argc, argv);
- if (daemonize) {
- if (daemon(0, 0) < 0) {
- perror("Unable to daemonize");
- exit(EXIT_FAILURE);
- }
- }
- lockfile();
- init_logging(0);
- signal(SIGTERM, sigterm_handler);
- if (rr)
- set_scheduler();
-
- setup_cman(0);
- loop();
-
- return 0;
-}
diff --git a/cman/qdisk/Makefile b/cman/qdisk/Makefile
deleted file mode 100644
index f39c036..0000000
--- a/cman/qdisk/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-TARGET1= qdiskd
-TARGET2= mkqdisk
-
-SBINDIRT=${TARGET1} ${TARGET2}
-
-all: depends ${TARGET1} ${TARGET2}
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -D_GNU_SOURCE
-CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${logtincdir}
-CFLAGS += -I${zlibincdir}
-CFLAGS += -I$(S)
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${logtlibdir} -llogthread -lpthread
-LDFLAGS += -L${zliblibdir} -lz -lrt
-LDFLAGS += -L${libdir}
-
-EXTRA_LDFLAGS += -L${cmanlibdir} -L${ccslibdir} -lcman -lccs
-
-OBJS1= main.o \
- score.o \
- bitmap.o \
- daemon_init.o
-
-OBJS2= mkqdisk.o
-
-SHAREDOBJS= disk.o \
- disk_util.o \
- proc.o \
- scandisk.o \
- iostate.o
-
-${TARGET1}: ${SHAREDOBJS} ${OBJS1}
- $(CC) -o $@ $^ $(EXTRA_LDFLAGS) $(LDFLAGS)
-
-${TARGET2}: ${SHAREDOBJS} ${OBJS2}
- $(CC) -o $@ $^ $(EXTRA_LDFLAGS) $(LDFLAGS)
-
-depends:
- $(MAKE) -C ../lib all
-
-clean: generalclean
-
--include $(OBJS1:.o=.Tpo)
--include $(OBJS2:.o=.Tpo)
--include $(SHAREDOBJS:.o=.Tpo)
diff --git a/cman/qdisk/bitmap.c b/cman/qdisk/bitmap.c
deleted file mode 100644
index 094ad2f..0000000
--- a/cman/qdisk/bitmap.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @file
- * Bitmap and membership mask handling routines.
- */
-#include <stdint.h>
-
-int clear_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
-int set_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
-int is_bit_set(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
-
-/**
- * Clear a bit in a bitmap / bitmask.
- *
- * @param mask Bitmask to modify.
- * @param bitidx Bit to modify.
- * @param masklen Bitmask length (in uint8_t units)
- * @return -1 if the index exceeds the number of bits in the
- * bitmap, otherwise 0.
- */
-int
-clear_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen)
-{
- uint32_t idx;
- uint32_t bit;
-
- /* Index into array */
- idx = bitidx >> 3;
- bit = 1 << (bitidx & 0x7);
-
- if (idx >= masklen)
- return -1;
-
- mask[idx] &= ~bit;
-
- return 0;
-}
-
-
-/**
- * Set a bit in a bitmap / bitmask.
- *
- * @param mask Bitmask to modify.
- * @param bitidx Bit to modify.
- * @param masklen Bitmask length (in uint8_t units).
- * @return -1 if the index exceeds the number of bits in the
- * bitmap, otherwise 0.
- */
-int
-set_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen)
-{
- uint32_t idx;
- uint32_t bit;
-
- /* Index into array */
- idx = bitidx >> 3;
- bit = 1 << (bitidx & 0x7);
-
- if (idx >= masklen)
- return -1;
-
- mask[idx] |= bit;
-
- return 0;
-}
-
-
-/**
- * Check the status of a bit in a bitmap / bitmask.
- *
- * @param mask Bitmask to check.
- * @param bitidx Bit to to check.
- * @param masklen Bitmask length (in uint8_t units).
- * @return -1 if the index exceeds the number of bits in the
- * bitmap, 0 if not set, or 1 if set.
- */
-int
-is_bit_set(uint8_t *mask, uint32_t bitidx, uint32_t masklen)
-{
- uint32_t idx;
- uint32_t bit;
-
- /* Index into array */
- idx = bitidx >> 3;
- bit = 1 << (bitidx & 0x7);
-
- if (idx >= masklen)
- return -1;
-
- return !!(mask[idx]&bit);
-}
-
-
diff --git a/cman/qdisk/daemon_init.c b/cman/qdisk/daemon_init.c
deleted file mode 100644
index 7c26f8a..0000000
--- a/cman/qdisk/daemon_init.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/** @file
- * daemon_init function, does sanity checks and calls daemon().
- *
- * Author: Jeff Moyer <jmoyer(a)redhat.com>
- */
-/*
- * TODO: Clean this up so that only one function constructs the
- * pidfile /var/run/loggerd.PID, and perhaps only one function
- * forms the /proc/PID/ path.
- *
- * Also need to add file locking for the pid file.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <sys/mman.h>
-#include <sys/errno.h>
-#include <libgen.h>
-#include <signal.h>
-#include <liblogthread.h>
-
-/*
- * This should ultimately go in a header file.
- */
-void daemon_init(char *prog);
-void daemon_cleanup(void);
-int check_process_running(char *prog, pid_t * pid);
-
-/*
- * Local prototypes.
- */
-static void update_pidfile(char *prog);
-static int setup_sigmask(void);
-static char pid_filename[PATH_MAX];
-
-static int
-check_pid_valid(pid_t pid, char *prog)
-{
- FILE *fp;
- DIR *dir;
- char filename[PATH_MAX];
- char dirpath[PATH_MAX];
- char proc_cmdline[64]; /* yank this from kernel somewhere */
- char *s = NULL;
- size_t proc_cmdline_len = 0;
-
- memset(filename, 0, PATH_MAX);
- memset(dirpath, 0, PATH_MAX);
-
- snprintf(dirpath, sizeof (dirpath) - 1, "/proc/%d", pid);
- dir = opendir(dirpath);
- if (!dir)
- return 0; /* Pid has gone away. */
- closedir(dir);
-
- /*
- * proc-pid directory exists. Now check to see if this
- * PID corresponds to the daemon we want to start.
- */
- snprintf(filename, sizeof (filename) - 1, "/proc/%d/cmdline", pid);
- fp = fopen(filename, "r");
- if (fp == NULL) {
- perror("check_pid_valid");
- return 0; /* Who cares.... Let's boogy on. */
- }
-
- if (!fgets(proc_cmdline, sizeof (proc_cmdline), fp)) {
- /*
- * Okay, we've seen processes keep a reference to a
- * /proc/PID/stat file and not let go. Then when
- * you try to read /proc/PID/cmline, you get either
- * \000 or -1. In either case, we can safely assume
- * the process has gone away.
- */
- fclose(fp);
- return 0;
- }
- fclose(fp);
-
- proc_cmdline_len = strlen(proc_cmdline);
- if (proc_cmdline_len) {
- s = &(proc_cmdline[proc_cmdline_len]);
- if (*s == '\n')
- *s = 0;
- }
-
- /*
- * Check to see if this is the same executable.
- */
- if (!strstr(proc_cmdline, prog)) {
- return 0;
- } else {
- return 1;
- }
-}
-
-
-int
-check_process_running(char *prog, pid_t * pid)
-{
- pid_t oldpid;
- FILE *fp;
- char filename[PATH_MAX];
- char *cmd;
- int ret;
- struct stat st;
-
- *pid = -1;
-
- if (!prog) {
- errno = EINVAL;
- return -1;
- }
-
- /*
- * Now see if there is a pidfile associated with this cmd in /var/run
- */
- fp = NULL;
- memset(filename, 0, PATH_MAX);
-
- cmd = basename(prog);
- if (!cmd)
- return -1;
-
- snprintf(filename, sizeof (filename) - 1, "/var/run/%s.pid", cmd);
-
- ret = stat(filename, &st);
- if ((ret < 0) || (!st.st_size))
- return 0;
-
- /*
- * Read the pid from the file.
- */
- fp = fopen(filename, "r");
- if (fp == NULL) /* error */
- return 0;
-
- ret = fscanf(fp, "%d\n", &oldpid);
- fclose(fp);
-
- if ((ret == EOF) || (ret != 1))
- return 0;
-
- if (check_pid_valid(oldpid, cmd)) {
- *pid = oldpid;
- return 1;
- }
-
- return 0;
-}
-
-
-static void
-update_pidfile(char *prog)
-{
- FILE *fp = NULL;
- char *cmd;
-
- memset(pid_filename, 0, PATH_MAX);
-
- cmd = basename(prog);
- snprintf(pid_filename, sizeof (pid_filename), "/var/run/%s.pid", cmd);
-
- fp = fopen(pid_filename, "w");
- if (fp == NULL) {
- exit(1);
- }
-
- fprintf(fp, "%d", getpid());
- fclose(fp);
-}
-
-
-static int
-setup_sigmask(void)
-{
- sigset_t set;
-
- sigfillset(&set);
-
- /*
- * Dont't block signals which would cause us to dump core.
- */
- sigdelset(&set, SIGQUIT);
- sigdelset(&set, SIGILL);
- sigdelset(&set, SIGTRAP);
- sigdelset(&set, SIGABRT);
- sigdelset(&set, SIGFPE);
- sigdelset(&set, SIGSEGV);
- sigdelset(&set, SIGBUS);
-
- /*
- * Don't block SIGTERM or SIGCHLD
- */
- sigdelset(&set, SIGTERM);
- sigdelset(&set, SIGCHLD);
-
- return (sigprocmask(SIG_BLOCK, &set, NULL));
-}
-
-
-void
-daemon_init(char *prog)
-{
- if (getuid()) {
- logt_print(LOG_ERR,
- "daemon_init: Sorry, only root wants to run this.\n");
- exit(1);
- }
-
- if (setup_sigmask() < 0) {
- logt_print(LOG_ERR, "daemon_init: Unable to set signal mask.\n");
- exit(1);
- }
-
- if(daemon(0, 0)) {
- logt_print(LOG_ERR, "daemon_init: Unable to daemonize.\n");
- exit(1);
- }
-
- update_pidfile(prog);
-}
-
-
-void
-daemon_cleanup(void)
-{
- if (strlen(pid_filename))
- unlink(pid_filename);
-}
diff --git a/cman/qdisk/disk.c b/cman/qdisk/disk.c
deleted file mode 100644
index 9e43462..0000000
--- a/cman/qdisk/disk.c
+++ /dev/null
@@ -1,784 +0,0 @@
-/** @file
- * Single-block Raw/Direct I/O Functions
- */
-/*
- * author: Tim Burke <tburke at redhat.com>
- * description: Raw IO Interfaces.
- *
- * The RAW IO code we are using from 2.2.13 requires user buffers and
- * disk offsets to be 512 byte aligned. So this code consists of a
- * read and write routine which check to see if the user buffer is
- * aligned. If it isn't a temporary aligned buffer is allocated, a data
- * copy is performed along with the IO operation itself.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <string.h>
-#include <errno.h>
-#include <disk.h>
-#include <platform.h>
-#include <unistd.h>
-#include <time.h>
-#include <linux/types.h>
-#include <linux/fs.h>
-#include <liblogthread.h>
-#include <zlib.h>
-#include "iostate.h"
-
-static int diskRawRead(target_info_t *disk, char *buf, int len);
-
-/**
- * Calculate CRC32 of a data set.
- *
- * @param data Data set for building CRC32
- * @param count Size of data set, in bytes.
- * @return CRC32 of data set.
- */
-static uint32_t clu_crc32(const char *data, size_t count)
-{
- return (uint32_t)crc32(0L, (const Bytef *)data, (uInt)count);
-}
-
-
-/**
- * Swap the bytes of a shared header so that it's always in big-endian form
- * when stored on disk.
- *
- * @param hdr Header to encode.
- */
-static void
-header_encode(shared_header_t *hdr)
-{
- /* sanity check - LE machine -> already encoded. */
- if (hdr->h_magic == le_swap32(SHARED_HEADER_MAGIC))
- return;
-
- hdr->h_magic = le_swap32(hdr->h_magic);
- hdr->h_hcrc = le_swap32(hdr->h_hcrc);
- hdr->h_dcrc = le_swap32(hdr->h_dcrc);
- hdr->h_length = le_swap32(hdr->h_length);
- hdr->h_view = le_swap64(hdr->h_view);
- hdr->h_timestamp = le_swap64(hdr->h_timestamp);
-}
-
-
-/**
- * Swap the bytes of a shared header so that it's always in host-byte order
- * after we read it. This should be a macro calling header_encode.
- *
- * @param hdr Header to decode.
- */
-static void
-header_decode(shared_header_t *hdr)
-{
- /* sanity check - LE machine -> already decoded. */
- if (hdr->h_magic == SHARED_HEADER_MAGIC)
- return;
-
- hdr->h_magic = le_swap32(hdr->h_magic);
- hdr->h_hcrc = le_swap32(hdr->h_hcrc);
- hdr->h_dcrc = le_swap32(hdr->h_dcrc);
- hdr->h_length = le_swap32(hdr->h_length);
- hdr->h_view = le_swap64(hdr->h_view);
- hdr->h_timestamp = le_swap64(hdr->h_timestamp);
-}
-
-
-/**
- * Generate a shared header suitable for storing data. This includes:
- * header magic, header crc, data crc, header length, timestamp.
- * The header CRC is generated *after* the data CRC; so the header,
- * in effect, ensures that the data CRC is valid before we even look
- * at the data. Thus, if the header CRC decodes properly, then we
- * assume that there's a very very high chance that the data CRC is valid.
- * If the data CRC doesn't match the data, it's indicative of a problem.
- *
- * @param hdr Preallocated pointer to shared_header_t structure.
- * @param data Data to be stored with hdr.
- * @param count Size of data.
- * @return -1 if CRC32 generation fails, or 0 on success.
- */
-static int
-header_generate(shared_header_t *hdr, const char *data, size_t count)
-{
- memset(hdr,0,sizeof(*hdr));
-
- hdr->h_magic = SHARED_HEADER_MAGIC;
-
- if (data && count) {
- hdr->h_dcrc = clu_crc32(data, count);
- hdr->h_length = (uint32_t)count;
-
- if (hdr->h_dcrc == 0) {
- logt_print(LOG_ERR, "Invalid CRC32 generated on data!\n");
- return -1;
- }
- }
-
- hdr->h_timestamp = (uint64_t)time(NULL);
- header_encode(hdr);
- hdr->h_hcrc = 0;
- hdr->h_hcrc = le_swap32(clu_crc32((char *)hdr, sizeof(*hdr)));
-
- if (hdr->h_hcrc == 0) {
- logt_print(LOG_ERR, "Invalid CRC32 generated on header!\n");
- return -1;
- }
-
- return 0;
-}
-
-
-/**
- * Verify the integrity of a shared header. Basically, check the CRC32
- * information against the data and header. A better name for this would
- * be "shared_block_verify".
- *
- * @param hdr Preallocated pointer to shared_header_t structure.
- * @param data Data to be stored with hdr.
- * @param count Size of data.
- * @return -1 if CRC32 generation fails, or 0 on success.
- */
-static int
-header_verify(shared_header_t *hdr, const char *data, size_t count)
-{
- uint32_t crc;
- uint32_t bkupcrc;
-
- /*
- * verify the header's CRC32. Ok, we know it's overkill taking
- * the CRC32 of a friggin' 16-byte (12 bytes, really) structure,
- * but why not?
- */
- bkupcrc = hdr->h_hcrc;
-
- /* BUG: Headers are stored in little-endian form */
- bkupcrc = le_swap32(hdr->h_hcrc);
-
- hdr->h_hcrc = 0;
- crc = clu_crc32((char *)hdr, sizeof(*hdr));
- hdr->h_hcrc = bkupcrc;
- if (bkupcrc != crc) {
- logt_print(LOG_DEBUG, "Header CRC32 mismatch; Exp: 0x%08x "
- "Got: 0x%08x\n", bkupcrc, crc);
- return -1;
- }
-
- header_decode(hdr);
-
- /*
- * Verify the magic number.
- */
- if (hdr->h_magic != SHARED_HEADER_MAGIC) {
- logt_print(LOG_DEBUG, "Magic mismatch; Exp: 0x%08x "
- "Got: 0x%08x\n", SHARED_HEADER_MAGIC, hdr->h_magic);
- return -1;
- }
-
- /*
- * If there's no data or no count, or perhaps the length fed in is less
- * then the expected length, bail.
- */
- if (!data || !count || (count < hdr->h_length))
- return 0;
-
- crc = clu_crc32(data, (count > hdr->h_length) ?
- hdr->h_length : count);
-
- if (hdr->h_dcrc != crc) {
- logt_print(LOG_DEBUG, "Data CRC32 mismatch; Exp: 0x%08x "
- "Got: 0x%08x\n", hdr->h_dcrc, crc);
- return -1;
- }
-
- return 0;
-}
-
-
-
-/*
- * qdisk_open
- * Called to open the shared state partition with appropriate mode.
- * Returns - (the file descriptor), a value >= 0 on success.
- */
-int
-qdisk_open(char *name, target_info_t *disk)
-{
- int ret;
- int ssz;
-
- /*
- * Open for synchronous writes to insure all writes go directly
- * to disk.
- */
- disk->d_fd = open(name, O_RDWR | O_SYNC | O_DIRECT);
- if (disk->d_fd < 0)
- return disk->d_fd;
-
- ret = ioctl(disk->d_fd, BLKSSZGET, &ssz);
- if (ret < 0) {
- logt_print(LOG_ERR, "qdisk_open: ioctl(BLKSSZGET)");
- close(disk->d_fd);
- return -1;
- }
-
- disk->d_blksz = ssz;
- disk->d_pagesz = sysconf(_SC_PAGESIZE);
-
- /* Check to verify that the partition is large enough.*/
- io_state(STATE_LSEEK);
- ret = lseek(disk->d_fd, END_OF_DISK(disk->d_blksz), SEEK_SET);
- io_state(STATE_NONE);
- if (ret < 0) {
- logt_print(LOG_DEBUG, "open_partition: seek");
- close(disk->d_fd);
- return -1;
- }
-
- if (ret < END_OF_DISK(disk->d_blksz)) {
- logt_print(LOG_ERR, "Partition %s too small\n", name);
- errno = EINVAL;
- close(disk->d_fd);
- return -1;
- }
-
- /* Set close-on-exec bit */
- ret = fcntl(disk->d_fd, F_GETFD, 0);
- if (ret < 0) {
- logt_print(LOG_ERR, "open_partition: fcntl(F_GETFD)");
- close(disk->d_fd);
- return -1;
- }
-
- ret |= FD_CLOEXEC;
- if (fcntl(disk->d_fd, F_SETFD, ret) < 0) {
- logt_print(LOG_ERR, "open_partition: fcntl(F_SETFD)");
- close(disk->d_fd);
- return -1;
- }
-
- return 0;
-}
-
-
-/*
- * qdisk_close
- * Closes the shared state disk partition.
- * Returns - value from close syscall.
- */
-int
-qdisk_close(target_info_t *disk)
-{
- int retval;
-
- if (!disk || disk->d_fd < 0) {
- errno = EINVAL;
- return -1;
- }
-
- retval = close(disk->d_fd);
- disk->d_fd = -1;
-
- return retval;
-}
-
-/*
- * qdisk_validate
- * Called to verify that the specified device special file representing
- * the partition appears to be a valid device.
- * Returns: 0 - success, 1 - failure
- */
-int
-qdisk_validate(char *name)
-{
- struct stat stat_st, *stat_ptr;
- target_info_t disk;
- stat_ptr = &stat_st;
-
- if (stat(name, stat_ptr) < 0) {
- logt_print(LOG_ERR, "stat");
- return -1;
- }
- /*
- * Verify that its a block or character special file.
- */
- if (S_ISCHR(stat_st.st_mode) == 0 && S_ISBLK(stat_st.st_mode) == 0) {
-/*
- errno = EINVAL;
- return -1;
-*/
- logt_print(LOG_WARNING, "Warning: %s is not a block device\n",
- name);
- }
-
- /*
- * Verify read/write permission.
- */
- if (qdisk_open(name, &disk) < 0) {
- logt_print(LOG_DEBUG, "%s: open of %s for RDWR failed: %s\n",
- __FUNCTION__, name, strerror(errno));
- return -1;
- }
- qdisk_close(&disk);
- return 0;
-}
-
-
-static int
-diskRawReadShadow(target_info_t *disk, off_t readOffset, char *buf, int len)
-{
- int ret;
- shared_header_t *hdrp;
- char *data;
-
- io_state(STATE_LSEEK);
- ret = lseek(disk->d_fd, readOffset, SEEK_SET);
- io_state(STATE_NONE);
- if (ret != readOffset) {
- logt_print(LOG_DEBUG,
- "diskRawReadShadow: can't seek to offset %d.\n",
- (int) readOffset);
- errno = ENODATA;
- return -1;
- }
-
- ret = diskRawRead(disk, buf, len);
- if (ret != len) {
- logt_print(LOG_DEBUG, "diskRawReadShadow: aligned read "
- "returned %d, not %d.\n", ret, len);
- errno = ENODATA;
- return -1;
- }
-
- /* Decode the header portion so we can run a checksum on it. */
- hdrp = (shared_header_t *)buf;
- data = (char *)buf + sizeof(*hdrp);
-
- if (header_verify(hdrp, data, len)) {
- logt_print(LOG_DEBUG, "diskRawReadShadow: bad CRC32, "
- "offset = %d len = %d\n",
- (int) readOffset, len);
- errno = EPROTO;
- return -1;
- }
-
- return 0;
-}
-
-
-/*
- * The RAW IO implementation requires buffers to be 512 byte aligned.
- * Here we check for alignment and do a bounceio if necessary.
- */
-static int
-diskRawRead(target_info_t *disk, char *buf, int len)
-{
- void *alignedBuf;
- int readret;
- int extraLength;
- int readlen;
- int bounceNeeded = 1;
-
-
- /* was 3ff, which is (512<<1-1) */
- if ((((unsigned long) buf &
- (unsigned long) ((disk->d_blksz << 1) -1)) == 0) &&
- ((len % (disk->d_blksz)) == 0)) {
- bounceNeeded = 0;
- }
-
- if (bounceNeeded == 0) {
- /* Already aligned and even multiple of 512, no bounceio
- * required. */
- io_state(STATE_READ);
- readret = read(disk->d_fd, buf, len);
- io_state(STATE_NONE);
- return readret;
- }
-
- if (len > disk->d_blksz) {
- logt_print(LOG_ERR,
- "diskRawRead: not setup for reads larger than %d.\n",
- (int)disk->d_blksz);
- return (-1);
- }
- /*
- * All IOs must be of size which is a multiple of 512. Here we
- * just add in enough extra to accommodate.
- * XXX - if the on-disk offsets don't provide enough room we're cooked!
- */
- extraLength = 0;
- if (len % disk->d_blksz) {
- extraLength = disk->d_blksz - (len % disk->d_blksz);
- }
-
- readlen = len;
- if (extraLength) {
- readlen += extraLength;
- }
-
- readret = posix_memalign((void **)&alignedBuf, disk->d_pagesz, disk->d_blksz);
- if (readret < 0) {
- return -1;
- }
-
- io_state(STATE_READ);
- readret = read(disk->d_fd, alignedBuf, readlen);
- io_state(STATE_NONE);
- if (readret > 0) {
- if (readret > len) {
- memcpy(buf, alignedBuf, len);
- readret = len;
- } else {
- memcpy(buf, alignedBuf, readret);
- }
- }
-
- free(alignedBuf);
- if (readret != len) {
- logt_print(LOG_ERR, "diskRawRead: read err, len=%d, readret=%d\n",
- len, readret);
- }
-
- return (readret);
-}
-
-
-/*
- * The RAW IO implementation requires buffers to be 512 byte aligned.
- * Here we check for alignment and do a bounceio if necessary.
- */
-static int
-diskRawWrite(target_info_t *disk, char *buf, int len)
-{
- void *alignedBuf;
- int ret;
- int extraLength;
- int writelen;
- int bounceNeeded = 1;
-
- /* was 3ff, which is (512<<1-1) */
- if ((((unsigned long) buf &
- (unsigned long) ((disk->d_blksz << 1) -1)) == 0) &&
- ((len % (disk->d_blksz)) == 0)) {
- bounceNeeded = 0;
- }
-
- if (bounceNeeded == 0) {
- /* Already aligned and even multiple of 512, no bounceio
- * required. */
- io_state(STATE_WRITE);
- ret = write(disk->d_fd, buf, len);
- io_state(STATE_NONE);
- return ret;
- }
-
- if (len > disk->d_blksz) {
- logt_print(LOG_ERR,
- "diskRawRead: not setup for reads larger than %d.\n",
- (int)disk->d_blksz);
- return (-1);
- }
- /*
- * All IOs must be of size which is a multiple of 512. Here we
- * just add in enough extra to accommodate.
- * XXX - if the on-disk offsets don't provide enough room we're cooked!
- */
- extraLength = 0;
- if (len % disk->d_blksz) {
- extraLength = disk->d_blksz - (len % disk->d_blksz);
- }
-
- writelen = len;
- if (extraLength) {
- writelen += extraLength;
- }
-
- ret = posix_memalign((void **)&alignedBuf, disk->d_pagesz, disk->d_blksz);
- if (ret < 0) {
- return -1;
- }
-
- if (len > disk->d_blksz) {
- free(alignedBuf);
- logt_print(LOG_ERR,
- "diskRawWrite: not setup for larger than %d.\n",
- (int)disk->d_blksz);
- return (-1);
- }
-
- memcpy(alignedBuf, buf, len);
- io_state(STATE_WRITE);
- ret = write(disk->d_fd, alignedBuf, writelen);
- io_state(STATE_NONE);
- if (ret > len) {
- ret = len;
- }
-
- free(alignedBuf);
- if (ret != len) {
- logt_print(LOG_ERR, "diskRawWrite: write err, len=%d, ret=%dn",
- len, ret);
- }
-
- return (ret);
-}
-
-
-static int
-diskRawWriteShadow(target_info_t *disk, __off64_t writeOffset, char *buf, int len)
-{
- off_t retval_seek;
- ssize_t retval_write;
-
- if ((writeOffset < 0) || (len < 0)) {
- logt_print(LOG_ERR,
- "diskRawWriteShadow: writeOffset=%08x, "
- "len=%08x.\n", (int)writeOffset, len);
- return (-1);
- }
-
- io_state(STATE_LSEEK);
- retval_seek = lseek(disk->d_fd, writeOffset, SEEK_SET);
- io_state(STATE_NONE);
- if (retval_seek != writeOffset) {
- logt_print(LOG_ERR,
- "diskRawWriteShadow: can't seek to offset %d\n",
- (int) writeOffset);
- return (-1);
- }
-
- retval_write = diskRawWrite(disk, buf, len);
- if (retval_write != len) {
- if (retval_write == -1) {
- logt_print(LOG_ERR, "%s: %s\n", __FUNCTION__,
- strerror(errno));
- }
- logt_print(LOG_ERR,
- "diskRawWriteShadow: aligned write returned %d"
- ", not %d\n", (int)retval_write, (int)len);
- return (-1);
- }
-
- return 0;
-}
-
-
-int
-qdisk_read(target_info_t *disk, __off64_t offset, void *bufin, int count)
-{
- shared_header_t *hdrp;
- void *ptr;
- char *data;
- size_t total;
- int rv;
- char *buf = (char *)bufin;
-
- /*
- * Calculate the total length of the buffer, including the header.
- * Raw blocks are 512 byte aligned.
- */
- total = count + sizeof(shared_header_t);
- if (total < disk->d_blksz)
- total = disk->d_blksz;
-
- /* Round it up */
- if (total % disk->d_blksz)
- total = total + (disk->d_blksz * !!(total % disk->d_blksz)) - (total % disk->d_blksz);
-
- ptr = NULL;
- rv = posix_memalign((void **)&ptr, disk->d_pagesz, disk->d_blksz);
- if (rv < 0)
- return -1;
-
- if (ptr == NULL)
- return -1;
-
- hdrp = (shared_header_t *)ptr;
- data = (char *)hdrp + sizeof(shared_header_t);
-
- rv = diskRawReadShadow(disk, offset, (char *)hdrp, disk->d_blksz);
-
- if (rv == -1) {
- free(hdrp);
- return -1;
- }
-
- /* Copy out the data */
- memcpy(buf, data, hdrp->h_length);
-
- /* Zero out the remainder. */
- if (hdrp->h_length < count) {
- memset(buf + hdrp->h_length, 0,
- count - hdrp->h_length);
- }
-
- free(hdrp);
- return count;
-}
-
-
-int
-qdisk_write(target_info_t *disk, __off64_t offset, const void *buf, int count)
-{
- size_t maxsize;
- shared_header_t *hdrp;
- void *ptr;
- char *data;
- size_t total = 0, psz = disk->d_blksz; //sysconf(_SC_PAGESIZE);
- int rv = -1;
-
- maxsize = psz - (sizeof(shared_header_t));
- if (count >= (maxsize + sizeof(shared_header_t))) {
- logt_print(LOG_ERR, "error: count %d >= (%d + %d)\n", (int)count,
- (int)maxsize, (int)sizeof(shared_header_t));
- errno = ENOSPC;
- return -1;
- }
-
- /*
- * Calculate the total length of the buffer, including the header.
- */
- total = count + sizeof(shared_header_t);
- if (total < psz)
- total = psz;
-
- /* Round it up */
- if (total % psz)
- total = total + (psz * !!(total % psz)) - (total % psz);
-
- ptr = NULL;
- rv = posix_memalign((void **)&ptr, disk->d_pagesz, total);
- if (rv < 0) {
- logt_print(LOG_ERR, "posix_memalign");
- return -1;
- }
-
- /*
- * Copy the data into our new buffer
- */
- hdrp = (shared_header_t *)ptr;
- data = (char *)hdrp + sizeof(shared_header_t);
- memcpy(data, buf, count);
-
- if (header_generate(hdrp, buf, count) == -1) {
- free((char *)hdrp);
- return -1;
- }
-
- /*
- * Locking must be performed elsewhere. We make no assumptions
- * about locking here.
- */
- if (total == psz)
- rv = diskRawWriteShadow(disk, offset, (char *)hdrp, psz);
-
- if (rv == -1)
- logt_print(LOG_ERR, "diskRawWriteShadow");
-
- free((char *)hdrp);
- if (rv == -1)
- return -1;
- return count;
-}
-
-
-static int
-header_init(target_info_t *disk, char *label)
-{
- quorum_header_t qh;
-
- if (qdisk_read(disk, OFFSET_HEADER, &qh, sizeof(qh)) == sizeof(qh)) {
- swab_quorum_header_t(&qh);
- if (qh.qh_magic == HEADER_MAGIC_OLD) {
- printf("Warning: Red Hat Cluster Manager 1.2.x "
- "header found\n");
- } else if (qh.qh_magic == HEADER_MAGIC_NUMBER) {
- printf("Warning: Initializing previously "
- "initialized partition\n");
- }
- }
-
- if (gethostname(qh.qh_updatehost, sizeof(qh.qh_updatehost)) < 0) {
- logt_print(LOG_ERR, "gethostname");
- return -1;
- }
-
- /* Copy in the cluster/label name */
- snprintf(qh.qh_cluster, sizeof(qh.qh_cluster)-1, "%s", label);
-
- qh.qh_version = VERSION_MAGIC_V2;
- if ((qh.qh_timestamp = (uint64_t)time(NULL)) <= 0) {
- logt_print(LOG_ERR, "time");
- return -1;
- }
-
- qh.qh_magic = HEADER_MAGIC_NUMBER;
- qh.qh_blksz = disk->d_blksz;
- qh.qh_kernsz = 0;
-
- swab_quorum_header_t(&qh);
- if (qdisk_write(disk, OFFSET_HEADER, &qh, sizeof(qh)) != sizeof(qh)) {
- return -1;
- }
-
- return 0;
-}
-
-
-int
-qdisk_init(char *partname, char *label)
-{
- target_info_t disk;
- status_block_t ps, wps;
- int nid, ret;
- time_t t;
-
- ret = qdisk_validate(partname);
- if (ret < 0) {
- logt_print(LOG_DEBUG, "qdisk_validate: %s\n", strerror(errno));
- return -1;
- }
-
- ret = qdisk_open(partname, &disk);
- if (ret < 0) {
- logt_print(LOG_ERR, "qdisk_open: %s\n", strerror(errno));
- return -1;
- }
-
- if (header_init(&disk, label) < 0) {
- return -1;
- }
-
- time(&t);
-
- memset(&ps, 0, sizeof(status_block_t));
-
- ps.ps_magic = STATE_MAGIC_NUMBER;
- ps.ps_timestamp = (uint64_t)t;
-
- /* Node IDs 1..N */
- for (nid = 1; nid <= MAX_NODES_DISK; nid++) {
- ps.ps_nodeid = nid;
-
- printf("Initializing status block for node %d...\n", nid);
- wps = ps;
- swab_status_block_t(&wps);
-
- if (qdisk_write(&disk, qdisk_nodeid_offset(nid, disk.d_blksz), &wps, sizeof(wps)) < 0) {
- printf("Error writing node ID block %d\n", nid);
- qdisk_close(&disk);
- return -1;
- }
- }
-
- qdisk_close(&disk);
-
- return 0;
-}
-
diff --git a/cman/qdisk/disk.h b/cman/qdisk/disk.h
deleted file mode 100644
index 1d8f7c8..0000000
--- a/cman/qdisk/disk.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/**
- @file Main quorum daemon include file
- */
-#ifndef _QUORUM_DISK_H
-#define _QUORUM_DISK_H
-
-#include <stdint.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <libcman.h>
-
-#define MAX_NODES_DISK 16
-#define MEMB_MASK_LEN ((MAX_NODES_DISK / 8) + \
- (!!(MAX_NODES_DISK % 8)))
-#define DISK_MEMB_MASK_LEN ((MEMB_MASK_LEN + 7) & ~7)
-
-/** The membership bitmask type */
-typedef uint8_t memb_mask_t [DISK_MEMB_MASK_LEN];
-
-typedef enum {
- S_NONE = 0x0, // Shutdown / not quorate / not running
- S_EVICT = 0x1, // Voted out / about to be fenced.
- /* ^^^ Fencing OK */
- S_INIT = 0x2, // Initializing. Hold your fire.
- /* vvv Fencing will kill a node */
- S_RUN = 0x5, // I think I'm running.
- S_MASTER= 0x6, // I know I'm running, and have advertised to
- // CMAN the availability of the disk vote for my
- // partition.
- S_EXIT = 0x7 // trigger master re-election before exit
- // status is set only by master in master-win | auto-masterwin
- // and next status _must_ be S_NONE
-} disk_node_state_t;
-
-
-typedef enum {
- M_NONE = 0x0,
- M_BID = 0x1,
- M_ACK = 0x2,
- M_NACK = 0x3,
- M_MASK = 0x4
-} disk_msg_id_t;
-
-
-typedef enum {
- FL_MSG = 0x1,
- FL_BID = 0x2,
- FL_VOTE = 0x4
-} disk_state_flag_t;
-
-
-typedef enum {
- RF_REBOOT = 0x1, /* Reboot if we go from master->none */
- RF_STOP_CMAN = 0x2,
- RF_DEBUG = 0x4,
- RF_PARANOID = 0x8,
- RF_ALLOW_KILL = 0x10,
- RF_UPTIME = 0x20,
- RF_CMAN_LABEL = 0x40,
- RF_IOTIMEOUT = 0x80,
- RF_MASTER_WINS = 0x100,
- RF_AUTO_VOTES = 0x200,
- RF_AUTO_MASTER_WINS = 0x400
-} run_flag_t;
-
-
-/* RHEL 2.1 / RHCS3 old magic numbers */
-#define HEADER_MAGIC_OLD 0x39119FCD /* partition header */
-#define STATE_MAGIC_OLD 0xF1840DCE /* Status block */
-#define SHARED_HEADER_MAGIC_OLD 0x00DEBB1E /* Per-block header */
-
-/* Conversion */
-#define HEADER_MAGIC_NUMBER 0xeb7a62c2 /* Partition header */
-#define STATE_MAGIC_NUMBER 0x47bacef8 /* Status block */
-#define SHARED_HEADER_MAGIC 0x00DEBB1E /* Per-block headeer */
-
-/* Version magic. */
-#define VERSION_MAGIC_V2 0x389fabc4
-
-
-typedef struct __attribute__ ((packed)) {
- uint32_t ps_magic;
- /* 4 */
- uint32_t ps_updatenode; // Last writer
- /* 8 */
- uint64_t ps_timestamp; // time of last update
- /* 16 */
- uint32_t ps_nodeid;
- uint32_t pad0;
- /* 24 */
- uint8_t ps_state; // running or stopped
- uint8_t pad1[1];
- uint16_t ps_flags;
- /* 26 */
- uint16_t ps_score; // Local points
- uint16_t ps_scoremax; // What we think is our max
- // points, if other nodes
- // disagree, we may be voted
- // out
- /* 28 */
- uint32_t ps_ca_sec; // Cycle speed (average)
- uint32_t ps_ca_usec;
- /* 36 */
- uint32_t ps_lc_sec; // Cycle speed (last)
- uint32_t ps_lc_usec;
- uint64_t ps_incarnation; // Token to detect hung +
- // restored node
- /* 44 */
- uint16_t ps_msg; // Vote/bid mechanism
- uint16_t ps_seq;
- uint32_t ps_arg;
- /* 52 */
- memb_mask_t ps_mask; // Bitmap
- memb_mask_t ps_master_mask; // Bitmap
- /* 60 */
-} status_block_t;
-
-#define swab_status_block_t(ptr) \
-{\
- swab32((ptr)->ps_magic);\
- swab32((ptr)->ps_updatenode);\
- swab64((ptr)->ps_timestamp);\
- swab32((ptr)->ps_nodeid);\
- swab32((ptr)->pad0);\
- /* state + pad */ \
- swab16((ptr)->ps_flags);\
- swab16((ptr)->ps_score);\
- swab16((ptr)->ps_scoremax);\
- /* Cycle speeds */ \
- swab32((ptr)->ps_ca_sec);\
- swab32((ptr)->ps_ca_usec);\
- swab32((ptr)->ps_lc_sec);\
- swab32((ptr)->ps_lc_usec);\
- /* Message */ \
- swab16((ptr)->ps_msg); \
- swab16((ptr)->ps_seq); \
- swab32((ptr)->ps_arg); \
- }
-
-
-/*
- * Shared state disk header. Describes cluster global information.
- */
-typedef struct __attribute__ ((packed)) {
- uint32_t qh_magic;
- uint32_t qh_version; //
- uint64_t qh_timestamp; // time of last update
- char qh_updatehost[128];// Hostname who put this here...
- char qh_cluster[120]; // Cluster name; CMAN only
- // supports 16 chars.
- uint32_t qh_blksz; // Known block size @ creation
- uint32_t qh_kernsz; // Ingored
-} quorum_header_t;
-
-#define swab_quorum_header_t(ptr) \
-{\
- swab32((ptr)->qh_magic); \
- swab32((ptr)->qh_version); \
- swab32((ptr)->qh_blksz); \
- swab32((ptr)->qh_kernsz); \
- swab64((ptr)->qh_timestamp); \
-}
-
-
-
-/*
- * The user data is stored with this header prepended.
- * The header ONLY contains CRC information and the length of the data.
- * The data blocks themselves contain their own respective magic numbers.
- */
-typedef struct __attribute__ ((packed)) {
- uint32_t h_magic; /* Header magic */
- uint32_t h_hcrc; /* Header CRC */
- uint32_t h_dcrc; /* CRC32 of data */
- uint32_t h_length; /* Length of real data */
- uint64_t h_view; /* View # of real data */
- uint64_t h_timestamp; /* Timestamp */
-} shared_header_t;
-
-#define SHARED_HEADER_INITIALIZER = {0, 0, 0, 0, 0, 0}
-
-#define swab_shared_header_t(ptr) \
-{\
- swab32((ptr)->h_magic);\
- swab32((ptr)->h_hcrc);\
- swab32((ptr)->h_dcrc);\
- swab32((ptr)->h_length);\
- swab64((ptr)->h_view);\
- swab64((ptr)->h_timestamp);\
-}
-
-
-/* Offsets from RHCM 1.2.x */
-#define OFFSET_HEADER 0
-#define HEADER_SIZE(ssz) (ssz<4096?4096:ssz)
-
-#define OFFSET_FIRST_STATUS_BLOCK(ssz) (OFFSET_HEADER + HEADER_SIZE(ssz))
-#define SPACE_PER_STATUS_BLOCK(ssz) (ssz<4096?4096:ssz)
-#define STATUS_BLOCK_COUNT MAX_NODES_DISK
-
-#define END_OF_DISK(ssz) (OFFSET_FIRST_STATUS_BLOCK(ssz) + \
- (MAX_NODES_DISK + 1) * \
- SPACE_PER_STATUS_BLOCK(ssz)) \
-
-
-typedef struct {
- int d_fd;
- int _pad_;
- size_t d_blksz;
- size_t d_pagesz;
-} target_info_t;
-
-
-/* From disk.c */
-int qdisk_open(char *name, target_info_t *disk);
-int qdisk_close(target_info_t *disk);
-int qdisk_init(char *name, char *clustername);
-int qdisk_validate(char *name);
-int qdisk_read(target_info_t *disk, __off64_t ofs, void *buf, int len);
-int qdisk_write(target_info_t *disk, __off64_t ofs, const void *buf, int len);
-
-#define qdisk_nodeid_offset(nodeid, ssz) \
- (OFFSET_FIRST_STATUS_BLOCK(ssz) + (SPACE_PER_STATUS_BLOCK(ssz) * (nodeid - 1)))
-
-/* From disk_utils.c */
-#define HISTORY_LENGTH 60
-typedef struct {
- disk_msg_id_t m_msg; /* this is an int, but will be stored as 16bit*/
- uint32_t m_arg;
- uint16_t m_seq;
- uint16_t pad0;
-} disk_msg_t;
-
-
-typedef struct {
- uint64_t qc_incarnation;
- struct timeval qc_average;
- struct timeval qc_last[HISTORY_LENGTH];
- target_info_t qc_disk;
- int qc_my_id;
- int qc_writes;
- int qc_interval;
- int qc_tko;
- int qc_tko_up;
- int qc_upgrade_wait;
- int qc_master_wait;
- int qc_votes;
- int qc_scoremin;
- int qc_sched;
- int qc_sched_prio;
- int qc_max_error_cycles;
- int qc_master; /* Master?! */
- int qc_config;
- int qc_token_timeout;
- int qc_auto_votes;
- disk_node_state_t qc_disk_status;
- disk_node_state_t qc_status;
- run_flag_t qc_flags;
- cman_handle_t qc_cman_admin;
- cman_handle_t qc_cman_user;
- char *qc_device;
- char *qc_label;
- char *qc_status_file;
- char *qc_cman_label;
- char *qc_status_sockname;
-} qd_ctx;
-
-typedef struct {
- uint64_t ni_incarnation;
- uint64_t ni_evil_incarnation;
- time_t ni_last_seen;
- int ni_misses;
- int ni_seen;
- disk_msg_t ni_msg;
- disk_msg_t ni_last_msg;
- disk_node_state_t ni_state;
- status_block_t ni_status;
-} node_info_t;
-
-typedef struct {
- qd_ctx *ctx;
- node_info_t *ni;
- size_t ni_len;
-} qd_priv_t;
-
-int qd_write_status(qd_ctx *ctx, int nid, disk_node_state_t state,
- disk_msg_t *msg, memb_mask_t mask, memb_mask_t master);
-int qd_init(qd_ctx *ctx, cman_handle_t ch_admin,
- cman_handle_t ch_user, int me);
-void qd_destroy(qd_ctx *ctx);
-
-/* proc.c */
-int find_partitions(const char *label,
- char *devname, size_t devlen, int print);
-int check_device(char *device, char *label, quorum_header_t *qh, int flags);
-
-
-#endif
diff --git a/cman/qdisk/disk_util.c b/cman/qdisk/disk_util.c
deleted file mode 100644
index 6d6e93e..0000000
--- a/cman/qdisk/disk_util.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- @file Misc. Quorum daemon context utilities / high-level functions
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <string.h>
-#include <errno.h>
-#include <disk.h>
-#include <platform.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <time.h>
-#include <liblogthread.h>
-
-inline void _diff_tv(struct timeval *dest, struct timeval *start, struct timeval *end);
-inline int get_time(struct timeval *tv, int use_uptime);
-
-inline void
-_diff_tv(struct timeval *dest, struct timeval *start, struct timeval *end)
-{
- dest->tv_sec = end->tv_sec - start->tv_sec;
- dest->tv_usec = end->tv_usec - start->tv_usec;
-
- if (dest->tv_usec < 0) {
- dest->tv_usec += 1000000;
- dest->tv_sec--;
- }
-}
-
-
-/**
- *
- * Grab the uptime from /proc/uptime.
- *
- * @param tv Timeval struct to store time in. The sec
- * field contains seconds, the usec field
- * contains the hundredths-of-seconds (converted
- * to micro-seconds)
- * @return -1 on failure, 0 on success.
- */
-static inline int
-getuptime(struct timeval *tv)
-{
- FILE *fp;
- struct timeval junk;
- int rv;
-
- fp = fopen("/proc/uptime","r");
- if (!fp)
- return -1;
-
-#if defined(__sparc__)
- rv = fscanf(fp,"%ld.%d %ld.%d\n", &tv->tv_sec, &tv->tv_usec,
- &junk.tv_sec, &junk.tv_usec);
-#else
- rv = fscanf(fp,"%ld.%ld %ld.%ld\n", &tv->tv_sec, &tv->tv_usec,
- &junk.tv_sec, &junk.tv_usec);
-#endif
- fclose(fp);
-
- if (rv != 4) {
- return -1;
- }
-
- tv->tv_usec *= 10000;
-
- return 0;
-}
-
-
-inline int
-get_time(struct timeval *tv, int use_uptime)
-{
- if (use_uptime) {
- return getuptime(tv);
- } else {
- return gettimeofday(tv, NULL);
- }
-}
-
-
-/**
- Update write times and calculate a new average time
- */
-static void
-qd_update_wtime(qd_ctx *ctx, struct timeval *newtime)
-{
- int x;
- int max = HISTORY_LENGTH;
- uint64_t sum = 0;
-
- /* Store the thing */
- ctx->qc_writes++;
- ctx->qc_last[ctx->qc_writes % HISTORY_LENGTH].tv_sec = newtime->tv_sec;
- ctx->qc_last[ctx->qc_writes % HISTORY_LENGTH].tv_usec = newtime->tv_usec;
-
- if (ctx->qc_writes < HISTORY_LENGTH)
- max = ctx->qc_writes;
-
- for (x = 0; x < max; x++) {
- sum += (ctx->qc_last[x].tv_sec * 1000000);
- sum += ctx->qc_last[x].tv_usec;
- }
-
- sum /= max;
-
- ctx->qc_average.tv_sec = (sum / 1000000);
- ctx->qc_average.tv_usec = (sum % 1000000);
-}
-
-
-/**
- Write a status block to disk, given state, nodeid, message, and the
- membership mask.
- */
-int
-qd_write_status(qd_ctx *ctx, int nid, disk_node_state_t state,
- disk_msg_t *msg, memb_mask_t mask, memb_mask_t master)
-{
- status_block_t ps;
- struct timeval start, end;
- int utime_ok = 1;
-
- if (!ctx) {
- errno = EINVAL;
- return -1;
- }
-
- if (nid <= 0) {
- errno = EINVAL;
- return -1;
- }
-
- ps.ps_magic = STATE_MAGIC_NUMBER;
- ps.ps_nodeid = nid;
- ps.ps_updatenode = ctx->qc_my_id;
- ps.pad0 = 0;
- ps.ps_timestamp = (uint64_t)time(NULL);
- ps.ps_state = (uint8_t)state;
- ps.pad1[0] = 0;
- ps.ps_flags = 0;
- ps.ps_score = 0;
- ps.ps_scoremax = 0;
- ps.ps_ca_sec = ctx->qc_average.tv_sec;
- ps.ps_ca_usec = ctx->qc_average.tv_usec;
- ps.ps_incarnation = ctx->qc_incarnation;
- if (mask) {
- memcpy(ps.ps_mask, mask, sizeof(memb_mask_t));
- } else {
- memset(ps.ps_mask, 0, sizeof(memb_mask_t));
- }
- if (master) {
- memcpy(ps.ps_master_mask, master, sizeof(memb_mask_t));
- } else {
- memset(ps.ps_master_mask, 0, sizeof(memb_mask_t));
- }
-
- if (ctx->qc_writes) {
- ps.ps_lc_sec =
- ctx->qc_last[(ctx->qc_writes - 1) % HISTORY_LENGTH].tv_sec;
- ps.ps_lc_usec =
- ctx->qc_last[(ctx->qc_writes - 1) % HISTORY_LENGTH].tv_usec;
- } else {
- ps.ps_lc_sec = ps.ps_lc_usec = 0;
- }
- ps.ps_nodeid = nid;
-
- /* Argh! */
- if (msg) {
- ps.ps_msg = msg->m_msg;
- ps.ps_seq = msg->m_seq;
- ps.ps_arg = msg->m_arg;
- } else {
- ps.ps_msg = 0;
- ps.ps_seq = 0;
- ps.ps_arg = 0;
- }
-
- if (get_time(&start, ctx->qc_flags&RF_UPTIME) < 0)
- utime_ok = 0;
- swab_status_block_t(&ps);
- if (qdisk_write(&ctx->qc_disk,
- qdisk_nodeid_offset(nid, ctx->qc_disk.d_blksz),
- &ps, sizeof(ps)) < 0) {
- logt_print(LOG_ERR, "Error writing node ID block %d\n", nid);
- return -1;
- }
- if (utime_ok && (get_time(&end, ctx->qc_flags&RF_UPTIME) < 0))
- utime_ok = 0;
-
- if (utime_ok) {
- _diff_tv(&start,&start,&end);
- } else {
- /* Use heuristic */
- start.tv_sec = ctx->qc_average.tv_sec;
- start.tv_usec = ctx->qc_average.tv_usec;
- }
- qd_update_wtime(ctx, &start);
-
- return 0;
-}
-
-
-/**
- Generate a token based on the current system time.
- */
-static uint64_t
-generate_token(void)
-{
- uint64_t my_token = 0;
- struct timeval tv;
-
- while(my_token == 0) {
- gettimeofday(&tv, NULL);
-
- my_token = ((uint64_t) (tv.tv_sec) << 32) |
- (uint64_t) (tv.tv_sec & 0x00000000ffffffff);
- }
-
- return my_token;
-}
-
-
-/**
- Initialize a quorum disk context, given a CMAN handle and a nodeid.
- */
-int
-qd_init(qd_ctx *ctx, cman_handle_t ch_admin, cman_handle_t ch, int me)
-{
- if (!ctx || !ch || !me) {
- errno = EINVAL;
- return -1;
- }
-
- memset(ctx, 0, sizeof(*ctx));
- ctx->qc_incarnation = generate_token();
- ctx->qc_cman_admin = ch_admin;
- ctx->qc_cman_user = ch;
- ctx->qc_my_id = me;
- ctx->qc_config = 0;
-
- return 0;
-}
-
-
-/**
- Destroy a quorum disk context
- */
-void
-qd_destroy(qd_ctx *ctx)
-{
- if (ctx->qc_my_id == 0)
- return;
- if (ctx->qc_device) {
- free(ctx->qc_device);
- ctx->qc_device = NULL;
- }
- qdisk_close(&ctx->qc_disk);
-}
diff --git a/cman/qdisk/iostate.c b/cman/qdisk/iostate.c
deleted file mode 100644
index 9050276..0000000
--- a/cman/qdisk/iostate.c
+++ /dev/null
@@ -1,154 +0,0 @@
-#include <pthread.h>
-#include <libcman.h>
-#include <iostate.h>
-#include <unistd.h>
-#include <time.h>
-#include <sys/time.h>
-#include <liblogthread.h>
-#include <stdint.h>
-#include "platform.h"
-#include "iostate.h"
-#include "../daemon/cnxman-socket.h"
-
-static iostate_t main_state = 0;
-static int main_incarnation = 0;
-static int qdisk_timeout = 0, sleeptime = 0;
-static int thread_active = 0;
-static pthread_t io_nanny_tid = 0;
-static pthread_mutex_t state_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t state_cond = PTHREAD_COND_INITIALIZER;
-
-struct state_table {
- iostate_t state;
- const char *value;
-};
-
-static struct state_table io_state_table[] = {
-{ STATE_NONE, "none" },
-{ STATE_WRITE, "write" },
-{ STATE_READ, "read" },
-{ STATE_LSEEK, "seek" },
-{ -1, NULL } };
-
-const char *
-state_to_string(iostate_t state)
-{
- static const char *ret = "unknown";
- int i;
-
- for (i=0; io_state_table[i].value; i++) {
- if (io_state_table[i].state == state) {
- ret = io_state_table[i].value;
- break;
- }
- }
-
- return ret;
-}
-
-
-void
-io_state(iostate_t state)
-{
- pthread_mutex_lock(&state_mutex);
- main_state = state;
- main_incarnation++; /* it does not matter if this wraps. */
-
- /* Optimization: Don't signal on STATE_NONE */
- if (state != STATE_NONE)
- pthread_cond_broadcast(&state_cond);
-
- pthread_mutex_unlock(&state_mutex);
-}
-
-
-static void *
-io_nanny_thread(void *arg)
-{
- struct timespec wait_time;
- iostate_t last_main_state = 0, current_main_state = 0;
- int last_main_incarnation = 0, current_main_incarnation = 0;
- int logged_incarnation = 0;
- cman_handle_t ch = (cman_handle_t)arg;
- int32_t whine_state;
-
- /* Start with wherever we're at now */
- pthread_mutex_lock(&state_mutex);
- current_main_state = last_main_state = main_state;
- current_main_incarnation = last_main_incarnation = main_incarnation;
- pthread_mutex_unlock(&state_mutex);
-
- while (thread_active) {
- pthread_mutex_lock(&state_mutex);
- clock_gettime(CLOCK_REALTIME, &wait_time);
- wait_time.tv_sec += sleeptime;
- pthread_cond_timedwait(&state_cond, &state_mutex, &wait_time);
- current_main_state = main_state;
- current_main_incarnation = main_incarnation;
- pthread_mutex_unlock(&state_mutex);
-
- if (!thread_active)
- break;
-
- if (!current_main_state)
- continue;
-
- /* if the state or incarnation changed, the main qdiskd
- * thread is healthy */
- if (current_main_state != last_main_state ||
- current_main_incarnation != last_main_incarnation) {
- last_main_state = current_main_state;
- last_main_incarnation = current_main_incarnation;
- continue;
- }
-
- /* Whine on CMAN api */
- whine_state = (int32_t)current_main_state;
- swab32(whine_state);
- cman_send_data(ch, &whine_state, sizeof(int32_t), 0, CLUSTER_PORT_QDISKD , 0);
-
- /* Don't log things twice */
- if (logged_incarnation == current_main_incarnation)
- continue;
- logged_incarnation = current_main_incarnation;
-
- logt_print(LOG_WARNING, "qdiskd: %s "
- "(system call) has hung for %d seconds\n",
- state_to_string(current_main_state), sleeptime);
- logt_print(LOG_WARNING,
- "In %d more seconds, we will be evicted\n",
- (qdisk_timeout-sleeptime));
- }
-
- return NULL;
-}
-
-
-int
-io_nanny_start(cman_handle_t ch, int timeout)
-{
- int ret;
-
- pthread_mutex_lock(&state_mutex);
-
- sleeptime = timeout / 2;
- qdisk_timeout = timeout;
- thread_active = 1;
-
- ret = pthread_create(&io_nanny_tid, NULL, io_nanny_thread, ch);
- pthread_mutex_unlock(&state_mutex);
-
- return ret;
-}
-
-
-int
-io_nanny_stop(void)
-{
- thread_active = 0;
- pthread_cond_broadcast(&state_cond);
- pthread_join(io_nanny_tid, NULL);
- io_nanny_tid = 0;
-
- return 0;
-}
diff --git a/cman/qdisk/iostate.h b/cman/qdisk/iostate.h
deleted file mode 100644
index a65b1d4..0000000
--- a/cman/qdisk/iostate.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef _IOSTATE_H
-#define _IOSTATE_H
-
-typedef enum {
- STATE_NONE = 0,
- STATE_READ = 1,
- STATE_WRITE = 2,
- STATE_LSEEK = 3,
- STATE_UNKNOWN = 4
-} iostate_t;
-
-void io_state(iostate_t state);
-
-int io_nanny_start(cman_handle_t ch, int timeout);
-int io_nanny_stop(void);
-
-const char * state_to_string(iostate_t state);
-
-#endif
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
deleted file mode 100644
index 9dee134..0000000
--- a/cman/qdisk/main.c
+++ /dev/null
@@ -1,2289 +0,0 @@
-/**
- @file Main loop / functions for disk-based quorum daemon.
- */
-#define SYSLOG_NAMES
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <string.h>
-#include <errno.h>
-#include <disk.h>
-#include <platform.h>
-#include <unistd.h>
-#include <time.h>
-#include <sys/reboot.h>
-#include <sys/time.h>
-#include <sys/un.h>
-#include <linux/reboot.h>
-#include <sched.h>
-#include <signal.h>
-#include <ccs.h>
-#include <liblogthread.h>
-#include "score.h"
-#include "../daemon/cman.h"
-#include "../daemon/cnxman-socket.h"
-#include <sys/syslog.h>
-
-#define LOG_DAEMON_NAME "qdiskd"
-#define LOG_MODE_DEFAULT LOG_MODE_OUTPUT_SYSLOG|LOG_MODE_OUTPUT_FILE
-#include "iostate.h"
-
-
-/* from main.c */
-void set_priority(int queue, int prio);
-
-/* from daemon_init.c */
-extern int daemon_init(char *);
-extern void daemon_cleanup(void);
-extern int check_process_running(char *, pid_t *);
-
-/* from proc.c */
-extern const char *state_str(disk_node_state_t s);
-
-/*
- TODO:
- 1) Take into account timings to gracefully extend node timeouts during
- node spikes (that's why they are there!).
- 2) Poll ccsd for configuration changes.
- 3) Logging.
- */
-
-/* From bitmap.c */
-extern int clear_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
-extern int set_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
-extern int is_bit_set(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
-
-/* From disk_utils.c */
-extern inline int get_time(struct timeval *tv, int use_uptime);
-extern inline void _diff_tv(struct timeval *dest, struct timeval *start,
- struct timeval *end);
-
-static int _running = 1, _reconfig = 0, _cman_shutdown = 0;
-static int _debug = 0, _foreground = 0;
-
-/* */
-#define DEBUG_CONF 0x1
-#define DEBUG_CMDLINE 0x2
-
-static void update_local_status(qd_ctx *ctx, node_info_t *ni, int max, int score,
- int score_req, int score_max);
-static int get_config_data(qd_ctx *ctx, struct h_data *h, int maxh, int *cfh);
-static int cman_wait(cman_handle_t ch, struct timeval *_tv);
-
-static int fake_cfh = 0;
-
-static void
-int_handler(int sig)
-{
- _running = 0;
-}
-
-
-static void
-hup_handler(int sig)
-{
- _reconfig = 1;
-}
-
-
-static void
-usr1_handler(int sig)
-{
- if (_debug)
- /* Shut up debug mode */
- _debug = 0;
- else
- _debug = DEBUG_CMDLINE;
-}
-
-
-/**
- Simple thing to see if a node is running.
- */
-static inline int
-state_run(disk_node_state_t state)
-{
- return (state >= S_INIT ? state : 0);
-}
-
-
-/**
- Clear out / initialize node info block.
- */
-static void
-node_info_init(node_info_t *ni, int max)
-{
- int x;
- time_t t = time(NULL);
-
- memset(ni, 0, sizeof(*ni) * max);
- for (x = 0; x < max; x++) {
- ni[x].ni_status.ps_nodeid = (x + 1); /* node ids are 1-based */
- ni[x].ni_status.ps_timestamp = t;
- ni[x].ni_misses = 0;
- ni[x].ni_last_seen = t;
- }
-}
-
-
-/**
- Check to see if someone tried to evict us but we were out to lunch.
- Rare case; usually other nodes would put up the 'Undead' message and
- re-evict us.
- */
-static void
-check_self(qd_ctx *ctx, status_block_t *sb)
-{
- if (!sb->ps_updatenode ||
- (sb->ps_updatenode == ctx->qc_my_id)) {
- return;
- }
-
- /* I did not update this??! */
- switch(sb->ps_state) {
- case S_EVICT:
- /* Someone told us to die. */
- reboot(RB_AUTOBOOT);
- default:
- logt_print(LOG_EMERG, "Unhandled state: %d\n", sb->ps_state);
- raise(SIGSTOP);
- break;
- }
-}
-
-
-/**
- Read in the node blocks off of the quorum disk and see if anyone has
- or has not updated their timestamp recently. See check_transitions as
- well.
- */
-static int
-read_node_blocks(qd_ctx *ctx, node_info_t *ni, int max)
-{
- int x, errors = 0;
- status_block_t *sb;
-
- for (x = 0; x < max; x++) {
-
- sb = &ni[x].ni_status;
-
- if (qdisk_read(&ctx->qc_disk,
- qdisk_nodeid_offset(x+1, ctx->qc_disk.d_blksz),
- sb, sizeof(*sb)) < 0) {
- logt_print(LOG_WARNING,"Error reading node ID block %d\n",
- x+1);
- ++errors;
- continue;
- }
- swab_status_block_t(sb);
-
- if (sb->ps_nodeid == ctx->qc_my_id) {
- check_self(ctx, sb);
- continue;
- }
- /* message. */
- memcpy(&(ni[x].ni_last_msg), &(ni[x].ni_msg),
- sizeof(ni[x].ni_last_msg));
- ni[x].ni_msg.m_arg = sb->ps_arg;
- ni[x].ni_msg.m_msg = sb->ps_msg;
- ni[x].ni_msg.m_seq = sb->ps_seq;
-
- if (!state_run(sb->ps_state))
- continue;
-
- /* Unchanged timestamp: miss */
- if ((sb->ps_timestamp == ni[x].ni_last_seen) &&
- (ni[x].ni_state != S_EXIT)) {
- if (ni[x].ni_state != S_NONE) {
- /* XXX check for average + allow grace */
- ni[x].ni_misses++;
- if (ni[x].ni_misses > 1) {
- logt_print(LOG_DEBUG,
- "Node %d missed an update (%d/%d)\n",
- x+1, ni[x].ni_misses, ctx->qc_tko);
- }
- }
- continue;
- }
-
- /* Got through? The node is good. */
- ni[x].ni_misses = 0;
- ni[x].ni_seen++;
- ni[x].ni_last_seen = sb->ps_timestamp;
- }
-
- return errors;
-}
-
-
-/**
- Check for node transitions.
- */
-static void
-check_transitions(qd_ctx *ctx, node_info_t *ni, int max, memb_mask_t mask)
-{
- int x;
-
- if (mask)
- memset(mask, 0, sizeof(memb_mask_t));
-
- for (x = 0; x < max; x++) {
-
- /*
- Case 0: check if master node is about to leave
- */
- if (ni[x].ni_state == S_EXIT) {
- logt_print(LOG_NOTICE, "Node %d is about to leave\n", ni[x].ni_status.ps_nodeid);
- ni[x].ni_evil_incarnation = 0;
- ni[x].ni_incarnation = 0;
- ni[x].ni_seen = 0;
- ni[x].ni_misses = 0;
- ni[x].ni_state = S_NONE;
- if (mask)
- clear_bit(mask, (ni[x].ni_status.ps_nodeid-1),
- sizeof(memb_mask_t));
- continue;
- }
-
- /*
- Case 1: check to see if the node is still up
- according to our internal state, but has been
- evicted by the master or cleanly shut down
- (or restarted).
-
- Transition from Evicted/Shutdown -> Offline
- */
- if ((ni[x].ni_state >= S_EVICT &&
- ni[x].ni_status.ps_state <= S_EVICT) ||
- (ni[x].ni_incarnation &&
- (ni[x].ni_incarnation !=
- ni[x].ni_status.ps_incarnation))) {
-
- if (ni[x].ni_status.ps_state == S_EVICT) {
- logt_print(LOG_NOTICE, "Node %d evicted\n",
- ni[x].ni_status.ps_nodeid);
- } else {
- /* State == S_NONE or incarnation change */
- logt_print(LOG_INFO, "Node %d shutdown\n",
- ni[x].ni_status.ps_nodeid);
- ni[x].ni_evil_incarnation = 0;
- }
-
- ni[x].ni_incarnation = 0;
- ni[x].ni_seen = 0;
- ni[x].ni_misses = 0;
- ni[x].ni_state = S_NONE;
-
- /* Clear our master mask for the node after eviction
- * or shutdown */
- if (mask)
- clear_bit(mask, (ni[x].ni_status.ps_nodeid-1),
- sizeof(memb_mask_t));
- continue;
- }
-
- /*
- Case 2: Check for a heartbeat timeout. Write an eviction
- notice if we're the master. If this is our first notice
- of the heartbeat timeout, update our internal state
- accordingly. When the master evicts this node, we will
- hit case 1 above.
-
- Transition from Online -> Evicted
- */
- if (ni[x].ni_misses > ctx->qc_tko &&
- state_run(ni[x].ni_status.ps_state)) {
-
- /*
- Mark our internal views as dead if nodes miss too
- many heartbeats... This will cause a master
- transition if no live master exists.
- */
- if (ni[x].ni_status.ps_state >= S_RUN &&
- ni[x].ni_seen) {
- logt_print(LOG_DEBUG, "Node %d DOWN\n",
- ni[x].ni_status.ps_nodeid);
- ni[x].ni_seen = 0;
- }
-
- ni[x].ni_state = S_EVICT;
- ni[x].ni_status.ps_state = S_EVICT;
- ni[x].ni_evil_incarnation =
- ni[x].ni_incarnation;
-
- /*
- Write eviction notice if we're the master.
- */
- if (ctx->qc_status == S_MASTER) {
- logt_print(LOG_NOTICE,
- "Writing eviction notice for node %d\n",
- ni[x].ni_status.ps_nodeid);
- if (qd_write_status(ctx, ni[x].ni_status.ps_nodeid,
- S_EVICT, NULL, NULL, NULL) != 0)
- logt_print(LOG_CRIT, "Unable to write eviction notice for node %d!\n",
- ni[x].ni_status.ps_nodeid);
- if (ctx->qc_flags & RF_ALLOW_KILL) {
- logt_print(LOG_DEBUG, "Telling CMAN to "
- "kill the node\n");
- cman_kill_node(ctx->qc_cman_admin,
- ni[x].ni_status.ps_nodeid);
- }
- }
-
- /* Clear our master mask for the node after eviction */
- if (mask)
- clear_bit(mask, (ni[x].ni_status.ps_nodeid-1),
- sizeof(memb_mask_t));
- continue;
- }
-
- /*
- Case 3: Check for node who is supposed to be dead, but
- has started writing to the disk again with the same
- incarnation.
-
- Transition from Offline -> Undead (BAD!!!)
- */
- if (ni[x].ni_evil_incarnation &&
- (ni[x].ni_evil_incarnation ==
- ni[x].ni_status.ps_incarnation) &&
- (ni[x].ni_status.ps_updatenode ==
- ni[x].ni_status.ps_nodeid)) {
- logt_print(LOG_CRIT, "Node %d is undead.\n",
- ni[x].ni_status.ps_nodeid);
-
- logt_print(LOG_ALERT,
- "Writing eviction notice (again) for node %d\n",
- ni[x].ni_status.ps_nodeid);
- if (qd_write_status(ctx, ni[x].ni_status.ps_nodeid,
- S_EVICT, NULL, NULL, NULL) != 0)
- logt_print(LOG_CRIT, "Unable to write eviction notice for node %d!\n",
- ni[x].ni_status.ps_nodeid);
- ni[x].ni_status.ps_state = S_EVICT;
-
- /* XXX Need to fence it again */
- if (ctx->qc_flags & RF_ALLOW_KILL) {
- logt_print(LOG_DEBUG, "Telling CMAN to "
- "kill the node\n");
- cman_kill_node(ctx->qc_cman_admin,
- ni[x].ni_status.ps_nodeid);
- }
- continue;
- }
-
-
- /*
- Case 4: Check for a node who has met our minimum # of
- 'seen' requests.
-
- Transition from Offline -> Online
- */
- if (ni[x].ni_seen > ctx->qc_tko_up &&
- !state_run(ni[x].ni_state)) {
- /*
- Node-join - everyone just kind of "agrees"
- there's no consensus to just have a node join
- right now.
- */
- ni[x].ni_state = S_RUN;
- logt_print(LOG_DEBUG, "Node %d is UP\n",
- ni[x].ni_status.ps_nodeid);
- ni[x].ni_incarnation =
- ni[x].ni_status.ps_incarnation;
- ni[x].ni_evil_incarnation = 0;
-
- if (mask)
- set_bit(mask, (ni[x].ni_status.ps_nodeid-1),
- sizeof(memb_mask_t));
-
- continue;
- }
-
- /*
- Case 5: Check for a node becoming master. Not really a
- transition.
- */
- if (ni[x].ni_state == S_RUN &&
- ni[x].ni_status.ps_state == S_MASTER) {
- logt_print(LOG_INFO, "Node %d is the master\n",
- ni[x].ni_status.ps_nodeid);
- ni[x].ni_state = S_MASTER;
- if (mask)
- set_bit(mask, (ni[x].ni_status.ps_nodeid-1),
- sizeof(memb_mask_t));
- continue;
- }
-
- /*
- Case 6: Check for a node which has changed its
- incarnation # quickly (e.g. killall -9 qdiskd;
- qdiskd). Not a transition.
- */
- if (state_run(ni[x].ni_state) &&
- ni[x].ni_incarnation != ni[x].ni_status.ps_incarnation) {
-
- logt_print(LOG_DEBUG, "Node %d incarnation # changed\n",
- ni[x].ni_status.ps_nodeid);
- ni[x].ni_incarnation =
- ni[x].ni_status.ps_incarnation;
- ni[x].ni_evil_incarnation = 0;
-
- continue;
- }
-
- /*
- All other cases: Believe the node's reported state
- */
- if (state_run(ni[x].ni_state)) {
- ni[x].ni_state = ni[x].ni_status.ps_state;
- if (mask)
- set_bit(mask, (ni[x].ni_status.ps_nodeid-1),
- sizeof(memb_mask_t));
- }
- }
-}
-
-
-/**
- Checks for presence of an online master. If there is no
- Returns
- */
-static int
-master_exists(qd_ctx *ctx, node_info_t *ni, int max, int *low_id, int *count)
-{
- int x;
- int masters = 0;
- int ret = 0;
-
- if (count)
- *count = 0;
- *low_id = ctx->qc_my_id;
-
- for (x = 0; x < max; x++) {
-
- /* See if this one's a master */
- if (ni[x].ni_state >= S_RUN &&
- ni[x].ni_status.ps_state == S_MASTER &&
- ni[x].ni_status.ps_nodeid != ctx->qc_my_id) {
- if (!ret)
- ret = ni[x].ni_status.ps_nodeid;
- ++masters;
- continue;
- }
-
- /* See if it's us... */
- if (ni[x].ni_status.ps_nodeid == ctx->qc_my_id &&
- ni[x].ni_status.ps_state == S_MASTER) {
- if (!ret)
- ret = ctx->qc_my_id;
- ++masters;
- continue;
- }
-
- /* Look for dead master */
- if (ni[x].ni_state < S_RUN &&
- ni[x].ni_status.ps_state == S_MASTER) {
- logt_print(LOG_DEBUG,
- "Node %d is marked master, but is dead.\n",
- ni[x].ni_status.ps_nodeid);
- continue;
- }
-
- if (ni[x].ni_state < S_RUN)
- continue;
-
- if (ni[x].ni_status.ps_nodeid < *low_id)
- *low_id = ni[x].ni_status.ps_nodeid;
- }
-
- if (count)
- *count = masters;
- /*
- else if (masters == 1) {
- printf("Node %d is the master\n", ret);
- } else {
- printf("No master found; node %d should be the master\n",
- *low_id);
- }
- */
-
- return ret;
-}
-
-
-/**
- initialize node information blocks and wait to see if there is already
- a cluster running using this QD. Note that this will delay master
- election if multiple nodes start with a second or two of each other.
- */
-static int
-quorum_init(qd_ctx *ctx, node_info_t *ni, int max, struct h_data *h, int maxh)
-{
- int x = 0, score, maxscore, score_req = 0;
- struct timeval tv;
-
- logt_print(LOG_INFO, "Quorum Daemon Initializing\n");
-
- if (mlockall(MCL_CURRENT|MCL_FUTURE) != 0) {
- logt_print(LOG_ERR, "Unable to mlockall()\n");
- }
-
- if (qdisk_validate(ctx->qc_device) < 0)
- return -1;
-
- if (qdisk_open(ctx->qc_device, &ctx->qc_disk) < 0) {
- logt_print(LOG_CRIT, "Failed to open %s: %s\n", ctx->qc_device,
- strerror(errno));
- return -1;
- }
-
- logt_print(LOG_DEBUG, "I/O Size: %lu Page Size: %lu\n",
- (unsigned long)ctx->qc_disk.d_blksz, (unsigned long)ctx->qc_disk.d_pagesz);
-
- if (h && maxh) {
- start_score_thread(ctx, h, maxh);
- } else {
- logt_print(LOG_DEBUG, "Permanently setting score to 1/1\n");
- fudge_scoring();
- }
-
- node_info_init(ni, max);
- ctx->qc_status = S_INIT;
- if (qd_write_status(ctx, ctx->qc_my_id,
- S_INIT, NULL, NULL, NULL) != 0) {
- logt_print(LOG_CRIT, "Could not initialize status block!\n");
- return -1;
- }
-
- while (++x <= ctx->qc_tko && _running) {
- read_node_blocks(ctx, ni, max);
- check_transitions(ctx, ni, max, NULL);
-
- if (qd_write_status(ctx, ctx->qc_my_id,
- S_INIT, NULL, NULL, NULL) != 0) {
- logt_print(LOG_CRIT, "Initialization failed\n");
- return -1;
- }
-
- get_my_score(&score, &maxscore);
- score_req = ctx->qc_scoremin;
- if (score_req <= 0)
- score_req = (maxscore/2 + 1);
- update_local_status(ctx, ni, max, score, score_req, maxscore);
-
- tv.tv_sec = ctx->qc_interval;
- tv.tv_usec = 0;
- if (cman_wait(ctx->qc_cman_user, &tv) < 0)
- logt_print(LOG_ERR, "cman_dispatch: %s\n",
- strerror(errno));
- }
-
- if (!_running) {
- return 1;
- }
-
- get_my_score(&score, &maxscore);
- logt_print(LOG_INFO, "Initial score %d/%d\n", score, maxscore);
- if ((ctx->qc_flags & RF_STOP_CMAN) && (score < score_req))
- return -1;
- logt_print(LOG_INFO, "Initialization complete\n");
-
- return 0;
-}
-
-
-/**
- Vote for a master if it puts a bid in.
- */
-static void
-do_vote(qd_ctx *ctx, node_info_t *ni, int max, disk_msg_t *msg)
-{
- int x;
-
- for (x = 0; x < max; x++) {
- if (ni[x].ni_state != S_RUN)
- continue;
-
- if (ni[x].ni_status.ps_msg == M_BID &&
- ni[x].ni_status.ps_nodeid < ctx->qc_my_id) {
-
- /* Vote for lowest bidding ID that is lower
- than us */
- msg->m_msg = M_ACK;
- msg->m_arg = ni[x].ni_status.ps_nodeid;
- msg->m_seq = ni[x].ni_status.ps_seq;
-
- return;
- }
- }
-}
-
-
-/*
- Check to match nodes in mask with nodes online according to CMAN.
- Only the master needs to do this.
- */
-static void
-check_cman(qd_ctx *ctx, memb_mask_t mask, memb_mask_t master_mask)
-{
- cman_node_t nodes[MAX_NODES_DISK];
- int retnodes, x;
- static unsigned int check_cycle = 0;
-
- if (cman_get_nodes(ctx->qc_cman_admin, MAX_NODES_DISK,
- &retnodes, nodes) <0 )
- return;
-
- memset(master_mask, 0, sizeof(memb_mask_t));
- for (x = 0; x < retnodes; x++) {
- /* See if the other node is running cman and not qdiskd.
- Just to this every 4 times (seconds) so we don't spam syslog
- too much. cman_is_listening() can return EBUSY which means
- "I don't know". We don't worry about this, and just report
- at the next check by which time it will.
- */
- check_cycle = (check_cycle + 1) % 4;
- if ((check_cycle == 1) &&
- (cman_is_listening(ctx->qc_cman_admin, nodes[x].cn_nodeid,
- CLUSTER_PORT_QDISKD) == 0)) {
- logt_print(LOG_NOTICE, "node %s is up but not running qdiskd", nodes[x].cn_name);
- }
- if (is_bit_set(mask, nodes[x].cn_nodeid-1, sizeof(memb_mask_t)) &&
- nodes[x].cn_member) {
- set_bit(master_mask, nodes[x].cn_nodeid-1,
- sizeof(memb_mask_t));
- } else {
- /* Not in CMAN output = not allowed */
- clear_bit(master_mask, (nodes[x].cn_nodeid-1),
- sizeof(memb_mask_t));
- }
- }
-}
-
-
-/*
- returns:
- 3: all acks received - you are the master.
- 2: nacked (not highest score?) might not happen
- 1: other node with lower ID is bidding and we should rescind our
- bid.
- 0: still waiting; don't clear bid; just wait another round.
- Modifies:
- *msg - it will store the vote for the lowest bid if we should
- clear our bid.
- */
-static int
-check_votes(qd_ctx *ctx, node_info_t *ni, int max, disk_msg_t *msg)
-{
- int x, running = 0, acks = 0, nacks = 0, low_id = ctx->qc_my_id;
-
- for (x = 0; x < max; x++) {
- if (state_run(ni[x].ni_state))
- ++running;
- else
- continue;
-
- if (ni[x].ni_status.ps_msg == M_ACK &&
- ni[x].ni_status.ps_arg == ctx->qc_my_id) {
- ++acks;
- }
-
- if (ni[x].ni_status.ps_msg == M_NACK &&
- ni[x].ni_status.ps_arg == ctx->qc_my_id) {
- ++nacks;
- }
-
- /* If there's someone with a lower ID who is also
- bidding for master, change our message to vote
- for the lowest bidding node ID */
- if (ni[x].ni_status.ps_msg == M_BID &&
- ni[x].ni_status.ps_nodeid < low_id) {
- low_id = ni[x].ni_status.ps_nodeid;
- msg->m_msg = M_ACK;
- msg->m_arg = ni[x].ni_status.ps_nodeid;
- msg->m_seq = ni[x].ni_status.ps_seq;
- }
- }
-
- if (acks == running)
- return 3;
- if (nacks)
- return 2;
- if (low_id != ctx->qc_my_id)
- return 1;
- return 0;
-}
-
-
-static int
-register_device(qd_ctx *ctx)
-{
- return cman_register_quorum_device(
- ctx->qc_cman_admin,
- (ctx->qc_flags&RF_CMAN_LABEL) ?
- ctx->qc_cman_label : ctx->qc_device,
- (!(ctx->qc_flags & RF_MASTER_WINS) ||
- ctx->qc_status == S_MASTER) ?
- ctx->qc_votes : 0);
-}
-
-static int
-update_device(qd_ctx *ctx)
-{
- return cman_update_quorum_device(
- ctx->qc_cman_admin,
- (ctx->qc_flags&RF_CMAN_LABEL) ?
- ctx->qc_cman_label : ctx->qc_device,
- (!(ctx->qc_flags & RF_MASTER_WINS) ||
- ctx->qc_status == S_MASTER) ?
- ctx->qc_votes : 0);
-}
-
-static int
-adjust_votes(qd_ctx *ctx)
-{
- if (!(ctx->qc_flags & RF_MASTER_WINS))
- return 0;
-
- return register_device(ctx);
-}
-
-
-static void
-print_node_info(FILE *fp, node_info_t *ni)
-{
- uint64_t incarnation;
-
- fprintf(fp, "node_info_t [node %d] {\n", ni->ni_status.ps_nodeid);
-
- incarnation = be_swap64(ni->ni_incarnation);
- fprintf(fp, " ni_incarnation = 0x%08x%08x\n",
- ((int)(incarnation>>32))&0xffffffff,
- ((int)(incarnation)&0xffffffff));
-
- incarnation = be_swap64(ni->ni_evil_incarnation);
- fprintf(fp, " ni_evil_incarnation = 0x%08x%08x\n",
- ((int)(incarnation>>32))&0xffffffff,
- ((int)(incarnation)&0xffffffff));
- fprintf(fp, " ni_last_seen = %s", ctime(&ni->ni_last_seen));
- fprintf(fp, " ni_misses = %d\n", ni->ni_misses);
- fprintf(fp, " ni_seen = %d\n", ni->ni_seen);
- fprintf(fp, " ni_msg = {\n");
- fprintf(fp, " m_msg = 0x%08x\n", ni->ni_msg.m_msg);
- fprintf(fp, " m_arg = %d\n", ni->ni_msg.m_arg);
- fprintf(fp, " m_seq = %d\n", ni->ni_msg.m_seq);
- fprintf(fp, " }\n");
- fprintf(fp, " ni_last_msg = {\n");
- fprintf(fp, " m_msg = 0x%08x\n", ni->ni_last_msg.m_msg);
- fprintf(fp, " m_arg = %d\n", ni->ni_last_msg.m_arg);
- fprintf(fp, " m_seq = %d\n", ni->ni_last_msg.m_seq);
- fprintf(fp, " }\n");
- fprintf(fp, " ni_state = 0x%08x (%s)\n", ni->ni_state,
- state_str(ni->ni_state));
- fprintf(fp, "}\n\n");
-}
-
-
-static void
-update_local_status(qd_ctx *ctx, node_info_t *ni, int max, int score,
- int score_req, int score_max)
-{
- FILE *fp;
- int x, need_close = 0;
- time_t now;
- long flags;
- int fd;
-
- if (!ctx->qc_status_file)
- return;
-
- if (strcmp(ctx->qc_status_file, "-") == 0) {
- fp = stdout;
- } else {
- fp = fopen(ctx->qc_status_file, "w+");
- if (fp == NULL)
- return;
- need_close = 1;
- }
-
- /* Don't block while writing to this file
- * XXX Not set O_NONBLOCK twice on stdout?
- */
- fd = fileno(fp);
- flags = fcntl(fd, F_GETFD, 0);
- if (fcntl(fd, F_SETFD, flags | O_NONBLOCK) != 0) {
- if (need_close)
- fclose(fp);
- return;
- }
-
- now = time(NULL);
- fprintf(fp, "Time Stamp: %s", ctime(&now));
- fprintf(fp, "Node ID: %d\n", ctx->qc_my_id);
-
- fprintf(fp, "Score: %d/%d (Minimum required = %d)\n",
- score, score_max, score_req);
- fprintf(fp, "Current state: %s\n", state_str(ctx->qc_status));
-
- /*
- fprintf(fp, "Current disk state: %s\n",
- state_str(ctx->qc_disk_status));
- */
- fprintf(fp, "Initializing Set: {");
- for (x=0; x<max; x++) {
- if (ni[x].ni_status.ps_state == S_INIT && ni[x].ni_seen)
- fprintf(fp," %d", ni[x].ni_status.ps_nodeid);
- }
- fprintf(fp, " }\n");
-
- fprintf(fp, "Visible Set: {");
- for (x=0; x<max; x++) {
- if (ni[x].ni_state >= S_RUN || ni[x].ni_status.ps_nodeid ==
- ctx->qc_my_id)
- fprintf(fp," %d", ni[x].ni_status.ps_nodeid);
- }
- fprintf(fp, " }\n");
-
- if (ctx->qc_status == S_INIT)
- goto out;
-
- if (ctx->qc_master)
- fprintf(fp, "Master Node ID: %d\n", ctx->qc_master);
- else
- fprintf(fp, "Master Node ID: (none)\n");
-
- if (!ctx->qc_master)
- goto out;
-
- fprintf(fp, "Quorate Set: {");
- for (x=0; x<max; x++) {
- if (is_bit_set(ni[ctx->qc_master-1].ni_status.ps_master_mask,
- ni[x].ni_status.ps_nodeid-1,
- sizeof(memb_mask_t))) {
- fprintf(fp," %d", ni[x].ni_status.ps_nodeid);
- }
- }
-
- fprintf(fp, " }\n");
-
-out:
- if (ctx->qc_flags & RF_DEBUG) {
- for (x = 0; x < max; x++)
- print_node_info(fp, &ni[x]);
- }
-
- fprintf(fp, "\n");
- if (need_close)
- fclose(fp);
-}
-
-static inline int
-_cmp_tv(struct timeval *left, struct timeval *right)
-{
- if (left->tv_sec > right->tv_sec)
- return -1;
-
- if (left->tv_sec < right->tv_sec)
- return 1;
-
- if (left->tv_usec > right->tv_usec)
- return -1;
-
- if (left->tv_usec < right->tv_usec)
- return 1;
-
- return 0;
-}
-
-
-void
-set_priority(int queue, int prio)
-{
- struct sched_param s;
- int ret;
- const char *func = "nice";
-
- if (queue == SCHED_OTHER) {
- s.sched_priority = 0;
- ret = sched_setscheduler(0, queue, &s);
- errno = 0;
- ret = nice(prio);
- } else {
- memset(&s,0,sizeof(s));
- s.sched_priority = prio;
- ret = sched_setscheduler(0, queue, &s);
- func = "sched_setscheduler";
- }
-
- if (ret < 0 && errno) {
- logt_print(LOG_WARNING, "set_priority [%s] failed: %s\n", func,
- strerror(errno));
- }
-}
-
-
-static int
-cman_wait(cman_handle_t ch, struct timeval *_tv)
-{
- fd_set rfds;
- int fd = cman_get_fd(ch);
- struct timeval tv_local = {0, 0};
- struct timeval *tv = _tv;
-
- if (!_tv)
- tv = &tv_local;
-
- FD_ZERO(&rfds);
- FD_SET(fd, &rfds);
- if (select(fd + 1, &rfds, NULL, NULL, tv) == 1) {
- if (cman_dispatch(ch, CMAN_DISPATCH_ALL) < 0) {
- if (errno == EAGAIN)
- return 0;
- return -1;
- }
- }
- return 0;
-}
-
-
-/*
- Listen for cman events
- */
-static void
-process_cman_event(cman_handle_t handle, void *private, int reason, int arg)
-{
- qd_priv_t *qp = (qd_priv_t *)private;
- qd_ctx *ctx = qp->ctx;
-
- switch(reason) {
- case CMAN_REASON_PORTOPENED:
- break;
- case CMAN_REASON_TRY_SHUTDOWN:
- _running = 0;
- _cman_shutdown = 1;
- break;
- case CMAN_REASON_CONFIG_UPDATE:
- get_config_data(ctx, NULL, 0, &fake_cfh);
- break;
- case CMAN_REASON_PORTCLOSED:
- break;
- case CMAN_REASON_STATECHANGE:
- /* Not used */
- break;
- }
-}
-
-
-static int
-quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
-{
- disk_msg_t msg = {0, 0, 0};
- int low_id, bid_pending = 0, score, score_max, score_req,
- upgrade = 0, count, errors, error_cycles = 0;
- memb_mask_t mask, master_mask;
- struct timeval maxtime, oldtime, newtime, diff, sleeptime, interval, rd_lastok, wr_lastok;
-
- ctx->qc_status = S_NONE;
-
- maxtime.tv_usec = 0;
- maxtime.tv_sec = ctx->qc_interval * ctx->qc_tko;
-
- interval.tv_usec = 0;
- interval.tv_sec = ctx->qc_interval;
-
- rd_lastok.tv_usec = 0;
- rd_lastok.tv_sec = 0;
-
- wr_lastok.tv_usec = 0;
- wr_lastok.tv_sec = 0;
-
- get_my_score(&score, &score_max);
- if (score_max < ctx->qc_scoremin) {
- logt_print(LOG_WARNING, "Minimum score (%d) is impossible to "
- "achieve (heuristic total = %d)\n",
- ctx->qc_scoremin, score_max);
- }
-
- _running = 1;
- while (_running) {
- if (_reconfig) {
- get_config_data(ctx, NULL, 0, &fake_cfh);
- _reconfig = 0;
- }
-
- /* XXX this was getuptime() in clumanager */
- get_time(&oldtime, (ctx->qc_flags&RF_UPTIME));
-
- /* Read everyone else's status */
- if ((errors = read_node_blocks(ctx, ni, max)) == 0 )
- get_time(&rd_lastok, ctx->qc_flags&RF_UPTIME);
-
- /* Check for node transitions */
- check_transitions(ctx, ni, max, mask);
-
- /* Check heuristics and remove ourself if necessary */
- get_my_score(&score, &score_max);
-
- /* If we recently upgraded, decrement our wait time */
- if (upgrade > 0)
- --upgrade;
-
- score_req = ctx->qc_scoremin;
- if (score_req <= 0)
- score_req = (score_max/2 + 1);
-
- if (score < score_req) {
- clear_bit(mask, (ctx->qc_my_id-1), sizeof(mask));
- if (ctx->qc_status > S_NONE) {
- logt_print(LOG_NOTICE,
- "Score insufficient for master "
- "operation (%d/%d; required=%d); "
- "downgrading\n",
- score, score_max, score_req);
- ctx->qc_status = S_NONE;
- adjust_votes(ctx);
- msg.m_msg = M_NONE;
- ++msg.m_seq;
- bid_pending = 0;
- if (cman_wait(ctx->qc_cman_user, NULL) < 0) {
- logt_print(LOG_ERR, "cman: %s\n",
- strerror(errno));
- } else {
- cman_poll_quorum_device(ctx->qc_cman_admin, 0);
- }
- if (ctx->qc_flags & RF_REBOOT)
- reboot(RB_AUTOBOOT);
- }
- } else {
- set_bit(mask, (ctx->qc_my_id-1), sizeof(mask));
- if (ctx->qc_status == S_NONE) {
- logt_print(LOG_NOTICE,
- "Score sufficient for master "
- "operation (%d/%d; required=%d); "
- "upgrading\n",
- score, score_max, score_req);
- ctx->qc_status = S_RUN;
- upgrade = ctx->qc_upgrade_wait;
- bid_pending = 0;
- msg.m_msg = M_NONE;
- ++msg.m_seq;
- }
- }
-
- /* Find master */
- ctx->qc_master = master_exists(ctx, ni, max, &low_id, &count);
-
- /* Resolve master conflict, if one exists */
- if (count >= 1 && ctx->qc_status == S_MASTER &&
- ctx->qc_master != ctx->qc_my_id) {
- logt_print(LOG_WARNING, "Master conflict: abdicating\n");
-
- /* Handle just like a recent upgrade */
- ctx->qc_status = S_RUN;
- adjust_votes(ctx);
- upgrade = ctx->qc_upgrade_wait;
- bid_pending = 0;
- msg.m_msg = M_NONE;
- ++msg.m_seq;
- }
-
- /* Figure out what to do based on what we know */
- if (!ctx->qc_master &&
- low_id == ctx->qc_my_id &&
- ctx->qc_status == S_RUN &&
- !bid_pending &&
- !upgrade) {
- /*
- If there's no master, and we are the lowest node
- ID, make a bid to become master if we're not
- already bidding. We can't do this if we've just
- upgraded.
- */
-
- logt_print(LOG_DEBUG,"Making bid for master\n");
- msg.m_msg = M_BID;
- ++msg.m_seq;
- bid_pending = 1;
-
- } else if (!ctx->qc_master && !bid_pending) {
-
- /* We're not the master, and we do not have a bid
- pending. Check for voting on other nodes. */
- do_vote(ctx, ni, max, &msg);
- } else if (!ctx->qc_master && bid_pending) {
-
- /* We're currently bidding for master.
- See if anyone's voted, or if we should
- rescind our bid */
- ++bid_pending;
-
- /* Yes, those are all deliberate fallthroughs */
- switch (check_votes(ctx, ni, max, &msg)) {
- case 3:
- /*
- * Give ample time to become aware of other
- * nodes
- */
- if (bid_pending < (ctx->qc_master_wait))
- break;
-
- logt_print(LOG_INFO,
- "Assuming master role\n");
- ctx->qc_status = S_MASTER;
- adjust_votes(ctx);
- case 2:
- msg.m_msg = M_NONE;
- case 1:
- bid_pending = 0;
- default:
- break;
- }
- } else if (ctx->qc_status == S_MASTER &&
- ctx->qc_master != ctx->qc_my_id) {
-
- /* We think we're master, but someone else claims
- that they are master. */
-
- logt_print(LOG_CRIT,
- "A master exists, but it's not me?!\n");
- /* XXX Handle this how? Should not happen*/
- /* reboot(RB_AUTOBOOT); */
-
- } else if (ctx->qc_status == S_MASTER &&
- ctx->qc_master == ctx->qc_my_id) {
-
- /* We are the master. Poll the quorum device.
- We can't be the master unless we score high
- enough on our heuristics. */
- if (cman_wait(ctx->qc_cman_user, NULL) < 0) {
- logt_print(LOG_ERR, "cman_dispatch: %s\n",
- strerror(errno));
- logt_print(LOG_ERR,
- "Halting qdisk operations\n");
- return -1;
- }
- check_cman(ctx, mask, master_mask);
- if (!errors)
- cman_poll_quorum_device(ctx->qc_cman_admin, 1);
-
- } else if (ctx->qc_status == S_RUN && ctx->qc_master &&
- ctx->qc_master != ctx->qc_my_id) {
-
- /* We're not the master, but a master exists
- Check to see if the master thinks we are
- online. If we are, tell CMAN so. */
- if (is_bit_set(
- ni[ctx->qc_master-1].ni_status.ps_master_mask,
- ctx->qc_my_id-1,
- sizeof(memb_mask_t))) {
- if (cman_wait(ctx->qc_cman_user, NULL) < 0) {
- logt_print(LOG_ERR, "cman_dispatch: %s\n",
- strerror(errno));
- logt_print(LOG_ERR,
- "Halting qdisk operations\n");
- return -1;
- }
- if (!errors) {
- cman_poll_quorum_device(
- ctx->qc_cman_admin,
- 1);
- }
- }
- }
-
- /* Write out our status */
- if (qd_write_status(ctx, ctx->qc_my_id, ctx->qc_status,
- &msg, mask, master_mask) != 0) {
- logt_print(LOG_ERR, "Error writing to quorum disk\n");
- errors++; /* this value isn't really used
- at this point */
- } else {
- get_time(&wr_lastok, ctx->qc_flags&RF_UPTIME);
- }
-
- /* write out our local status */
- update_local_status(ctx, ni, max, score, score_req, score_max);
-
- /* Cycle. We could time the loop and sleep
- (interval-looptime), but this is fine for now.*/
- get_time(&newtime, ctx->qc_flags&RF_UPTIME);
-
- /*
- * Reboot if the last successful hearbeat was longer ago than interval*TKO_COUNT
- */
- _diff_tv(&diff, &wr_lastok, &newtime);
- if (_cmp_tv(&maxtime, &diff) == 1 &&
- ctx->qc_flags & RF_IOTIMEOUT) {
- logt_print(LOG_EMERG, "Failed to send a heartbeat "
- "within %d second%s (%d.%06d) - REBOOTING\n",
- (int)maxtime.tv_sec,
- maxtime.tv_sec==1?"":"s",
- (int)diff.tv_sec,
- (int)diff.tv_usec);
- if (!(ctx->qc_flags & RF_DEBUG))
- reboot(RB_AUTOBOOT);
- }
-
- /*
- * Reboot if the last successful hearbeat was longer ago than interval*TKO_COUNT
- */
- _diff_tv(&diff, &rd_lastok, &newtime);
- if (_cmp_tv(&maxtime, &diff) == 1 &&
- ctx->qc_flags & RF_IOTIMEOUT) {
- logt_print(LOG_EMERG,
- "Failed to read from qdisk within "
- "%d second%s (%d.%06d) - REBOOTING\n",
- (int)maxtime.tv_sec,
- maxtime.tv_sec==1?"":"s",
- (int)diff.tv_sec,
- (int)diff.tv_usec);
- if (!(ctx->qc_flags & RF_DEBUG))
- reboot(RB_AUTOBOOT);
- }
-
- /*
- * Reboot if we didn't send a heartbeat in interval*TKO_COUNT
- */
- _diff_tv(&diff, &oldtime, &newtime);
- if (_cmp_tv(&maxtime, &diff) == 1 &&
- ctx->qc_flags & RF_PARANOID) {
- logt_print(LOG_EMERG, "Failed to complete a cycle within "
- "%d second%s (%d.%06d) - REBOOTING\n",
- (int)maxtime.tv_sec,
- maxtime.tv_sec==1?"":"s",
- (int)diff.tv_sec,
- (int)diff.tv_usec);
- if (!(ctx->qc_flags & RF_DEBUG))
- reboot(RB_AUTOBOOT);
- }
-
- /*
- * If the amount we took to complete a loop is greater or less
- * than our interval, we adjust by the difference each round.
- *
- * It's not really "realtime", but it helps!
- */
- if (_cmp_tv(&diff, &interval) == 1) {
- _diff_tv(&sleeptime, &diff, &interval);
- } else {
- logt_print(LOG_WARNING, "qdisk cycle took more "
- "than %d second%s to complete (%d.%06d)\n",
- ctx->qc_interval, ctx->qc_interval==1?"":"s",
- (int)diff.tv_sec, (int)diff.tv_usec);
- memcpy(&sleeptime, &interval, sizeof(sleeptime));
- }
-
- if (errors && ctx->qc_max_error_cycles) {
- ++error_cycles;
- if (error_cycles >= ctx->qc_max_error_cycles) {
- logt_print(LOG_ALERT,
- "Too many I/O errors; giving up.\n");
- _running = 0;
- }
- } else {
- error_cycles = 0;
- }
-
- /* Could hit a watchdog timer here if we wanted to */
- if (_running) {
- if (cman_wait(ctx->qc_cman_user, &sleeptime) < 0)
- logt_print(LOG_ERR, "cman_dispatch: %s\n",
- strerror(errno));
- }
- }
-
- return !!errors;
-}
-
-
-/**
- Tell the other nodes to elect a new master != me.
- */
-static int
-quorum_reelect_master(qd_ctx *ctx, node_info_t *ni, int max)
-{
- if (qd_write_status(ctx, ctx->qc_my_id, S_EXIT,
- NULL, NULL, NULL) != 0) {
- logt_print(LOG_WARNING,
- "Error writing to quorum disk during reelect_master\n");
- }
-
- while (1) {
- int master, x;
- int found = 0;
- int low_id, count;
-
- read_node_blocks(ctx, ni, max);
-
- for (x = 0; x < max; x++) {
- if (ni[x].ni_state >= S_RUN) {
- found = 1;
- }
- }
-
- if (!found) {
- logt_print(LOG_DEBUG, "No other nodes are active. Exiting\n");
- break;
- }
-
- master = master_exists(ctx, ni, max, &low_id, &count);
- if (master) {
- logt_print(LOG_DEBUG, "New master elected: %d\n", master);
- break;
- }
- /*
- * give time for message to be read
- */
- sleep(1);
- }
-
- return 0;
-}
-
-/**
- Tell the other nodes we're done (safely!).
- */
-static int
-quorum_logout(qd_ctx *ctx)
-{
- /* Write out our status */
- if (qd_write_status(ctx, ctx->qc_my_id, S_NONE,
- NULL, NULL, NULL) != 0) {
- logt_print(LOG_WARNING,
- "Error writing to quorum disk during logout\n");
- }
- return 0;
-}
-
-
-static void
-conf_logging(int debug, int logmode, int facility, int loglevel,
- int filelevel, char *fname)
-{
- static int _log_config = 0;
-
- if (debug)
- _debug |= DEBUG_CONF;
- else
- _debug &= ~DEBUG_CONF;
- if (_debug)
- loglevel = LOG_DEBUG;
- if (_foreground)
- logmode |= LOG_MODE_OUTPUT_STDERR;
-
- if (!_log_config) {
- logt_init(LOG_DAEMON_NAME, logmode, facility, loglevel,
- filelevel, fname);
- _log_config = 1;
- return;
-
- }
-
- logt_conf(LOG_DAEMON_NAME, logmode, facility, loglevel,
- filelevel, fname);
-}
-
-
-static int
-ccs_read_old_logging(int ccsfd, int *facility, int *priority)
-{
- char query[256];
- char *val;
- int x, ret = 0;
-
- /* Get log log_facility */
- snprintf(query, sizeof(query), "/cluster/quorumd/@log_facility");
- if (ccs_get(ccsfd, query, &val) == 0) {
- logt_print(LOG_WARNING,
- "Use of quorumd/@log_facility is deprecated!\n");
- for (x = 0; facilitynames[x].c_name; x++) {
- if (strcasecmp(val, facilitynames[x].c_name))
- continue;
- *facility = facilitynames[x].c_val;
- ret = 1;
- break;
- }
- free(val);
- }
-
- /* Get log level */
- snprintf(query, sizeof(query), "/cluster/quorumd/@log_level");
- if (ccs_get(ccsfd, query, &val) == 0) {
- logt_print(LOG_WARNING,
- "Use of quorumd/@log_level is deprecated!\n");
- *priority = atoi(val);
- free(val);
- if (*priority < 0)
- *priority = SYSLOGLEVEL;
- else
- ret = 1;
- }
-
- return ret;
-}
-
-
-/**
- Grab logsys configuration data from libccs
- */
-static int
-get_log_config_data(int ccsfd)
-{
- char fname[PATH_MAX];
- int debug = 0, logmode = LOG_MODE_OUTPUT_FILE | LOG_MODE_OUTPUT_SYSLOG;
- int facility = SYSLOGFACILITY;
- int loglevel = SYSLOGLEVEL, filelevel = SYSLOGLEVEL;
- int need_close = 0;
-
- logt_print(LOG_DEBUG, "Loading logging configuration\n");
-
- if (ccsfd < 0) {
- ccsfd = ccs_connect();
- if (ccsfd < 0) {
- logt_print(LOG_ERR, "Logging configuration "
- "unavailable; using defaults\n");
- return -1;
- }
- need_close = 1;
- }
-
- snprintf(fname, sizeof(fname)-1, LOGDIR "/qdiskd.log");
- if (ccs_read_old_logging(ccsfd, &facility, &loglevel))
- filelevel = loglevel;
-
- ccs_read_logging(ccsfd, (char *)"QDISKD", &debug, &logmode,
- &facility, &loglevel, &filelevel, (char *)fname);
- conf_logging(debug, logmode, facility, loglevel, filelevel, fname);
-
- if (need_close)
- ccs_disconnect(ccsfd);
-
- return 0;
-}
-
-
-/*
- * return number of nodes - 1 on success
- * -1 on generic error
- * -2 if one of the node votes is != 1
- */
-static int
-auto_qdisk_votes(int desc)
-{
- int ret = 1;
- char buf[PATH_MAX];
- char *v = NULL, *name = NULL;
-
- while (1) {
- int votes=0;
-
- name = NULL;
- snprintf(buf, sizeof(buf)-1,
- "/cluster/clusternodes/clusternode[%d]/@name", ret);
- if (ccs_get(desc, buf, &name) != 0)
- break;
-
- snprintf(buf, sizeof(buf)-1,
- "/cluster/clusternodes/clusternode[%d]/@votes", ret);
-
- if (ccs_get(desc, buf, &v) == 0) {
- votes = atoi(v);
- free(v);
- v = NULL;
- } else {
- votes = 1;
- }
-
- if (votes != 1) {
-
- logt_print(LOG_ERR, "%s's vote count is %d\n",
- name, votes);
- free(name);
-
- logt_print(LOG_ERR, "Set all node vote counts to 1 "
- "or specify qdiskd's votes\n");
- return -2;
- }
-
- free(name);
- ret++;
- }
-
- // adjust count (one from init and one from the node count)
- ret = ret - 2;
-
- if (ret <= 0)
- logt_print(LOG_ERR, "Unable to determine qdiskd votes "
- "automatically\n");
- else
- logt_print(LOG_DEBUG, "Setting autocalculated votes to %d\n", ret);
-
- return (ret);
-}
-
-
-static int
-get_dynamic_config_data(qd_ctx *ctx, int ccsfd)
-{
- char *val = NULL;
- char query[256];
- int old_votes = 0, found = 0;
-
- if (ccsfd < 0)
- return -1;
-
- logt_print(LOG_DEBUG, "Loading dynamic configuration\n");
-
- /* Check label / device presence. If it disappeared, we need to exit */
- if (ctx->qc_config) {
- val = NULL;
- snprintf(query, sizeof(query), "/cluster/quorumd/@device");
- found = ccs_get(ccsfd, query, &val);
- if (found != 0) {
- val = NULL;
- snprintf(query, sizeof(query), "/cluster/quorumd/@label");
- found = ccs_get(ccsfd, query, &val);
- free(val);
- }
-
- if (found != 0) {
- logt_print(LOG_NOTICE,
- "Quorum device removed from the configuration."
- " Shutting down.\n");
- ctx->qc_votes = 0;
- register_device(ctx);
- _running = 0;
- return -1;
- }
- }
-
- /* Get status file */
- snprintf(query, sizeof(query), "/cluster/quorumd/@status_file");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_status_file = val;
- }
-
- /* Get scheduling queue */
- snprintf(query, sizeof(query), "/cluster/quorumd/@scheduler");
- if (ccs_get(ccsfd, query, &val) == 0) {
- switch(val[0]) {
- case 'r':
- case 'R':
- ctx->qc_sched = SCHED_RR;
- break;
- case 'f':
- case 'F':
- ctx->qc_sched = SCHED_FIFO;
- break;
- case 'o':
- case 'O':
- ctx->qc_sched = SCHED_OTHER;
- break;
- default:
- logt_print(LOG_WARNING,
- "Invalid scheduling queue '%s'\n", val);
- break;
- }
- free(val);
- }
-
- /* Get priority */
- snprintf(query, sizeof(query), "/cluster/quorumd/@priority");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_sched_prio = atoi(val);
- free(val);
- }
- set_priority(ctx->qc_sched, ctx->qc_sched_prio);
-
- /* Get reboot flag for when we transition -> offline */
- /* default = on, so, 0 to turn off */
- snprintf(query, sizeof(query), "/cluster/quorumd/@reboot");
- if (ccs_get(ccsfd, query, &val) == 0) {
- if (!atoi(val))
- ctx->qc_flags &= ~RF_REBOOT;
- free(val);
- }
-
- /*
- * Get flag to see if we're supposed to kill cman if qdisk is not
- * available.
- */
- /* default = off, so, 1 to turn on */
- snprintf(query, sizeof(query), "/cluster/quorumd/@stop_cman");
- if (ccs_get(ccsfd, query, &val) == 0) {
- if (!atoi(val))
- ctx->qc_flags &= ~RF_STOP_CMAN;
- else
- ctx->qc_flags |= RF_STOP_CMAN;
- free(val);
- }
-
- /* default = off, so, 1 to turn on */
- snprintf(query, sizeof(query), "/cluster/quorumd/@io_timeout");
- if (ccs_get(ccsfd, query, &val) == 0) {
- if (!atoi(val))
- ctx->qc_flags &= ~RF_IOTIMEOUT;
- else
- ctx->qc_flags |= RF_IOTIMEOUT;
- free(val);
- }
-
- /*
- * Get flag to see if we're supposed to reboot if we can't complete
- * a pass in failure time
- */
- /* default = off, so, 1 to turn on */
- snprintf(query, sizeof(query), "/cluster/quorumd/@paranoid");
- if (ccs_get(ccsfd, query, &val) == 0) {
- if (!atoi(val))
- ctx->qc_flags &= ~RF_PARANOID;
- else
- ctx->qc_flags |= RF_PARANOID;
- free(val);
- }
-
- /*
- * Get flag to see if we're supposed to reboot if we can't complete
- * a pass in failure time
- */
- /* default = off, so, 1 to turn on */
- snprintf(query, sizeof(query), "/cluster/quorumd/@allow_kill");
- if (ccs_get(ccsfd, query, &val) == 0) {
- if (!atoi(val))
- ctx->qc_flags &= ~RF_ALLOW_KILL;
- else
- ctx->qc_flags |= RF_ALLOW_KILL;
- free(val);
- }
-
- /*
- * How many consecutive error cycles do we allow before
- * giving up?
- *
- * Notice that max_error_cycles is disabled if io_timeout is
- * active.
- */
- /* default = no max */
- snprintf(query, sizeof(query), "/cluster/quorumd/@max_error_cycles");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_max_error_cycles = atoi(val);
- if ((ctx->qc_max_error_cycles <= 0) || (ctx->qc_flags & RF_IOTIMEOUT))
- ctx->qc_max_error_cycles = 0;
- free(val);
- }
-
- /* Get votes */
- if (ctx->qc_config) {
- old_votes = ctx->qc_votes;
- ctx->qc_flags &= ~RF_AUTO_VOTES;
- }
-
- ctx->qc_auto_votes = auto_qdisk_votes(ccsfd);
-
- snprintf(query, sizeof(query), "/cluster/quorumd/@votes");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_votes = atoi(val);
- free(val);
- if (ctx->qc_votes < 0)
- ctx->qc_votes = 0;
- } else {
- ctx->qc_votes = ctx->qc_auto_votes;
- if (ctx->qc_votes < 0) {
- if (ctx->qc_config) {
- logt_print(LOG_WARNING, "Unable to determine "
- "new vote value; retaining old "
- "value of %d\n", old_votes);
- ctx->qc_votes = old_votes;
- } else {
- /* During startup, this is fatal */
- return -1;
- }
- } else {
- ctx->qc_flags |= RF_AUTO_VOTES;
- }
- }
-
- if (ctx->qc_config && old_votes != ctx->qc_votes) {
- logt_print(LOG_DEBUG, "Changing vote count from %d to %d\n",
- old_votes, ctx->qc_votes);
-
- if (ctx->qc_flags & RF_AUTO_MASTER_WINS) {
- logt_print(LOG_DEBUG, "Vote count changed! "
- "Disabling master-wins\n");
- ctx->qc_flags &= ~(RF_MASTER_WINS|RF_AUTO_MASTER_WINS);
- }
-
- /*
- * Here, we are reconfiguring _only_ the votes. The
- * label / cman runflags do not change during reconfiguration
- *
- * This only works after we have already gotten static
- * configuration data during initial startup.
- */
- register_device(ctx);
- }
-
- return 0;
-}
-
-
-static int
-get_static_config_data(qd_ctx *ctx, int ccsfd)
-{
- char *val = NULL;
- char query[256];
- int qdisk_fo;
-
- if (ccsfd < 0)
- return -1;
-
- logt_print(LOG_DEBUG, "Loading static configuration\n");
-
- /* Get interval */
- snprintf(query, sizeof(query), "/cluster/quorumd/@interval");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_interval = atoi(val);
- free(val);
- if (ctx->qc_interval < 1)
- ctx->qc_interval = 1;
- }
-
- snprintf(query, sizeof(query), "/cluster/totem/@token");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_token_timeout = atoi(val);
- free(val);
- if (ctx->qc_token_timeout < 10000) {
- logt_print(LOG_ERR, "Token timeout %d is too fast "
- "to use with qdiskd!\n",
- ctx->qc_token_timeout);
- return -1;
- }
- } else {
- ctx->qc_token_timeout = DEFAULT_TOKEN_TIMEOUT;
- }
-
- /* Get tko */
- snprintf(query, sizeof(query), "/cluster/quorumd/@tko");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_tko = atoi(val);
- free(val);
- } else {
- ctx->qc_tko = ((ctx->qc_token_timeout / 1000) -
- ctx->qc_interval) / 2;
- logt_print(LOG_DEBUG, "Auto-configured TKO as %d based on "
- "token=%d interval=%d\n", ctx->qc_tko,
- ctx->qc_token_timeout, ctx->qc_interval);
- }
-
- if (ctx->qc_tko < 4) {
- logt_print(LOG_WARNING, "Quorum disk TKO (%d) is too low!\n",
- ctx->qc_tko);
- }
-
- /* Get up-tko (transition off->online) */
- ctx->qc_tko_up = (ctx->qc_tko / 3);
- snprintf(query, sizeof(query), "/cluster/quorumd/@tko_up");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_tko_up = atoi(val);
- free(val);
- }
- if (ctx->qc_tko_up < 2)
- ctx->qc_tko_up = 2;
-
- /* After coming online, wait this many intervals before
- being allowed to bid for master. */
- ctx->qc_upgrade_wait = 2; /* (ctx->qc_tko / 3); */
- snprintf(query, sizeof(query), "/cluster/quorumd/@upgrade_wait");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_upgrade_wait = atoi(val);
- free(val);
- }
- if (ctx->qc_upgrade_wait < 1)
- ctx->qc_upgrade_wait = 1;
-
- /* wait this many intervals after bidding for master before
- becoming Caesar */
- ctx->qc_master_wait = (ctx->qc_tko / 2);
- snprintf(query, sizeof(query), "/cluster/quorumd/@master_wait");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_master_wait = atoi(val);
- free(val);
- }
- if (ctx->qc_master_wait <= ctx->qc_tko_up)
- ctx->qc_master_wait = ctx->qc_tko_up + 1;
-
- logt_print(LOG_DEBUG, "Timings: %d tko, %d interval\n",
- ctx->qc_tko, ctx->qc_interval);
- logt_print(LOG_DEBUG, "Timings: %d tko_up, %d master_wait, "
- "%d upgrade_wait\n",
- ctx->qc_tko_up, ctx->qc_master_wait, ctx->qc_upgrade_wait);
-
- qdisk_fo = ctx->qc_interval * (ctx->qc_master_wait +
- ctx->qc_upgrade_wait +
- ctx->qc_tko) * 1000;
- if (qdisk_fo >= ctx->qc_token_timeout) {
- logt_print(LOG_ERR, "Quorum disk timings are too slow for "
- "configured token timeout\n");
- logt_print(LOG_ERR, " * Totem Token timeout: %dms\n",
- ctx->qc_token_timeout);
- logt_print(LOG_ERR, " * Min. Master recovery time: %dms\n",
- qdisk_fo);
- logt_print(LOG_ERR,
- "Please set token timeout to at least %dms\n",
- qdisk_fo + (ctx->qc_interval * 1000));
- return -1;
- }
-
- /* Get device */
- snprintf(query, sizeof(query), "/cluster/quorumd/@device");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_device = val;
- }
-
- /* Get label (overrides device) */
- snprintf(query, sizeof(query), "/cluster/quorumd/@label");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_label = val;
- /* courtesy info message */
- if (ctx->qc_device)
- logt_print(LOG_INFO, "Quorum Label (%s) will be used to "
- "locate quorum partition, overriding Quorum Device\n",
- ctx->qc_label);
- }
-
- if (!ctx->qc_device && !ctx->qc_label) {
- logt_print(LOG_ERR, "No device or label specified; cannot "
- "run QDisk services.\n");
- return -1;
- }
-
- /* Get min score */
- snprintf(query, sizeof(query), "/cluster/quorumd/@min_score");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_scoremin = atoi(val);
- free(val);
- if (ctx->qc_scoremin < 0)
- ctx->qc_scoremin = 0;
- }
-
- /* Get master-wins flag for when we transition -> offline */
- /* default = off, so, 1 to turn on */
- snprintf(query, sizeof(query), "/cluster/quorumd/@master_wins");
- if (ccs_get(ccsfd, query, &val) == 0) {
- if (atoi(val))
- ctx->qc_flags |= RF_MASTER_WINS;
- free(val);
- }
-
- /* Get cman_label */
- snprintf(query, sizeof(query), "/cluster/quorumd/@cman_label");
- if (ccs_get(ccsfd, query, &val) == 0) {
- if (strlen(val) > 0) {
- ctx->qc_flags |= RF_CMAN_LABEL;
- ctx->qc_cman_label = val;
- }
- }
-
- /*
- * Get flag to see if we're supposed to use /proc/uptime instead of
- * gettimeofday(2)
- */
- /* default = off, so, 1 to turn on */
- snprintf(query, sizeof(query), "/cluster/quorumd/@use_uptime");
- if (ccs_get(ccsfd, query, &val) == 0) {
- if (!atoi(val))
- ctx->qc_flags &= ~RF_UPTIME;
- else
- ctx->qc_flags |= RF_UPTIME;
- free(val);
- }
-
- return 0;
-}
-
-
-/**
- Grab all our configuration data from libccs
- */
-static int
-get_config_data(qd_ctx *ctx, struct h_data *h, int maxh, int *cfh)
-{
- int ccsfd = -1, ret = -1;
-
- ccsfd = ccs_connect();
- if (ccsfd < 0) {
- logt_print(LOG_CRIT, "Configuration unavailable; "
- "cannot start\n");
- return -1;
- }
-
- get_log_config_data(ccsfd);
-
- /* Initialize defaults if we are not reconfiguring */
- if (ctx->qc_config == 0) {
- ctx->qc_interval = 1;
- ctx->qc_tko = 10;
- ctx->qc_scoremin = 0;
- ctx->qc_flags = RF_REBOOT | RF_ALLOW_KILL | RF_UPTIME;
- /* | RF_STOP_CMAN;*/
-
- ctx->qc_sched = SCHED_RR;
- ctx->qc_sched_prio = 1;
- ctx->qc_max_error_cycles = 0;
- }
-
- if (get_dynamic_config_data(ctx, ccsfd) < 0) {
- goto out;
- }
-
- if (ctx->qc_config) {
- ret = 0;
- goto out;
- }
-
- ctx->qc_config = 1;
-
- if (get_static_config_data(ctx, ccsfd) < 0) {
- goto out;
- }
-
- /* Heuristics need to report in 1 cycle before we need to
- * report in so we can get their score.
- */
- *cfh = configure_heuristics(ccsfd, h, maxh,
- ctx->qc_interval * (ctx->qc_tko - 1));
-
- if (ctx->qc_flags & RF_MASTER_WINS) {
- if (*cfh) {
- logt_print(LOG_WARNING, "Master-wins mode disabled "
- "(not compatible with heuristics)\n");
- ctx->qc_flags &= ~RF_MASTER_WINS;
- }
- if (ctx->qc_auto_votes != 1) {
- logt_print(LOG_WARNING, "Master-wins mode disabled "
- "(not compatible with more than 2 nodes)\n");
- ctx->qc_flags &= ~RF_MASTER_WINS;
- }
- } else {
- if (ctx->qc_flags & RF_AUTO_VOTES &&
- !*cfh &&
- ctx->qc_auto_votes == 1) {
- /* Two node cluster, no heuristics, 1 vote for
- * quorum disk daemon. Safe to enable master-wins.
- * In fact, qdiskd without master-wins in this config
- * is a waste of resources.
- */
- ctx->qc_flags |= RF_MASTER_WINS | RF_AUTO_MASTER_WINS;
- logt_print(LOG_INFO, "Enabling master-wins mode for "
- "simple two-node cluster\n");
- }
- }
-
- ret = 0;
-
- logt_print(LOG_DEBUG, "Quorum Daemon: %d heuristics, "
- "%d interval, %d tko, %d votes\n",
- *cfh, ctx->qc_interval, ctx->qc_tko, ctx->qc_votes);
- logt_print(LOG_DEBUG, "Run Flags: %08x\n", ctx->qc_flags);
-out:
- ccs_disconnect(ccsfd);
-
- return ret;
-}
-
-
-static void
-check_stop_cman(qd_ctx *ctx)
-{
- if (!(ctx->qc_flags & RF_STOP_CMAN))
- return;
-
- logt_print(LOG_WARNING, "Telling CMAN to leave the cluster; "
- "qdisk is not available\n");
- if (cman_shutdown(ctx->qc_cman_admin, 0) < 0) {
- logt_print(LOG_CRIT,
- "Could not leave the cluster - rebooting\n");
- sleep(5);
- if (ctx->qc_flags & RF_DEBUG) {
- logt_print(LOG_CRIT, "Debug mode specified! "
- "Reboot averted.\n");
- return;
- }
- reboot(RB_AUTOBOOT);
- }
-}
-
-
-#define logt_print_once(level, fmt, args...) \
-do { static int _logged=0; if (!_logged) { _logged=1; logt_print(level, fmt, ##args); } } while(0)
-
-
-static void
-qdisk_whine(cman_handle_t h, void *privdata, char *buf, int len,
- uint8_t port, int nodeid)
-{
- int32_t dstate;
- qd_priv_t *qp = (qd_priv_t *)privdata;
- node_info_t *ni = qp->ni;
-
- if (len != sizeof(dstate)) {
- return;
- }
-
- dstate = *((int32_t*)buf);
-
- if (nodeid == (qp->ctx->qc_my_id))
- return;
-
- swab32(dstate);
-
- if (dstate) {
- logt_print(LOG_NOTICE, "qdiskd on node %d reports hung %s()\n", nodeid,
- state_to_string(dstate));
- ni[nodeid-1].ni_misses = 0;
- }
-}
-
-
-int
-main(int argc, char **argv)
-{
- cman_node_t me;
- int cfh = 0, rv, nfd = -1, ret = -1, active;
- qd_ctx ctx;
- cman_handle_t ch_admin = NULL;
- cman_handle_t ch_user = NULL;
- node_info_t ni[MAX_NODES_DISK];
- struct h_data h[10];
- char device[128];
- pid_t pid;
- quorum_header_t qh;
- qd_priv_t qp;
-
-
- rv = check_process_running(argv[0], &pid);
- if (rv < 0) {
- fprintf(stderr, "Unable to determin if %s is already running: %s\n",
- argv[0], strerror(errno));
- return -1;
- }
- if (rv && pid !=getpid()) {
- printf("QDisk services already running\n");
- return 0;
- }
-
- while ((rv = getopt(argc, argv, "fdQs")) != EOF) {
- switch (rv) {
- case 'd':
- _debug = DEBUG_CMDLINE;
- break;
- case 'f':
- _foreground = 1;
- break;
- case 'Q':
- /* Make qdisk very quiet */
- nfd = open("/dev/null", O_RDWR);
- if (nfd < 0) {
- fprintf(stderr, "Could not open /dev/null!\n");
- ret = -1;
- goto out;
- }
- close(0);
- close(1);
- close(2);
- dup2(nfd, 0);
- dup2(nfd, 1);
- dup2(nfd, 2);
- close(nfd);
- break;
- default:
- break;
- }
- }
-
- if(getenv("QDISK_DEBUG"))
- _debug = 1;
-
- if (!_foreground && daemon_init(argv[0]) < 0) {
- fprintf(stderr, "Could not fork: %s\n", strerror(errno));
- goto out;
- }
-
- conf_logging(0, LOG_MODE_OUTPUT_SYSLOG, SYSLOGFACILITY,
- SYSLOGLEVEL, 0, NULL);
-
- while (_running && (ch_admin = cman_admin_init(NULL)) == NULL) {
- logt_print_once(LOG_INFO, "Waiting for CMAN to start\n");
- sleep(1);
- }
-
- while (_running && (active = cman_is_active(ch_admin)) <= 0) {
- logt_print_once(LOG_INFO,
- "Waiting for CMAN to become active\n");
- if (active < 0) {
- logt_print(LOG_CRIT, "cman_is_active: %s\n",
- strerror(errno));
- goto out;
- }
- sleep(1);
- }
-
- if (!_running)
- goto out;
-
- /* For cman notifications we need two sockets - one for events,
- one for config change callbacks */
- qp.ctx = &ctx;
- qp.ni = &ni[0];
- qp.ni_len = MAX_NODES_DISK;
-
- ch_user = cman_init(&qp);
- if (cman_start_notification(ch_user, process_cman_event) != 0) {
- logt_print(LOG_CRIT, "Could not register with CMAN: %s\n",
- strerror(errno));
- goto out;
- }
-
- if (cman_start_recv_data(ch_user, qdisk_whine, CLUSTER_PORT_QDISKD) != 0) {
- logt_print(LOG_CRIT, "Could not register with CMAN: %s\n",
- strerror(errno));
- goto out;
- }
-
- memset(&me, 0, sizeof(me));
- if (cman_get_node(ch_admin, CMAN_NODEID_US, &me) < 0) {
- logt_print(LOG_CRIT, "Could not determine local node ID: %s\n",
- strerror(errno));
- goto out;
- }
-
- qd_init(&ctx, ch_admin, ch_user, me.cn_nodeid);
-
- signal(SIGINT, int_handler);
- signal(SIGTERM, int_handler);
- signal(SIGHUP, hup_handler);
- signal(SIGUSR1, usr1_handler);
-
- /* RF_DEBUG can only be set from the command line */
- if (_debug)
- ctx.qc_flags |= RF_DEBUG;
-
- if (get_config_data(&ctx, h, 10, &cfh) < 0) {
- logt_print(LOG_CRIT, "Configuration failed\n");
- check_stop_cman(&ctx);
- goto out;
- }
-
- if (ctx.qc_label) {
- ret = find_partitions(ctx.qc_label, device, sizeof(device), 0);
- if (ret < 0) {
- logt_print(LOG_CRIT, "Unable to match label"
- " '%s' to any device\n",
- ctx.qc_label);
- check_stop_cman(&ctx);
- goto out;
- } else if (ret > 0) {
- logt_print(LOG_WARNING, "%d matches found for "
- "label '%s'; please use 'device=' "
- "instead!\n", ret, ctx.qc_label);
- }
-
- if (ctx.qc_device)
- free(ctx.qc_device);
- ctx.qc_device = strdup(device);
-
- logt_print(LOG_INFO, "Quorum Partition: %s Label: %s\n",
- ctx.qc_device, ctx.qc_label);
- } else if (ctx.qc_device) {
- if (check_device(ctx.qc_device, NULL, &qh, 0) != 0) {
- logt_print(LOG_CRIT,
- "Specified partition %s does not have a "
- "qdisk label\n", ctx.qc_device);
- check_stop_cman(&ctx);
- goto out;
- }
-
- if (qh.qh_version == VERSION_MAGIC_V2 &&
- qh.qh_blksz != qh.qh_kernsz) {
- logt_print(LOG_CRIT,
- "Specified device %s does not match kernel's "
- "reported sector size (%lu != %lu)\n",
- ctx.qc_device,
- (unsigned long)qh.qh_blksz,
- (unsigned long)qh.qh_kernsz);
- check_stop_cman(&ctx);
- goto out;
- }
- }
-
- ret = quorum_init(&ctx, ni, MAX_NODES_DISK, h, cfh);
- if (ret < 0) {
- logt_print(LOG_CRIT, "Initialization failed\n");
- check_stop_cman(&ctx);
- goto out;
- } else if (ret > 0) {
- /* ret > 0 means we received a shutdown during initialization */
- /* Write our 'clean down' state to disk and get out of here */
- logt_print(LOG_INFO, "Shutdown request received during initialization\n");
- quorum_logout(&ctx);
- goto out;
- }
-
- ret = 0;
-
- if (!_running)
- goto out;
-
- /* This registers the quorum device */
- ret = register_device(&ctx);
- if (ret) {
- if (errno == EBUSY) {
- logt_print(LOG_NOTICE, "quorum device is already registered, updating\n");
- ret = update_device(&ctx);
- if (ret) {
- logt_print(LOG_ERR, "Unable to update quorum device info!\n");
- goto out;
- }
- } else {
- logt_print(LOG_ERR, "Unable to register quorum device!\n");
- goto out;
- }
- }
-
- io_nanny_start(ch_user, ctx.qc_tko * ctx.qc_interval);
-
- if (quorum_loop(&ctx, ni, MAX_NODES_DISK) == 0) {
- /*
- * if we are master and we are in master-win mode,
- * request other qdiskd to elect a new one
- */
- if ((ctx.qc_status == S_MASTER) &&
- ((ctx.qc_flags & RF_MASTER_WINS) ||
- (ctx.qc_flags & RF_AUTO_MASTER_WINS))) {
- quorum_reelect_master(&ctx, ni, MAX_NODES_DISK);
- }
- /* Only clean up if we're exiting w/o error) */
- logt_print(LOG_NOTICE, "Unregistering quorum device.\n");
- cman_unregister_quorum_device(ctx.qc_cman_admin);
- quorum_logout(&ctx);
- }
-
- io_nanny_stop();
-
-out:
- /* free cman handle to avoid leak in cman */
- cman_finish(ch_admin);
- if (_cman_shutdown) {
- cman_replyto_shutdown(ch_user, 1);
- cman_finish(ch_user);
- }
- qd_destroy(&ctx);
- logt_exit();
- daemon_cleanup();
- return ret;
-}
-
diff --git a/cman/qdisk/mkqdisk.c b/cman/qdisk/mkqdisk.c
deleted file mode 100644
index 6d64ee5..0000000
--- a/cman/qdisk/mkqdisk.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- @file Quorum disk utility
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <disk.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <platform.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <liblogthread.h>
-
-#define PROGRAM_NAME "mkqdisk"
-
-int
-main(int argc, char **argv)
-{
- char device[128];
- char *newdev = NULL, *newlabel = NULL;
- int rv, flg = 0, verbose_level = 1;
-
- printf(PROGRAM_NAME " v" RELEASE_VERSION "\n\n");
-
- /* XXX this is horrible but we need to prioritize options as long as
- * we can't queue messages properly
- */
- while ((rv = getopt(argc, argv, "Ldf:c:l:h")) != EOF) {
- switch (rv) {
- case 'd':
- ++verbose_level;
- if (verbose_level > LOG_DEBUG)
- verbose_level = LOG_DEBUG;
- break;
- }
- }
-
- logt_init(PROGRAM_NAME, LOG_MODE_OUTPUT_STDERR,
- verbose_level, verbose_level, verbose_level, NULL);
-
- /* reset the option index to reparse */
- optind = 0;
-
- while ((rv = getopt(argc, argv, "Ldf:c:l:h")) != EOF) {
- switch (rv) {
- case 'd':
- /* processed above, needs to be here for compat */
- break;
- case 'L':
- /* List */
- flg = rv;
- break;
- case 'f':
- flg = rv;
- newlabel = optarg;
- break;
- case 'c':
- newdev = optarg;
- break;
- case 'l':
- newlabel = optarg;
- break;
- case 'h':
- printf("usage: mkqdisk -L | -f <label> | -c "
- "<device> -l <label> [-d]\n");
- return 0;
- default:
- break;
- }
- }
-
- /* list */
- if (flg == 'L') {
- return find_partitions(NULL, NULL, 0, verbose_level);
- } else if (flg == 'f') {
- return find_partitions( newlabel, device,
- sizeof(device), verbose_level);
- }
-
- if (!newdev && !newlabel) {
- printf("usage: mkqdisk -L | -f <label> | -c "
- "<device> -l <label>\n");
- return 1;
- }
-
- if (!newdev || !newlabel) {
- printf("Both a device and a label are required\n");
- return 1;
- }
-
- printf("Writing new quorum disk label '%s' to %s.\n",
- newlabel, newdev);
- printf("WARNING: About to destroy all data on %s; proceed [N/y] ? ",
- newdev);
- if (getc(stdin) != 'y') {
- printf("Good thinking.\n");
- return 0;
- }
-
- return qdisk_init(newdev, newlabel);
-}
diff --git a/cman/qdisk/platform.h b/cman/qdisk/platform.h
deleted file mode 100644
index b1dfc64..0000000
--- a/cman/qdisk/platform.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/** @file
- * Defines for byte-swapping
- */
-#ifndef __PLATFORM_H
-#define __PLATFORM_H
-
-#include <endian.h>
-#include <sys/param.h>
-#include <byteswap.h>
-#include <bits/wordsize.h>
-
-/* No swapping on little-endian machines */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define le_swap16(x) (x)
-#define le_swap32(x) (x)
-#define le_swap64(x) (x)
-#else
-#define le_swap16(x) bswap_16(x)
-#define le_swap32(x) bswap_32(x)
-#define le_swap64(x) bswap_64(x)
-#endif
-
-/* No swapping on big-endian machines */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define be_swap16(x) bswap_16(x)
-#define be_swap32(x) bswap_32(x)
-#define be_swap64(x) bswap_64(x)
-#else
-#define be_swap16(x) (x)
-#define be_swap32(x) (x)
-#define be_swap64(x) (x)
-#endif
-
-
-#define swab16(x) x=be_swap16(x)
-#define swab32(x) x=be_swap32(x)
-#define swab64(x) x=be_swap64(x)
-
-
-#endif /* __PLATFORM_H */
diff --git a/cman/qdisk/proc.c b/cman/qdisk/proc.c
deleted file mode 100644
index 688a4d1..0000000
--- a/cman/qdisk/proc.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- @file Quorum disk /proc/partition scanning functions
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <disk.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <platform.h>
-#include <stdlib.h>
-#include <string.h>
-#include <liblogthread.h>
-#include "scandisk.h"
-
-const char *state_str(disk_node_state_t s);
-
-struct device_args {
- char *label;
- struct devnode *devnode;
- int sector_size;
- int flags;
- int count;
- int pad;
-};
-
-int
-check_device(char *device, char *label, quorum_header_t *qh,
- int flags)
-{
- int ret = -1;
- quorum_header_t qh_local;
- target_info_t disk;
-
- if (!qh)
- qh = &qh_local;
-
- ret = qdisk_validate(device);
- if (ret < 0) {
- logt_print(LOG_DEBUG, "qdisk_validate: %s\n", strerror(errno));
- return -1;
- }
-
- ret = qdisk_open(device, &disk);
- if (ret < 0) {
- logt_print(LOG_ERR, "qdisk_open: %s\n", strerror(errno));
- return -1;
- }
-
- ret = -1;
- if (qdisk_read(&disk, OFFSET_HEADER, qh, sizeof(*qh)) == sizeof(*qh)) {
- swab_quorum_header_t(qh);
- if (qh->qh_magic == HEADER_MAGIC_NUMBER) {
- if (!label || !strcmp(qh->qh_cluster, label)) {
- ret = 0;
- }
- }
- }
-
- qh->qh_kernsz = disk.d_blksz;
-
- /* only flag now is 'strict device check'; i.e.,
- "block size recorded must match kernel's reported size" */
- if (flags && qh->qh_version == VERSION_MAGIC_V2 &&
- disk.d_blksz != qh->qh_blksz) {
- ret = -1;
- }
-
- qdisk_close(&disk);
-
- return ret;
-}
-
-
-static void
-filter_devs(struct devnode *node, void *v_args)
-{
- struct device_args *args = (struct device_args *)v_args;
- quorum_header_t qh;
- quorum_header_t *ret_qh = NULL;
- int ret;
-
- if (!node->sysfsattrs.sysfs)
- return;
- if (!node->devpath)
- return;
- if (node->sysfsattrs.holders)
- return;
- /* Qdiskd doesn't work on soft-raid */
- if (node->md > 0)
- return;
-
- ret = check_device(node->devpath->path, args->label, &qh, args->flags);
- if (ret == 0) {
- ret_qh = malloc(sizeof(qh));
- if (!ret_qh)
- return;
- memcpy(ret_qh, &qh, sizeof(qh));
-
- node->filter = (void *)ret_qh;
- if (!args->count) {
- args->devnode = node;
- }
- ++args->count;
- }
-}
-
-
-const char *
-state_str(disk_node_state_t s)
-{
- switch (s) {
- case S_NONE:
- return "None";
- case S_EVICT:
- return "Evicted";
- case S_INIT:
- return "Initializing";
- case S_RUN:
- return "Running";
- case S_MASTER:
- return "Master";
- default:
- return "ILLEGAL";
- }
-}
-
-
-static void
-print_status_block(status_block_t *sb)
-{
- time_t timestamp = (time_t)sb->ps_timestamp;
- uint64_t incarnation = be_swap64(sb->ps_incarnation);
-
- if (sb->ps_state == S_NONE)
- return;
- logt_print(LOG_INFO, "Status block for node %d\n", sb->ps_nodeid);
- logt_print(LOG_INFO, "\tLast updated by node %d\n", sb->ps_updatenode);
- logt_print(LOG_INFO, "\tLast updated on %s", ctime((time_t *)×tamp));
- logt_print(LOG_INFO, "\tState: %s\n", state_str(sb->ps_state));
- logt_print(LOG_INFO, "\tFlags: %04x\n", (be_swap16(sb->ps_flags)));
- logt_print(LOG_INFO, "\tScore: %d/%d\n", sb->ps_score, sb->ps_scoremax);
- logt_print(LOG_INFO, "\tAverage Cycle speed: %d.%06d seconds\n",
- sb->ps_ca_sec, sb->ps_ca_usec);
- logt_print(LOG_INFO, "\tLast Cycle speed: %d.%06d seconds\n",
- sb->ps_lc_sec, sb->ps_lc_usec);
- logt_print(LOG_INFO, "\tIncarnation: %08x%08x\n",
- (int)(incarnation>>32&0xffffffff),
- (int)(incarnation&0xffffffff));
-
-}
-
-
-static void
-read_info(char *dev)
-{
- target_info_t ti;
- int x;
- status_block_t sb;
-
- if (qdisk_open(dev, &ti) < 0) {
- logt_print(LOG_ERR, "Could not read from %s: %s\n",
- dev, strerror(errno));
- return;
- }
-
- for (x = 0; x < MAX_NODES_DISK; x++) {
-
- if (qdisk_read(&ti,
- qdisk_nodeid_offset(x+1, ti.d_blksz),
- &sb, sizeof(sb)) < 0) {
- logt_print(LOG_ERR, "Error reading node ID block %d\n",
- x+1);
- continue;
- }
- swab_status_block_t(&sb);
- print_status_block(&sb);
- }
-
- qdisk_close(&ti);
-}
-
-
-static void
-print_qdisk_info(struct devnode *dn)
-{
- quorum_header_t *qh = (quorum_header_t *)dn->filter;
- struct devpath *dp;
- time_t timestamp = (time_t)qh->qh_timestamp;
-
- for (dp = dn->devpath; dp; dp = dp->next)
- printf("%s:\n", dp->path);
- printf("\tMagic: %08x\n", qh->qh_magic);
- printf("\tLabel: %s\n", qh->qh_cluster);
- printf("\tCreated: %s", ctime(×tamp));
- printf("\tHost: %s\n", qh->qh_updatehost);
- printf("\tKernel Sector Size: %d\n", qh->qh_kernsz);
- if (qh->qh_version == VERSION_MAGIC_V2) {
- printf("\tRecorded Sector Size: %d\n\n", (int)qh->qh_blksz);
- }
-}
-
-int
-find_partitions(const char *label, char *devname, size_t devlen, int print)
-{
- struct devlisthead *dh = NULL;
- struct devnode *dn = NULL;
- struct device_args dargs;
-
- memset(&dargs, 0, sizeof(dargs));
- dargs.label = (char *)label;
- dargs.flags = 1; /* strict device check */
- dargs.devnode = NULL; /* First matching device */
-
- dh = scan_for_dev(NULL, 5, filter_devs, (void *)(&dargs));
- if (!dh)
- goto not_found;
- if (!dargs.devnode)
- goto not_found;
-
- if (dargs.count > 0 && print) {
- for (dn = dh->devnode; dn; dn = dn->next) {
- if (dn->filter == NULL) {
- continue;
- }
-
- print_qdisk_info(dn);
- if (print >= 2) {
- /* Print node stuff */
- read_info(dn->devpath->path);
- }
- }
- }
-
- if (dargs.count >= 1 && label) {
- snprintf(devname, devlen, "%s", dargs.devnode->devpath->path);
- }
-
- for (dn = dh->devnode; dn; dn = dn->next)
- if (dn->filter)
- free(dn->filter);
- free_dev_list(dh);
-
- if (print)
- /* No errors if we're just printing stuff */
- return 0;
-
- if (dargs.count == 1 || !label)
- return 0;
-
- /* more than one match */
- return dargs.count;
-
- not_found:
- if (dh) {
- for (dn = dh->devnode; dn; dn = dn->next)
- if (dn->filter)
- free(dn->filter);
- free_dev_list(dh);
- }
- errno = ENOENT;
- return -1;
-}
diff --git a/cman/qdisk/scandisk.c b/cman/qdisk/scandisk.c
deleted file mode 100644
index f37b420..0000000
--- a/cman/qdisk/scandisk.c
+++ /dev/null
@@ -1,782 +0,0 @@
-#include <stdio.h>
-#include <time.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-#include <dirent.h>
-#include <sys/sysmacros.h>
-#include <sys/stat.h>
-
-#include "scandisk.h"
-
-/** search in cache helpers **/
-
-/*
- * match is 0 for exact match
- * 1 to see if the string is contained and return the first match
- */
-
-static struct devnode *find_dev_by_path(struct devnode *startnode, char *path,
- int match)
-{
- struct devnode *nextnode;
- struct devpath *nextpath;
-
- while (startnode) {
- nextnode = startnode->next;
- nextpath = startnode->devpath;
- while (nextpath) {
- if (match) {
- if (strstr(nextpath->path, path))
- return startnode;
- } else {
- if (!strcmp(nextpath->path, path))
- return startnode;
- }
- nextpath = nextpath->next;
- }
- startnode = nextnode;
- }
-
- return 0;
-}
-
-static struct devnode *find_dev_by_majmin(struct devnode *startnode, int maj,
- int min)
-{
- struct devnode *nextnode;
-
- while (startnode) {
- nextnode = startnode->next;
- if ((startnode->maj == maj) && (startnode->min == min))
- return startnode;
- startnode = nextnode;
- }
-
- return 0;
-}
-
-/** free the cache.. this one is easy ;) **/
-
-/* free all the path associated to one node */
-static void flush_dev_list(struct devpath *startpath)
-{
- struct devpath *nextpath;
-
- while (startpath) {
- nextpath = startpath->next;
- free(startpath);
- startpath = nextpath;
- }
-
- return;
-}
-
-/* free all nodes associated with one devlist */
-static void flush_dev_cache(struct devlisthead *devlisthead)
-{
- struct devnode *nextnode, *startnode = devlisthead->devnode;
-
- while (startnode) {
- nextnode = startnode->next;
- flush_dev_list(startnode->devpath);
- free(startnode);
- startnode = nextnode;
- }
-
- return;
-}
-
-/** list object allocation helpers **/
-
-/* our only certain keys in the list are maj and min
- * this function append a devnode obj to devlisthead
- * and set maj and min
- */
-
-static struct devnode *alloc_list_obj(struct devlisthead *devlisthead, int maj,
- int min)
-{
- struct devnode *nextnode;
-
- nextnode = malloc(sizeof(struct devnode));
- if (!nextnode)
- return 0;
-
- memset(nextnode, 0, sizeof(struct devnode));
-
- if (!devlisthead->devnode)
- devlisthead->devnode = nextnode;
- else
- devlisthead->tail->next = nextnode;
-
- devlisthead->tail = nextnode;
-
- nextnode->maj = maj;
- nextnode->min = min;
-
- return nextnode;
-}
-
-/* really annoying but we have no way to know upfront how
- * many paths are linked to a certain maj/min combo.
- * Once we find a device, we know maj/min and this new path.
- * add_path_obj will add the given path to the devnode
- */
-static int add_path_obj(struct devnode *startnode, const char *path)
-{
- struct devpath *nextpath, *startpath;
-
- nextpath = malloc(sizeof(struct devpath));
- if (!nextpath)
- return 0;
-
- memset(nextpath, 0, sizeof(struct devpath));
-
- if (!startnode->devpath) {
- startnode->devpath = startpath = nextpath;
- } else {
- startpath = startnode->devpath;
- while (startpath->next)
- startpath = startpath->next;
-
- /* always append what we find */
- startpath->next = nextpath;
- startpath = nextpath;
- }
-
- strncpy(startpath->path, path, MAXPATHLEN - 1);
-
- return 1;
-}
-
-/* lsdev needs to add blocks in 2 conditions: if we have a real block device
- * or if have a symlink to a block device.
- * this function simply avoid duplicate code around.
- */
-static int add_lsdev_block(struct devlisthead *devlisthead, struct stat *sb,
- const char *path)
-{
- int maj, min;
- struct devnode *startnode;
-
- maj = major(sb->st_rdev);
- min = minor(sb->st_rdev);
-
- startnode = find_dev_by_majmin(devlisthead->devnode, maj, min);
- if (!startnode) {
- startnode = alloc_list_obj(devlisthead, maj, min);
- if (!startnode)
- return 0;
- }
-
- if (!add_path_obj(startnode, path))
- return 0;
-
- return 1;
-}
-
-/* check if it is a device or a symlink to a device */
-static int dev_is_block(struct stat *sb, char *path)
-{
- if (S_ISBLK(sb->st_mode))
- return 1;
-
- if (S_ISLNK(sb->st_mode))
- if (!stat(path, sb))
- if (S_ISBLK(sb->st_mode))
- return 1;
-
- return 0;
-}
-
-/* lsdev does nothing more than ls -lR /dev
- * dives into dirs (skips hidden directories)
- * add block devices
- * parse symlinks
- *
- * ret:
- * 1 on success
- * -1 for generic errors
- * -2 -ENOMEM
- */
-static int lsdev(struct devlisthead *devlisthead, const char *path)
-{
- int i, n, err = 0;
- struct dirent **namelist;
- struct stat sb;
- char newpath[MAXPATHLEN];
-
- i = scandir(path, &namelist, 0, alphasort);
- if (i < 0)
- return -1;
-
- for (n = 0; n < i; n++) {
- if (namelist[n]->d_name[0] != '.') {
- snprintf(newpath, sizeof(newpath), "%s/%s", path,
- namelist[n]->d_name);
-
- if (!lstat(newpath, &sb)) {
- if (S_ISDIR(sb.st_mode))
- err = lsdev(devlisthead, newpath);
- if (err < 0)
- return err;
-
- if (dev_is_block(&sb, newpath))
- if (!add_lsdev_block
- (devlisthead, &sb, newpath))
- return -2;
- }
- }
- free(namelist[n]);
- }
- free(namelist);
- return 1;
-}
-
-/*
- * scan /proc/partitions and adds info into the list.
- * It's able to add nodes if those are not found in sysfs.
- *
- * ret:
- * 0 if we can't scan
- * -2 -ENOMEM
- * 1 if everything is ok
- */
-
-static int scanprocpart(struct devlisthead *devlisthead)
-{
- char line[4096];
- FILE *fp;
- int minor, major;
- unsigned long long blkcnt;
- char device[128];
- struct devnode *startnode;
-
- fp = fopen("/proc/partitions", "r");
- if (!fp)
- return 0;
-
- while (fgets(line, sizeof(line), fp) != NULL) {
-
- if (strlen(line) > 128 + (22))
- continue;
-
- if (sscanf(line, "%4d %4d %10llu %s",
- &major, &minor, &blkcnt, device) < 4)
- continue;
-
- /* careful here.. if there is no device, we are scanning the
- * first two lines that are not useful to us
- */
- if (!strlen(device))
- continue;
-
- startnode =
- find_dev_by_majmin(devlisthead->devnode, major, minor);
- if (!startnode) {
- startnode = alloc_list_obj(devlisthead, major, minor);
- if (!startnode) {
- fclose(fp);
- return -2;
- }
- }
-
- startnode->procpart = 1;
- strncpy(startnode->procname, device, sizeof(startnode->procname) - 1);
- }
-
- fclose(fp);
- return 1;
-}
-
-/* scan /proc/mdstat and adds info to the list. At this point
- * all the devices _must_ be already in the list. We don't add anymore
- * since raids can only be assembled out of existing devices
- *
- * ret:
- * 1 if we could scan
- * 0 otherwise
- */
-static int scanmdstat(struct devlisthead *devlisthead)
-{
- char line[4096];
- FILE *fp;
- char device[16];
- char separator[4];
- char status[16];
- char personality[16];
- char firstdevice[16];
- char devices[4096];
- char *tmp, *next;
- struct devnode *startnode = NULL;
-
- fp = fopen("/proc/mdstat", "r");
- if (!fp)
- return 0;
-
- while (fgets(line, sizeof(line), fp) != NULL) {
-
- /* i like things to be absolutely clean */
- memset(device, 0, sizeof(device));
- memset(separator, 0, sizeof(separator));
- memset(status, 0, sizeof(status));
- memset(personality, 0, sizeof(personality));
- memset(firstdevice, 0, sizeof(firstdevice));
- memset(devices, 0, sizeof(devices));
-
- if (strlen(line) >= sizeof(line))
- continue;
-
- /* we only parse stuff that starts with ^md
- * that's supposed to point to raid */
- if (!(line[0] == 'm' && line[1] == 'd'))
- continue;
-
- if (sscanf(line, "%s %s %s %s %s",
- device, separator, status, personality, firstdevice) < 5)
- continue;
-
- /* scan only raids that are active */
- if (strcmp(status, "active"))
- continue;
-
- /* try to find *mdX and set the device as real raid.
- * if we don't find the device we don't try to set the slaves */
- startnode = find_dev_by_path(devlisthead->devnode, device, 1);
- if (!startnode)
- continue;
-
- startnode->md = 1;
-
- /* trunkate the string from sdaX[Y] to sdaX and
- * copy the whole device string over */
- tmp = strstr(firstdevice, "[");
- if (!tmp)
- continue;
- memset(tmp, 0, 1);
-
- tmp = strstr(line, firstdevice);
- if (!tmp)
- continue;
- strncpy(devices, tmp, sizeof(devices) - 1);
-
- /* if we don't find any slave (for whatever reason)
- * keep going */
- if (!strlen(devices))
- continue;
-
- tmp = devices;
- while ((tmp) && ((next = strstr(tmp, " ")) || strlen(tmp))) {
- char *tmp2;
-
- tmp2 = strstr(tmp, "[");
- if (tmp2)
- memset(tmp2, 0, 1);
-
- startnode =
- find_dev_by_path(devlisthead->devnode, tmp, 1);
- if (startnode)
- startnode->md = 2;
-
- tmp = next;
-
- if (tmp)
- tmp++;
-
- }
- }
-
- fclose(fp);
- return 1;
-}
-
-/* scanmapper parses /proc/devices to identify what maj are associated
- * with device-mapper
- *
- * ret:
- * can't fail for now
- */
-static int scanmapper(struct devlisthead *devlisthead)
-{
- struct devnode *startnode;
- FILE *fp;
- char line[4096];
- char major[4];
- char device[64];
- int maj, start = 0;
-
- fp = fopen("/proc/devices", "r");
- if (!fp)
- return 0;
-
- while (fgets(line, sizeof(line), fp) != NULL) {
- memset(major, 0, sizeof(major));
- memset(device, 0, sizeof(device));
-
- if (strlen(line) > sizeof(line))
- continue;
-
- if (!strncmp(line, "Block devices:", 13)) {
- start = 1;
- continue;
- }
-
- if (!start)
- continue;
-
- if (sscanf(line, "%s %s", major, device) < 2)
- continue;
-
- if (!strncmp(device, "device-mapper", 13)) {
- maj = atoi(major);
- startnode = devlisthead->devnode;
-
- while (startnode) {
- if (startnode->maj == maj)
- startnode->mapper = 1;
-
- startnode = startnode->next;
- }
-
- }
-
- }
-
- fclose(fp);
- return 1;
-}
-
-/* scan through the list and execute the custom filter for each entry */
-static void run_filter(struct devlisthead *devlisthead,
- devfilter filter, void *filter_args)
-{
- struct devnode *startnode = devlisthead->devnode;
-
- while (startnode) {
- filter(startnode, filter_args);
- startnode = startnode->next;
- }
- return;
-}
-
-/** sysfs helper functions **/
-
-/* /sys/block/sda/dev or /sys/block/sda1/dev exists
- * the device is real and dev contains maj/min info.
- *
- * ret:
- * 1 on success and set maj/min
- * 0 if no file is found
- * -1 if we could not open the file
- */
-static int sysfs_is_dev(char *path, int *maj, int *min)
-{
- char newpath[MAXPATHLEN];
- struct stat sb;
- FILE *f;
- snprintf(newpath, sizeof(newpath), "%s/dev", path);
- if (!lstat(newpath, &sb)) {
- f = fopen(newpath, "r");
- if (f) {
- int err;
-
- err = fscanf(f, "%d:%d", maj, min);
- fclose(f);
- if ((err == EOF) || (err != 2))
- return -1;
-
- return 1;
- } else
- return -1;
- }
- return 0;
-}
-
-/* /sys/block/sda/removable tells us if a device can be ejected
- * from the system or not. This is useful for USB pendrive that are
- * both removable and disks.
- *
- * ret:
- * 1 if is removable
- * 0 if not
- * -1 if we couldn't find the file.
- */
-static int sysfs_is_removable(char *path)
-{
- char newpath[MAXPATHLEN];
- struct stat sb;
- int i = -1;
- FILE *f;
- snprintf(newpath, sizeof(newpath), "%s/removable", path);
- if (!lstat(newpath, &sb)) {
- f = fopen(newpath, "r");
- if (f) {
- int err;
-
- err = fscanf(f, "%d\n", &i);
- fclose(f);
- if ((err == EOF) || (err != 1))
- i = -1;
- }
- }
- return i;
-}
-
-/* we use this function to scan /sys/block/sda{,1}/{holders,slaves}
- * to know in what position of the foodchain this device is.
- * NOTE: a device can have both holders and slaves at the same time!
- * (for example an lvm volume on top of a raid device made of N real disks
- *
- * ret:
- * always return the amount of entries in the dir if successful
- * or any return value from scandir.
- */
-static int sysfs_has_subdirs_entries(char *path, const char *subdir)
-{
- char newpath[MAXPATHLEN];
- struct dirent **namelist;
- struct stat sb;
- int n, i, count = 0;
-
- snprintf(newpath, sizeof(newpath), "%s/%s", path, subdir);
- if (!lstat(newpath, &sb)) {
- if (S_ISDIR(sb.st_mode)) {
- i = scandir(newpath, &namelist, 0, alphasort);
- if (i < 0)
- return i;
- for (n = 0; n < i; n++) {
- if (namelist[n]->d_name[0] != '.')
- count++;
- free(namelist[n]);
- }
- free(namelist);
- }
- }
- return count;
-}
-
-/* this is the best approach so far to make sure a block device
- * is a disk and distinguish it from a cdrom or tape or etc.
- * What we know for sure is that a type 0 is a disk.
- * From an old piece code 0xe is an IDE disk and comes from media.
- * NOTE: we scan also for ../ that while it seems stupid, it will
- * allow to easily mark partitions as real disks.
- * (see for example /sys/block/sda/device/type and
- * /sys/block/sda1/../device/type)
- * TODO: there might be more cases to evaluate.
- *
- * ret:
- * -2 we were not able to open the file
- * -1 no path found
- * 0 we found the path but we have 0 clue on what it is
- * 1 is a disk
- */
-static int sysfs_is_disk(char *path)
-{
- char newpath[MAXPATHLEN];
- struct stat sb;
- int i = -1;
- FILE *f;
-
- snprintf(newpath, sizeof(newpath), "%s/device/type", path);
- if (!lstat(newpath, &sb))
- goto found;
-
- snprintf(newpath, sizeof(newpath), "%s/../device/type", path);
- if (!lstat(newpath, &sb))
- goto found;
-
- snprintf(newpath, sizeof(newpath), "%s/device/media", path);
- if (!lstat(newpath, &sb))
- goto found;
-
- snprintf(newpath, sizeof(newpath), "%s/../device/media", path);
- if (!lstat(newpath, &sb))
- goto found;
-
- snprintf(newpath, sizeof(newpath), "%s/device/devtype", path);
- if (!lstat(newpath, &sb))
- return 1;
-
- snprintf(newpath, sizeof(newpath), "%s/../device/devtype", path);
- if (!lstat(newpath, &sb))
- return 1;
-
- return -1;
-
- found:
- f = fopen(newpath, "r");
- if (f) {
- int err;
-
- err = fscanf(f, "%d\n", &i);
- fclose(f);
-
- if ((err == EOF) || (err != 1))
- return 0;
-
- switch (i) {
- case 0x0: /* scsi type_disk */
- case 0xe: /* found on ide disks from old kernels.. */
- i = 1;
- break;
- default:
- i = 0; /* by default we have no clue */
- break;
- }
- } else
- i = -2;
-
- return i;
-}
-
-/* recursive function that will scan and dive into /sys/block
- * looking for devices and scanning for attributes.
- *
- * ret:
- * 1 on success
- * -1 on generic error
- * -2 -ENOMEM
- */
-static int scansysfs(struct devlisthead *devlisthead, const char *path, int level, int parent_holder)
-{
- struct devnode *startnode;
- int i, n, maj = -1, min = -1, has_holder;
- struct dirent **namelist;
- struct stat sb;
- char newpath[MAXPATHLEN];
-
- i = scandir(path, &namelist, 0, alphasort);
- if (i < 0)
- return -1;
-
- for (n = 0; n < i; n++) {
- if (namelist[n]->d_name[0] != '.') {
- snprintf(newpath, sizeof(newpath),
- "%s/%s", path, namelist[n]->d_name);
-
- if (!lstat(newpath, &sb) && level)
- if (S_ISLNK(sb.st_mode))
- continue;
-
- has_holder = parent_holder;
-
- if (sysfs_is_dev(newpath, &maj, &min) > 0) {
- startnode =
- alloc_list_obj(devlisthead, maj,
- min);
- if (!startnode)
- return -2;
-
- startnode->sysfsattrs.sysfs = 1;
- startnode->sysfsattrs.removable =
- sysfs_is_removable(newpath);
-
- if (!parent_holder)
- has_holder =
- sysfs_has_subdirs_entries(newpath,
- "holders");
-
- startnode->sysfsattrs.holders = has_holder;
-
- startnode->sysfsattrs.slaves =
- sysfs_has_subdirs_entries(newpath,
- "slaves");
- startnode->sysfsattrs.disk =
- sysfs_is_disk(newpath);
- }
-
- if (!stat(newpath, &sb) && !level)
- if (S_ISDIR(sb.st_mode))
- if (scansysfs(devlisthead, newpath, 1, has_holder) < 0)
- return -1;
-
- if (!lstat(newpath, &sb))
- if (S_ISDIR(sb.st_mode))
- if (scansysfs(devlisthead, newpath, 1, has_holder) < 0)
- return -1;
-
- }
- free(namelist[n]);
- }
-
- free(namelist);
- return 1;
-}
-
-/*
- * devlisthead can be null if you are at init time. pass the old one if you are
- * updating or scanning..
- *
- * timeout is used only at init time to set the cache timeout value if default
- * value is not good enough. We might extend its meaning at somepoint.
- * Anything <= 0 means that the cache does not expire.
- */
-
-struct devlisthead *scan_for_dev(struct devlisthead *devlisthead,
- time_t timeout,
- devfilter filter, void *filter_args)
-{
- int res;
- time_t current;
-
- time(¤t);
-
- if (devlisthead) {
- if ((current - devlisthead->cache_timestamp) <
- devlisthead->cache_timeout) {
- return devlisthead;
- }
- } else {
- devlisthead = malloc(sizeof(struct devlisthead));
- if (!devlisthead)
- return NULL;
- memset(devlisthead, 0, sizeof(struct devlisthead));
- if (timeout)
- devlisthead->cache_timeout = timeout;
- else
- devlisthead->cache_timeout = DEVCACHETIMEOUT;
- }
-
- flush_dev_cache(devlisthead);
- devlisthead->cache_timestamp = current;
-
- /* it's important we check those 3 errors and abort in case
- * as it means that we are running out of mem,
- */
- devlisthead->sysfs = res = scansysfs(devlisthead, SYSBLOCKPATH, 0, 0);
- if (res < -1)
- goto emergencyout;
-
- devlisthead->procpart = res = scanprocpart(devlisthead);
- if (res < -1)
- goto emergencyout;
-
- devlisthead->lsdev = res = lsdev(devlisthead, DEVPATH);
- if (res < -1)
- goto emergencyout;
-
- /* from now on we don't alloc mem ourselves but only add info */
- devlisthead->mdstat = scanmdstat(devlisthead);
- devlisthead->mapper = scanmapper(devlisthead);
- if (filter)
- run_filter(devlisthead, filter, filter_args);
-
- return devlisthead;
-
- emergencyout:
- free_dev_list(devlisthead);
- return 0;
-}
-
-/* free everything we used so far */
-
-void free_dev_list(struct devlisthead *devlisthead)
-{
- if (devlisthead) {
- flush_dev_cache(devlisthead);
- free(devlisthead);
- }
- return;
-}
diff --git a/cman/qdisk/scandisk.h b/cman/qdisk/scandisk.h
deleted file mode 100644
index 031de26..0000000
--- a/cman/qdisk/scandisk.h
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef __SCANDISK_H__
-#define __SCANDISK_H__
-
-#ifndef DEVPATH
-#define DEVPATH "/dev"
-#endif
-
-#ifndef SYSFSPATH
-#define SYSFSPATH "/sys"
-#endif
-
-#ifndef SYSBLOCKPATH
-#define SYSBLOCKPATH SYSFSPATH "/block"
-#endif
-
-#ifndef DEVCACHETIMEOUT
-#define DEVCACHETIMEOUT 30 /* expressed in seconds */
-#endif
-
-/* each entry can be (generally):
- * > 0 on success or good hit
- * 0 on success with no hit
- * < 0 on error
- */
-
-struct sysfsattrs { /* usual 0 | 1 game */
- int sysfs; /* did we find an entry in sysfs at all? */
- int slaves; /* device has slaves */
- int holders; /* device has holders */
- int removable; /* device is removable */
- int disk; /* device is a disk */
-};
-
-/* this structure is required because we don't know upfront how many
- * entries for a certain maj/min will be found in /dev, and so we need
- * to alloc them dynamically.
- */
-struct devpath {
- struct devpath *next;
- char path[MAXPATHLEN];
-};
-
-/* this structure holds all the data for each maj/min found in the system
- * that is a block device
- */
-struct devnode {
- struct devnode *next;
- struct devpath *devpath; /* point to the first path entry */
- int maj; /* device major */
- int min; /* device minor */
- struct sysfsattrs sysfsattrs; /* like the others.. scanning /sys */
- int procpart; /* 0 if the device is not in proc/part or 1 on success. <0 on error */
- char procname[MAXPATHLEN]; /* non-NULL if we find a maj/min match */
- int md; /* 0 nothing to do with raid, 1 is raid,
- * 2 is raid slave - data from /proc/mdstat */
- int mapper; /* 0 nothing, 1 we believe it's a devmap dev */
- void *filter; /* your filter output.. whatever it is */
-};
-
-/* this is what you get after a scan... if you are lucky */
-/* each entry can be 0 if we can't scan or < 0 if there are errors */
-
-struct devlisthead {
- struct devnode *devnode; /* points to the first entry */
- struct devnode *tail; /* last entry (for fast append) */
- time_t cache_timestamp; /* this cache timestamp */
- int cache_timeout; /* for how long this cache is valid */
- int sysfs; /* set to 1 if we were able to scan
- * /sys */
- int procpart; /* set to 1 if we were able to scan
- * /proc/partitions */
- int lsdev; /* set to 1 if we were able to ls /dev */
- int mdstat; /* set to 1 if we were able to scan
- * /proc/mdstat */
- int mapper; /* set to 1 if we were able to run
- * something against mapper */
-};
-
-typedef void (*devfilter) (struct devnode * cur, void *arg);
-
-struct devlisthead *scan_for_dev(struct devlisthead *devlisthead,
- time_t timeout,
- devfilter filter, void *filter_args);
-void free_dev_list(struct devlisthead *devlisthead);
-
-#endif /* __SCANDISK_H__ */
diff --git a/cman/qdisk/score.c b/cman/qdisk/score.c
deleted file mode 100644
index 653fdf3..0000000
--- a/cman/qdisk/score.c
+++ /dev/null
@@ -1,488 +0,0 @@
-/**
- @file Quorum daemon scoring functions + thread.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <string.h>
-#include <ccs.h>
-#include <liblogthread.h>
-#include <sched.h>
-#include <sys/mman.h>
-#include "disk.h"
-#include "score.h"
-
-static pthread_mutex_t sc_lock = PTHREAD_MUTEX_INITIALIZER;
-static int _score = 0, _maxscore = 0, _score_thread_running = 0;
-static pthread_t score_thread = (pthread_t)0;
-extern void set_priority(int, int);
-
-struct h_arg {
- struct h_data *h;
- int sched_queue;
- int sched_prio;
- int count;
-};
-
-/*
- XXX Messy, but works for now...
- */
-static void
-nullify(void)
-{
- int fd[3];
-
- close(0);
- close(1);
- close(2);
-
- fd[0] = open("/dev/null", O_RDONLY);
- if (fd[0] != 0)
- dup2(fd[0], 0);
- fd[1] = open("/dev/null", O_WRONLY);
- if (fd[1] != 1)
- dup2(fd[1], 1);
- fd[2] = open("/dev/null", O_WRONLY);
- if (fd[2] != 2)
- dup2(fd[2], 2);
-}
-
-
-/**
- Set all signal handlers to default for exec of a script.
- ONLY do this after a fork().
- */
-static void
-restore_signals(void)
-{
- sigset_t set;
- int x;
-
- for (x = 1; x < _NSIG; x++)
- signal(x, SIG_DFL);
-
- sigfillset(&set);
- sigprocmask(SIG_UNBLOCK, &set, NULL);
-}
-
-
-/**
- Spin off a user-defined heuristic
- */
-static int
-fork_heuristic(struct h_data *h, struct timespec *now)
-{
- int pid;
- char *argv[4];
-
- if (h->childpid) {
- errno = EINPROGRESS;
- return -1;
- }
-
- if (now->tv_sec < h->nextrun.tv_sec ||
- ((now->tv_sec == h->nextrun.tv_sec) &&
- (now->tv_nsec < h->nextrun.tv_nsec)))
- return 0;
-
- h->nextrun.tv_sec = now->tv_sec + h->interval;
- h->nextrun.tv_nsec = now->tv_nsec;
-
- h->failtime.tv_sec = now->tv_sec + h->maxtime;
- h->failtime.tv_nsec = now->tv_nsec;
-
- pid = fork();
- if (pid < 0)
- return -1;
-
- if (pid) {
- h->childpid = pid;
- return 0;
- }
-
- /*
- * always use SCHED_OTHER for the child processes
- * nice -1 is fine; but we don't know what the child process
- * might do, so leaving it (potentially) in SCHED_RR or SCHED_FIFO
- * is out of the question
- *
- * XXX if you set SCHED_OTHER in the conf file and nice 20, the below
- * will make the heuristics a higher prio than qdiskd. This should be
- * fine in practice, because running qdiskd at nice 20 will cause all
- * sorts of problems on a busy system.
- */
- set_priority(SCHED_OTHER, -1);
- munlockall();
- restore_signals();
-
- argv[0] = strdup("/bin/sh");
- argv[1] = strdup("-c");
- argv[2] = h->program;
- argv[3] = NULL;
-
- nullify();
-
- execv("/bin/sh", argv);
-
- free(argv[0]);
- free(argv[1]);
-
- logt_print(LOG_ERR, "Execv failed\n");
- return 0;
-}
-
-
-/**
- Total our current score
- */
-static void
-total_score(struct h_data *h, int max, int *score, int *maxscore)
-{
- int x;
-
- *score = 0;
- *maxscore = 0;
-
- /* Allow operation w/o any heuristics */
- if (!max) {
- *score = *maxscore = 1;
- return;
- }
-
- for (x = 0; x < max; x++) {
- *maxscore += h[x].score;
- if (h[x].available)
- *score += h[x].score;
- }
-}
-
-
-/**
- Check for response from a user-defined heuristic / script
- */
-static int
-check_heuristic(struct h_data *h, int block, struct timespec *now)
-{
- int ret;
- int status;
-
- if (h->childpid == 0)
- /* No child to check */
- return 0;
-
- ret = waitpid(h->childpid, &status, block?0:WNOHANG);
- if (!block && ret == 0) {
- /* No children exited */
-
- /* no timeout */
- if (!h->maxtime)
- return 0;
-
- /* If we overran our timeout, the heuristic is dead */
- if (now->tv_sec > h->failtime.tv_sec ||
- (now->tv_sec == h->failtime.tv_sec &&
- now->tv_nsec > h->failtime.tv_nsec)) {
- h->misses = h->tko;
- h->failed = ETIMEDOUT;
- if (h->available) {
- logt_print(LOG_INFO, "Heuristic: '%s' DOWN - "
- "Exceeded timeout of %d seconds\n",
- h->program, h->maxtime);
- h->available = 0;
- }
- }
-
- return 0;
- }
-
- h->childpid = 0;
- if (ret < 0 && errno == ECHILD)
- /* wrong child? */
- goto miss;
-
- /* Timed out previously; this run must be ignored. */
- if (h->failed) {
- h->failed = 0;
- goto miss;
- }
- if (!WIFEXITED(status)) {
- ret = 0;
- goto miss;
- }
- if (WEXITSTATUS(status) != 0) {
- logt_print(LOG_DEBUG, "Heuristic: sh returned %d for '%s'\n",
- WEXITSTATUS(status), h->program);
- ret = 0;
- goto miss;
- }
-
- /* Returned 0 and was not killed */
- if (!h->available) {
- h->available = 1;
- logt_print(LOG_INFO, "Heuristic: '%s' UP\n", h->program);
- }
- h->misses = 0;
- return 0;
-
-miss:
- if (h->available) {
- h->misses++;
- if (h->misses >= h->tko) {
- logt_print(LOG_INFO,
- "Heuristic: '%s' DOWN (%d/%d)\n",
- h->program, h->misses, h->tko);
- h->available = 0;
- } else {
- logt_print(LOG_DEBUG,
- "Heuristic: '%s' missed (%d/%d)\n",
- h->program, h->misses, h->tko);
- }
- }
-
- return ret;
-}
-
-
-/**
- Kick off all available heuristics
- */
-static int
-fork_heuristics(struct h_data *h, int max)
-{
- struct timespec now;
- int x;
-
- clock_gettime(CLOCK_MONOTONIC, &now);
- for (x = 0; x < max; x++)
- fork_heuristic(&h[x], &now);
- return 0;
-}
-
-
-/**
- Check all available heuristics
- */
-static int
-check_heuristics(struct h_data *h, int max, int block)
-{
- struct timespec now;
- int x;
-
- clock_gettime(CLOCK_MONOTONIC, &now);
- for (x = 0; x < max; x++)
- check_heuristic(&h[x], block, &now);
- return 0;
-}
-
-
-/*
- * absmax should be qdiskd (interval * (tko-1))
- */
-static void
-auto_heuristic_timing(int *interval, int *tko, int absmax)
-{
- if (!interval || ! tko)
- return;
-
- if (absmax < 3)
- return;
-
- if (absmax <= 4) {
- *interval = 1;
- } else if (absmax <= 22) {
- *interval = 2;
- } else if (absmax <= 39) {
- *interval = 3;
- } else if (absmax <= 50) {
- *interval = 4;
- } else {
- *interval = 5;
- }
-
- *tko = absmax / (*interval);
-}
-
-
-/**
- Read configuration data from CCS into the array provided
- */
-int
-configure_heuristics(int ccsfd, struct h_data *h, int max, int maxtime)
-{
- int x = 0;
- char *val;
- char query[128];
-
- if (!h || !max)
- return -1;
-
- do {
- h[x].program = NULL;
- h[x].available = 0;
- h[x].misses = 0;
- auto_heuristic_timing(&h[x].interval, &h[x].tko, maxtime);
- h[x].maxtime = maxtime;
- h[x].score = 1;
- h[x].childpid = 0;
- h[x].nextrun.tv_sec = 0;
- h[x].nextrun.tv_nsec = 0;
- h[x].failtime.tv_sec = 0;
- h[x].failtime.tv_nsec = 0;
-
- /* Get program */
- snprintf(query, sizeof(query),
- "/cluster/quorumd/heuristic[%d]/@program", x+1);
- if (ccs_get(ccsfd, query, &val) != 0)
- /* No more */
- break;
- h[x].program = val;
-
- /* Get score */
- snprintf(query, sizeof(query),
- "/cluster/quorumd/heuristic[%d]/@score", x+1);
- if (ccs_get(ccsfd, query, &val) == 0) {
- h[x].score = atoi(val);
- free(val);
- if (h[x].score <= 0)
- h[x].score = 1;
- }
-
- /* Get query interval */
- snprintf(query, sizeof(query),
- "/cluster/quorumd/heuristic[%d]/@interval", x+1);
- if (ccs_get(ccsfd, query, &val) == 0) {
- h[x].interval = atoi(val);
- free(val);
- if (h[x].interval <= 0)
- h[x].interval = 2;
- }
-
- /* Get tko for this heuristic */
- snprintf(query, sizeof(query),
- "/cluster/quorumd/heuristic[%d]/@tko", x+1);
- if (ccs_get(ccsfd, query, &val) == 0) {
- h[x].tko= atoi(val);
- free(val);
- if (h[x].tko <= 0)
- h[x].tko = 1;
- }
-
- logt_print(LOG_DEBUG,
- "Heuristic: '%s' score=%d interval=%d tko=%d\n",
- h[x].program, h[x].score, h[x].interval, h[x].tko);
-
- } while (++x < max);
-
- logt_print(LOG_DEBUG, "%d heuristics loaded\n", x);
-
- return x;
-}
-
-
-/**
- Return the current score + maxscore to the caller
- */
-int
-get_my_score(int *score, int *maxscore)
-{
- pthread_mutex_lock(&sc_lock);
- *score = _score;
- *maxscore = _maxscore;
- pthread_mutex_unlock(&sc_lock);
-
- return 0;
-}
-
-
-/**
- Call this if no heuristics are set to run in master-wins mode
- */
-int
-fudge_scoring(void)
-{
- pthread_mutex_lock(&sc_lock);
- _score = _maxscore = 1;
- pthread_mutex_unlock(&sc_lock);
-
- return 0;
-}
-
-
-/**
- Loop for the scoring thread.
- */
-static void *
-score_thread_main(void *arg)
-{
- struct h_arg *args = (struct h_arg *)arg;
- int score, maxscore;
-
- set_priority(args->sched_queue, args->sched_prio);
-
- while (_score_thread_running) {
- fork_heuristics(args->h, args->count);
- check_heuristics(args->h, args->count, 0);
- total_score(args->h, args->count, &score, &maxscore);
-
- pthread_mutex_lock(&sc_lock);
- _score = score;
- _maxscore = maxscore;
- pthread_mutex_unlock(&sc_lock);
-
- if (_score_thread_running)
- sleep(1);
- }
-
- free(args->h);
- free(args);
- logt_print(LOG_INFO, "Score thread going away\n");
- return (NULL);
-}
-
-
-/**
- Start the score thread. h is copied into an argument which is
- passed in as the arg parameter in the score thread, so it is safe
- to pass in h if it was allocated on the stack.
- */
-int
-start_score_thread(qd_ctx *ctx, struct h_data *h, int count)
-{
- pthread_attr_t attrs;
- struct h_arg *args;
-
- if (!h || !count)
- return -1;
-
- args = malloc(sizeof(struct h_arg));
- if (!args)
- return -1;
-
- args->h = malloc(sizeof(struct h_data) * count);
- if (!args->h) {
- free(args);
- return -1;
- }
-
- memcpy(args->h, h, (sizeof(struct h_data) * count));
- args->count = count;
- args->sched_queue = ctx->qc_sched;
- args->sched_prio = ctx->qc_sched_prio;
-
- _score_thread_running = 1;
-
- pthread_attr_init(&attrs);
- pthread_attr_setinheritsched(&attrs, PTHREAD_INHERIT_SCHED);
- pthread_create(&score_thread, &attrs, score_thread_main, args);
- pthread_attr_destroy(&attrs);
-
- if (score_thread)
- return 0;
- _score_thread_running = 0;
- return -1;
-}
diff --git a/cman/qdisk/score.h b/cman/qdisk/score.h
deleted file mode 100644
index beff31b..0000000
--- a/cman/qdisk/score.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- @file Quorum daemon scoring functions + thread header file
- */
-#ifndef _SCORE_H
-#define _SCORE_H
-
-#include <time.h>
-#include <sys/time.h>
-#include <sys/types.h>
-
-struct h_data {
- char * program;
- struct timespec nextrun;
- struct timespec failtime;
- int score;
- int available;
- int tko;
- int interval;
- int maxtime;
- int misses;
- int failed;
- pid_t childpid;
-};
-
-/*
- Grab score data from CCSD
- */
-int configure_heuristics(int ccsfd, struct h_data *hp, int max, int maxtime);
-
-/*
- Start the thread which runs the scoring applets
- */
-int start_score_thread(qd_ctx *ctx, struct h_data *h, int count);
-
-/*
- Get our score + maxscore
- */
-int get_my_score(int *score, int *maxscore);
-
-/*
- Set score + maxscore to 1. Call if no heuristics are present
- to enable master-wins mode
- */
-int fudge_scoring(void);
-
-
-#endif
diff --git a/cman/scripts/Makefile b/cman/scripts/Makefile
deleted file mode 100644
index f80f7e4..0000000
--- a/cman/scripts/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-SHAREDIRTEX=checkquorum
-SHAREDIRT=checkquorum.wdmd
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-all:
-
-clean: generalclean
diff --git a/cman/scripts/checkquorum b/cman/scripts/checkquorum
deleted file mode 100755
index 61934cd..0000000
--- a/cman/scripts/checkquorum
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/usr/bin/perl -w
-# Quorum detection watchdog script
-#
-# This script will return -2 if the node had quorum at one point
-# and then subsequently lost it
-#
-# Copyright 2011 Red Hat, Inc.
-
-# Amount of time in seconds to wait after quorum is lost to fail script
-$wait_time = 60;
-
-# Hard Reboot the system (doesn't cleanly shut down the system)
-$hardreboot = 0;
-
-# Location of temporary file to capture timeouts
-$timerfile = "/var/run/cluster/checkquorum-timer";
-
-# Enable debug messages (0 to disable, 1 to enable)
-$debugval = 0;
-
-# If command is called attempting to 'repair' we automatically fail
-if (($#ARGV != -1) && ($ARGV[0] eq "repair")) {
- debug ("Failing on repair\n");
- exit 1;
-}
-
-if (!quorum()) {
- if (has_quorum_already_been_formed()) {
- debug("Quorum has already existed, node can be rebooted!\n");
- if (-e $timerfile) {
- $tf = open (FILE, "$timerfile");
- $time = <FILE>;
- close (FILE);
- $timediff = time() - $time;
- if ($timediff >= $wait_time) {
- reboot()
- } else {
- $remaining = $wait_time - $timediff;
- debug("Time has not exceeded wait time ($remaining seconds remaining).\n");
- }
- } else {
- debug("Creating timer file...\n");
- $tf = open (FILE, ">$timerfile");
- print FILE time();
- close (FILE);
- }
- } else {
- debug("This is a new startup no reboot will occur.\n");
- `rm -f $timerfile`;
- }
-} else {
- debug("Quorum exists, no reboot should occur.\n");
- `rm -f $timerfile`;
-}
-
-sub has_quorum_already_been_formed {
- $oe = `corosync-objctl 2>&1 | grep -E "runtime.totem.pg.mrp.srp.operational_entered|Could not initialize objdb library|Cannot connect to quorum service" `;
- if ($oe =~ /^Could not/ || $oe =~ /^Cannot/) {
- debug("corosync is not running\n");
- exit 0;
- }
- $oe =~ s/.*=//;
- if ($oe > 1) {
- return 1;
- } else {
- return 0;
- }
-}
-
-sub quorum {
- $cq = `corosync-quorumtool -s 2>&1 | grep -E "Quorate:|Cannot connect to quorum service"`;
- if ($cq =~ /Cannot connect to quorum service/) {
- debug("corosync is not running\n");
- exit 0;
- }
- $cq =~ s/Quorate: *//;
- chomp ($cq);
- return 1 if ($cq eq "Yes");
- return 0;
-}
-
-sub reboot {
- debug("Reboot commencing...\n");
- `rm -f $timerfile`;
- if ($hardreboot == 1) {
- `echo 1 > /proc/sys/kernel/sysrq`;
- `echo b > /proc/sysrq-trigger`;
- }
- exit -2;
-}
-
-sub debug {
- $out = pop(@_);
- if ($debugval) {
- print $out;
- }
-}
diff --git a/cman/scripts/checkquorum.wdmd b/cman/scripts/checkquorum.wdmd
deleted file mode 100644
index 1d81ff6..0000000
--- a/cman/scripts/checkquorum.wdmd
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/bash
-# Quorum detection watchdog script
-#
-# This script will return -2 if the node had quorum at one point
-# and then subsequently lost it
-#
-# Copyright 2012 Red Hat, Inc.
-
-# defaults
-
-# Amount of time in seconds to wait after quorum is lost to fail script
-waittime=60
-
-# action to take if quorum is missing for over > waittime
-# autodetect|hardreboot|crashdump|watchdog
-action=autodetect
-
-# Location of temporary file to capture timeouts
-timerfile="/var/run/cluster/checkquorum-timer"
-
-# rpm based distros
-[ -d /etc/sysconfig ] && \
- [ -f /etc/sysconfig/checkquorum ] && \
- . /etc/sysconfig/checkquorum
-
-# deb based distros
-[ ! -d /etc/sysconfig ] && \
- [ -f /etc/default/checkquorum ] && \
- . /etc/default/checkquorum
-
-has_quorum() {
- corosync-quorumtool -s 2>/dev/null | \
- grep ^Quorate: | \
- grep -q Yes$
-}
-
-had_quorum() {
- output="$(corosync-objctl 2>/dev/null | \
- grep runtime.totem.pg.mrp.srp.operational_entered | cut -d "=" -f 2)"
- [ -n "$output" ] && {
- [ "$output" -ge 1 ] && return 0
- return 1
- }
-}
-
-take_action() {
- case "$action" in
- watchdog)
- [ -n "$wdmd_action" ] && return 1
- ;;
- hardreboot)
- echo 1 > /proc/sys/kernel/sysrq
- echo b > /proc/sysrq-trigger
- ;;
- crashdump)
- echo 1 > /proc/sys/kernel/sysrq
- echo c > /proc/sysrq-trigger
- ;;
- autodetect)
- service kdump status > /dev/null 2>&1
- usekexec="$?"
- [ -n "$wdmd_action" ] && [ "$usekexec" != "0" ] && return 1
- echo 1 > /proc/sys/kernel/sysrq
- [ "$usekexec" = "0" ] && echo c > /proc/sysrq-trigger
- echo b > /proc/sysrq-trigger
- esac
-}
-
-# watchdog uses $1 = test or = repair
-# with no arguments we are called by wdmd
-[ -z "$1" ] && wdmd_action=yes
-
-# we don't support watchdog repair action
-[ "$1" = "repair" ] && exit 1
-
-service corosync status > /dev/null 2>&1
-ret=$?
-
-case "$ret" in
- 3) # corosync is not running (clean)
- rm -f "$timerfile"
- exit 0
- ;;
- 1) # corosync crashed or did exit abonormally (dirty - take action)
- logger -t checkquorum.wdmd "corosync crashed or exited abonarmally. Node will soon reboot"
- take_action
- ;;
- 0) # corosync is running (clean)
- # check quorum here
- has_quorum && {
- echo -e "oldtime=$(date +%s)" > "$timerfile"
- exit 0
- }
- . "$timerfile"
- newtime="$(date +%s)"
- delta=$((newtime - oldtime))
- logger -t checkquorum.wdmd "Node has lost quorum. Node will soon reboot"
- had_quorum && [ "$delta" -gt "$waittime" ] && {
- take_action
- }
- ;;
-esac
-
-exit $?
diff --git a/cman/tests/Makefile b/cman/tests/Makefile
deleted file mode 100644
index eb800c1..0000000
--- a/cman/tests/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-TARGETS= client libtest sysman sysmand
-
-all: depends ${TARGETS}
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-
-CFLAGS += -I${cmanincdir}
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${cmanlibdir} -lcman
-LDFLAGS += -L${libdir}
-
-depends:
- $(MAKE) -C ../lib all
-
-%: %.o
- $(CC) -o $@ $^ $(LDFLAGS)
-
-install:
-
-clean: generalclean
diff --git a/cman/tests/client.c b/cman/tests/client.c
deleted file mode 100644
index ff74816..0000000
--- a/cman/tests/client.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* test client */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/utsname.h>
-#include <netinet/in.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "libcman.h"
-
-static cman_handle_t handle;
-static void get_members(void);
-
-static void event_callback(cman_handle_t handle, void *private, int reason, int arg)
-{
- get_members();
-}
-
-
-static void data_callback(cman_handle_t handle, void *private,
- char *buf, int len, uint8_t port, int nodeid)
-{
- printf("Received from node %d port %d: '%s'\n", nodeid, port, buf);
-}
-
-
-int main(int argc, char *argv[])
-{
-
- unsigned char port = 100;
- char message[256];
- struct utsname ubuf;
-
- if (argc >= 2)
- port = atoi(argv[1]);
-
- if (argc >= 3)
- strcpy(message, argv[2]);
-
- printf("Cluster port number is %d\n", port);
- uname(&ubuf);
- sprintf(message, "Hello from %s", ubuf.nodename);
-
- handle = cman_init(NULL);
- if (!handle)
- {
- perror("Can't connect to cman");
- return -1;
- }
-
-
- if (cman_start_recv_data(handle, data_callback, port))
- {
- perror("Can't bind cluster socket");
- return -1;
- }
- cman_start_notification(handle, event_callback);
-
- while (1)
- {
-
- if (cman_send_data(handle, message, strlen(message)+1,0, port, 0) < 0)
- {
- perror("write");
- cman_finish(handle);
- exit(-1);
- }
-
- while (1)
- {
- if (cman_dispatch(handle, CMAN_DISPATCH_ALL|CMAN_DISPATCH_BLOCKING) == -1)
- break;
- }
- }
- fprintf(stderr, "EOF: finished\n");
-}
-
-
-void get_members(void)
-{
- cman_node_t *nodes;
- int i;
- int num_nodes = cman_get_node_count(handle);
-
- if (num_nodes == -1)
- {
- perror("get nodes");
- }
- else
- {
- printf("There are %d nodes: \n", num_nodes);
-
- nodes = malloc(num_nodes * sizeof(cman_node_t));
- if ( (cman_get_nodes(handle, num_nodes, &num_nodes, nodes)))
- {
- for (i=0; i<num_nodes; i++)
- {
- printf("%s %d\n", nodes[i].cn_name, nodes[i].cn_nodeid);
- }
- }
- else
- {
- perror("get node details");
- }
- }
-}
diff --git a/cman/tests/libtest.c b/cman/tests/libtest.c
deleted file mode 100644
index 85c1ea8..0000000
--- a/cman/tests/libtest.c
+++ /dev/null
@@ -1,132 +0,0 @@
-#include <netinet/in.h>
-#include <inttypes.h>
-#include "libcman.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-
-static void cman_callback(cman_handle_t handle, void *private, int reason, int arg)
-{
- printf("callback called reason = %d, arg=%d\n", reason, arg);
-}
-
-static void confchg_callback(cman_handle_t handle, void *private,
- unsigned int *member_list, int member_list_entries,
- unsigned int *left_list, int left_list_entries,
- unsigned int *joined_list, int joined_list_entries)
-{
- int i;
- printf("Confchg callback\n");
- printf("member_list: %d entries:\n", member_list_entries);
- for (i=0; i<member_list_entries; i++)
- printf(" %d\n", member_list[i]);
- printf("left_list: %d entries:\n", left_list_entries);
- for (i=0; i<left_list_entries; i++)
- printf(" %d\n", left_list[i]);
- printf("joined_list: %d entries:\n", joined_list_entries);
- for (i=0; i<joined_list_entries; i++)
- printf(" %d\n", joined_list[i]);
-}
-
-static void print_node(cman_node_t *node)
-{
- printf(" node id %d\n", node->cn_nodeid);
- printf(" node member %d\n", node->cn_member);
- printf(" node name %s\n", node->cn_name);
- printf(" node incarn %d\n", node->cn_incarnation);
- printf("\n");
-}
-
-int main()
-{
- cman_handle_t h;
- int num;
- int retnodes;
- cman_node_t *nodes;
- cman_version_t ver;
- cman_cluster_t clinfo;
-
- h = cman_init(0);
- if (!h)
- {
- perror("cman_init failed");
- exit(1);
- }
-
- num = cman_get_node_count(h);
- if (num > 0)
- printf("cluster has %d nodes\n", num);
- else
- perror("node count");
-
- printf("cman is active: %d\n", cman_is_active(h));
- printf("cman is quorate: %d\n", cman_is_quorate(h));
- printf("cman is listening: %d\n", cman_is_listening(h, CMAN_NODEID_US, 1)); /* membership! */
- cman_get_version(h, &ver);
- printf("cman version %d.%d.%d (config %d)\n",
- ver.cv_minor,
- ver.cv_major,
- ver.cv_patch,
- ver.cv_config);
-
- if (!cman_get_cluster(h, &clinfo))
- {
- printf("Cluster '%s', number %d\n", clinfo.ci_name, clinfo.ci_number);
- }
- else
- perror("cluster info failed");
-
- nodes = malloc(num * sizeof(cman_node_t));
- if (!nodes)
- {
- perror("malloc");
- exit(1);
- }
-
- if (!cman_get_nodes(h, num, &retnodes, nodes))
- {
- int i;
- printf("Getting all nodes:\n");
- for (i=0; i<retnodes; i++)
- print_node(&nodes[i]);
- }
- else
- {
- perror("get_nodes failed");
- }
-
- // Need to clear this.
- // Who wrote this rubbish? oh, I did.
- nodes[0].cn_name[0] = '\0';
- if (!cman_get_node(h, CMAN_NODEID_US, &nodes[0]))
- {
- printf("Getting our info:\n");
- print_node(&nodes[0]);
- }
- else
- {
- perror("get_node failed");
- }
-
- if (cman_start_notification(h, cman_callback))
- {
- perror("start_notification");
- }
-
- if (cman_start_confchg(h, confchg_callback))
- {
- perror("start_confchg");
- }
-
-
- while (1) {
- int ret = cman_dispatch(h, CMAN_DISPATCH_BLOCKING | CMAN_DISPATCH_ALL);
- if (ret == -1) {
- perror("cman_dispatch");
- break;
- }
- }
- cman_finish(h);
-
- return 0;
-}
diff --git a/cman/tests/qwait.c b/cman/tests/qwait.c
deleted file mode 100644
index 5d6a3f7..0000000
--- a/cman/tests/qwait.c
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <sys/un.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/utsname.h>
-#include <netinet/in.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "cnxman-socket.h"
-
-static int cluster_sock;
-
-static void signal_handler(int sig)
-{
-
- return;
-}
-
-
-int main(int argc, char *argv[])
-{
- struct sigaction sa;
- sigset_t ss;
-
- cluster_sock = socket(AF_CLUSTER, SOCK_DGRAM, CLPROTO_CLIENT);
- if (cluster_sock == -1)
- {
- perror("Can't open cluster socket");
- return -1;
- }
- sa.sa_handler = signal_handler;
- sa.sa_mask = ss;
- sa.sa_flags = 0;
- sigaction(SIGUSR1, &sa, NULL);
-
- if (ioctl(cluster_sock, SIOCCLUSTER_NOTIFY, SIGUSR1) == -1)
- {
- perror("Can't set up cluster notification");
- close(cluster_sock);
- return -1;
- }
-
- while (!ioctl(cluster_sock, SIOCCLUSTER_ISQUORATE, 0))
- {
- pause();
- }
-
- close(cluster_sock);
-
- return 0;
-}
diff --git a/cman/tests/sysman.c b/cman/tests/sysman.c
deleted file mode 100644
index 99ba562..0000000
--- a/cman/tests/sysman.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* "sysman" client */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <sys/un.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/utsname.h>
-#include <netinet/in.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#define LOCAL_SOCKNAME "/var/run/sysman"
-static int open_local_sock(void);
-
-int main(int argc, char *argv[])
-{
- char message[PIPE_BUF];
- int local_sock;
- int len;
-
- if (argc < 2)
- {
- printf("usage: sysman \"command\"\n");
- return 0;
- }
-
- local_sock = open_local_sock();
- if (local_sock < 0)
- exit(2);
-
- /* Send the command */
- write(local_sock, argv[1], strlen(argv[1])+1);
-
- /* Print the replies */
- while ( (len = read(local_sock, message, sizeof(message))) )
- {
- write(STDOUT_FILENO, message, len);
- }
- printf("\n");
- return 0;
-}
-
-
-static int open_local_sock(void)
-{
- int local_socket;
- struct sockaddr_un sockaddr;
-
- // Open local socket
- local_socket = socket(PF_UNIX, SOCK_STREAM, 0);
- if (local_socket < 0)
- {
- perror("Can't create local socket");
- return -1;
- }
-
- strcpy(sockaddr.sun_path, LOCAL_SOCKNAME);
- sockaddr.sun_family = AF_UNIX;
- if (connect(local_socket, (struct sockaddr *)&sockaddr, sizeof(sockaddr)))
- {
- fprintf(stderr, "sysmand is not running\n");
- close(local_socket);
- return -1;
- }
- return local_socket;
-}
-
diff --git a/cman/tests/sysmand.c b/cman/tests/sysmand.c
deleted file mode 100644
index 8391c06..0000000
--- a/cman/tests/sysmand.c
+++ /dev/null
@@ -1,469 +0,0 @@
-/* "sysman" server
-
- Listens on a cluster port and executes commands.
-
- This is just a demonstration piece of code, not for production use
-
- *************************************
- *** IT IS A MASSIVE SECURITY HOLE ***
- *************************************
-
- Any command passed to it will be run as root!
-
-*/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <sys/un.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/utsname.h>
-#include <sys/errno.h>
-#include <syslog.h>
-#include <netinet/in.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <time.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "libcman.h"
-#define LOCAL_SOCKNAME "/var/run/sysman"
-#define CLUSTER_PORT_SYSMAN 12
-
-static cman_node_t *nodes = NULL;
-static int num_nodes;
-static cman_handle_t ch;
-static int expected_responses;
-
-/* Header for all commands sent to other sysmand servers */
-struct sysman_header
-{
- int fd; /* local FD to return output to. in network byte order */
- int ret; /* Return code of command */
- char cmd;
-#define SYSMAN_CMD_REQUEST 1
-#define SYSMAN_CMD_REPLY 2
-};
-
-/* One of these for each fd we are listening on
- some fields are specific to particular types.
-*/
-struct read_fd
-{
- int fd;
- enum {CLUSTER_SOCK, LOCAL_RENDEZVOUS, LOCAL_SOCK} type;
- int nodes_done;
- time_t start_time;
- struct read_fd *next;
-};
-/* Head of the fd list. Also contains
- the cluster_socket details */
-static struct read_fd read_fd_head;
-
-
-static void get_members(void);
-static int open_local_sock(void);
-static int exec_command(char *cmd, char *reply, int *len);
-static int name_from_nodeid(int nodeid, char *name);
-static void remove_sock(struct read_fd *deadfd);
-static struct read_fd *find_by_fd(int fd);
-static int nodes_listening(int);
-
-static void event_callback(cman_handle_t handle, void *private, int reason, int arg)
-{
- get_members();
-}
-
-static void data_callback(cman_handle_t handle, void *private,
- char *buf, int len, uint8_t port, int nodeid)
-{
- struct read_fd *replyfd = NULL;
- char reply[PIPE_BUF];
- char title[PIPE_BUF];
- char nodename[CMAN_MAX_NODENAME_LEN];
- struct sysman_header *header;
- int status;
- int title_len;
- struct sysman_header *inheader = (struct sysman_header *)buf;
-
- switch (inheader->cmd)
- {
- case SYSMAN_CMD_REQUEST:
-
- /* Execute command and capture stdout/stderr into 'reply'*/
- status = exec_command(buf+sizeof(struct sysman_header), reply+sizeof(struct sysman_header), &len);
-
- header = (struct sysman_header *)reply;
-
- /* Send reply */
- header->fd = inheader->fd; /* Already in the right format */
- header->cmd = SYSMAN_CMD_REPLY;
- header->ret = htonl(status);
-
- cman_send_data(ch, reply, len, 0, port, nodeid);
- break;
-
- case SYSMAN_CMD_REPLY:
- name_from_nodeid(nodeid, nodename);
- title_len = sprintf(title, "\nReply from %s:", nodename);
- if (inheader->ret != 0)
- title_len += sprintf(title+title_len, " (ret=%d)", ntohl(inheader->ret));
- strcat(title, "\n"); title_len++;
- write(ntohl(inheader->fd), title, title_len);
- write(ntohl(inheader->fd), buf+sizeof(struct sysman_header),
- len - sizeof(struct sysman_header));
-
- replyfd = find_by_fd(ntohl(inheader->fd));
- if (replyfd)
- {
- /* If we've done all nodes then close the client down */
- if (++replyfd->nodes_done == expected_responses)
- {
- close(replyfd->fd);
- remove_sock(replyfd);
- }
- }
- break;
-
- default:
- name_from_nodeid(nodeid, nodename);
- syslog(LOG_ERR, "Unknown sysman command received from %s: %d\n",
- nodename, inheader->cmd);
- break;
- }
-}
-
-int main(int argc, char *argv[])
-{
- unsigned char port = CLUSTER_PORT_SYSMAN;
- int local_sock;
- struct read_fd *newfd;
- struct utsname nodeinfo;
-
- ch = cman_init(NULL);
- if (!ch)
- {
- perror("Can't connect to cman");
- return -1;
- }
-
- uname(&nodeinfo);
-
- if (cman_start_recv_data(ch, data_callback, port))
- {
- perror("Can't bind cluster socket");
- return -1;
- }
-
- cman_start_notification(ch, event_callback);
-
- read_fd_head.fd = cman_get_fd(ch);
- read_fd_head.type = CLUSTER_SOCK;
-
- /* Preload cluster members list */
- get_members();
-
- /* Just a sensible default, we work out just how many
- responses we expect properly later */
- expected_responses = num_nodes;
-
- /* Open the Unix socket we listen for commands on */
- local_sock = open_local_sock();
- if (local_sock < 0)
- exit(2);
-
- newfd = malloc(sizeof(struct read_fd));
- if (!newfd)
- exit(2);
-
- newfd->fd = local_sock;
- newfd->type = LOCAL_RENDEZVOUS;
- newfd->next = NULL;
- read_fd_head.next = newfd;
-
- while (1)
- {
- fd_set in;
- struct read_fd *thisfd;
- struct timeval tv = {10,0};
-
- read_fd_head.fd = cman_get_fd(ch);
- FD_ZERO(&in);
- for (thisfd = &read_fd_head; thisfd != NULL; thisfd = thisfd->next)
- {
- FD_SET(thisfd->fd, &in);
- }
-
- if (select(FD_SETSIZE, &in, NULL, NULL, &tv) > 0)
- {
- struct read_fd *lastfd = NULL;
-
- for (thisfd = &read_fd_head; thisfd != NULL; thisfd = thisfd->next)
- {
- if (FD_ISSET(thisfd->fd, &in))
- {
- switch(thisfd->type)
- {
- /* Request or response from another cluster node */
- case CLUSTER_SOCK:
- if (cman_dispatch(ch, CMAN_DISPATCH_ONE) == -1)
- goto closedown;
- break;
-
- /* Someone connected to our local socket */
- case LOCAL_RENDEZVOUS:
- {
- struct sockaddr_un socka;
- struct read_fd *newfd;
- socklen_t sl = sizeof(socka);
- int client_fd = accept(local_sock, (struct sockaddr *)&socka, &sl);
-
- if (client_fd >= 0)
- {
- newfd = malloc(sizeof(struct read_fd));
- if (!newfd)
- {
- close(client_fd);
- break;
- }
- newfd->fd = client_fd;
- newfd->type = LOCAL_SOCK;
- newfd->next = thisfd->next;
- newfd->nodes_done = 0;
- newfd->start_time = time(NULL);
- thisfd->next = newfd;
- }
- }
- break;
-
- /* Data on a connected socket */
- case LOCAL_SOCK:
- {
- int len;
- char buffer[PIPE_BUF];
- len = read(thisfd->fd, buffer, sizeof(buffer));
-
- /* EOF on socket */
- if (len <= 0)
- {
- struct read_fd *free_fd;
-
- close(thisfd->fd);
- /* Remove it from the list safely */
- lastfd->next = thisfd->next;
- free_fd = thisfd;
- thisfd = lastfd;
- free(free_fd);
- }
- else
- {
- char cman_buffer[PIPE_BUF];
- struct sysman_header *header = (struct sysman_header *)cman_buffer;
-
- expected_responses = nodes_listening(thisfd->fd);
-
- header->fd = htonl(thisfd->fd);
- header->cmd = SYSMAN_CMD_REQUEST;
- memcpy(cman_buffer+sizeof(*header), buffer, len);
-
- if (!cman_send_data(ch, cman_buffer, sizeof(*header)+len, 0, port, 0))
- {
- perror("write");
- goto closedown;
- }
- }
- }
- break;
-
- } /* switch */
-
- }
- lastfd = thisfd;
- }
- }
- /* Check for timed-out connections */
- for (thisfd = &read_fd_head; thisfd != NULL; thisfd = thisfd->next)
- {
- if (thisfd->type == LOCAL_SOCK && (thisfd->start_time <= time(NULL)-10))
- {
- write(thisfd->fd,"Timed-out\n", 10);
- close(thisfd->fd);
- remove_sock(thisfd);
-
- /* Refresh members list in case a node has gone down
- or a remote sysmand has crashed */
- get_members();
- }
- }
- }
- closedown:
- cman_finish(ch);
- close(local_sock);
-
- return 0;
-}
-
-/* Get a list of members */
-static void get_members()
-{
- num_nodes = cman_get_node_count(ch);
- if (num_nodes == -1)
- {
- perror("get nodes");
- }
- else
- {
- if (nodes) free(nodes);
-
- nodes = malloc(num_nodes * sizeof(cman_node_t));
-
- if (cman_get_nodes(ch, num_nodes, &num_nodes, nodes))
- perror("Error getting node list");
- }
-}
-
-/* Convert a nodeid to a node name */
-static int name_from_nodeid(int nodeid, char *name)
-{
- int i;
-
- for (i=0; i<num_nodes; i++)
- {
- if (nodeid == nodes[i].cn_nodeid)
- {
- strcpy(name, nodes[i].cn_name);
- return 0;
- }
- }
- /* Who?? */
- strcpy(name, "Unknown");
- return -1;
-}
-
-/* Check which nodes are listening on the SYSMAN port */
-static int nodes_listening(int errfd)
-{
- int i;
- int num_listening = 0;
-
- for (i=0; i<num_nodes; i++)
- {
- int listening;
-
- listening = cman_is_listening(ch, nodes[i].cn_nodeid, CLUSTER_PORT_SYSMAN);
-
- if (listening > 0)
- {
- num_listening++;
- }
- else
- {
- if (listening == 0)
- {
- char errstring[1024];
- int len;
- len = snprintf(errstring, sizeof(errstring),
- "WARNING: node %s is not listening for SYSMAN requests\n",
- nodes[i].cn_name);
- write(errfd, errstring, len);
- }
- }
- }
- return num_listening;
-}
-
-static int open_local_sock()
-{
- int local_socket;
- struct sockaddr_un sockaddr;
-
- // Open local socket
- unlink(LOCAL_SOCKNAME);
- local_socket = socket(PF_UNIX, SOCK_STREAM, 0);
- if (local_socket < 0)
- {
- syslog(LOG_ERR, "Can't create local socket: %m");
- return -1;
- }
-
- strcpy(sockaddr.sun_path, LOCAL_SOCKNAME);
- sockaddr.sun_family = AF_UNIX;
- if (bind(local_socket, (struct sockaddr *)&sockaddr, sizeof(sockaddr)))
- {
- syslog(LOG_ERR, "can't bind local socket: %m");
- close(local_socket);
- return -1;
- }
- if (listen(local_socket, 1) != 0)
- {
- syslog(LOG_ERR, "listen local: %m");
- close(local_socket);
- return -1;
- }
- // Make sure only root can talk to us via the local socket.
- // Considering the rest of the security implications of
- // this code, this is simply pathetic!
- chmod(LOCAL_SOCKNAME, 0600);
-
- return local_socket;
-}
-
-static struct read_fd *find_by_fd(int fd)
-{
- struct read_fd *thisfd;
-
- for (thisfd = &read_fd_head; thisfd != NULL; thisfd = thisfd->next)
- if (fd == thisfd->fd) return thisfd;
-
- return NULL;
-}
-
-static void remove_sock(struct read_fd *deadfd)
-{
- struct read_fd *thisfd;
- struct read_fd *lastfd=NULL;
-
- for (thisfd = &read_fd_head; thisfd != NULL; thisfd = thisfd->next)
- {
- if (thisfd == deadfd)
- {
- lastfd->next = deadfd->next;
- free(deadfd);
- }
- lastfd = thisfd;
- }
-}
-
-static int exec_command(char *cmd, char *reply, int *len)
-{
- FILE *pipe;
- int readlen;
- int avail = PIPE_BUF-sizeof(struct sysman_header)-1;
- char realcmd[strlen(cmd)+25];
-
- /* Send stderr back to the caller, and make stdin /dev/null */
- snprintf(realcmd, sizeof(realcmd), "%s </dev/null 2>&1", cmd);
-
- *len = 0;
- pipe = popen(realcmd, "r");
-
- /* Fill the buffer as full as possible */
- do
- {
- readlen = fread(reply + *len, 1, avail, pipe);
- if (readlen > 0)
- {
- *len += readlen;
- avail -= readlen;
- }
- }
- while (avail>0 && readlen > 0);
-
- reply[*len] ='\0';
-
- /* Return completion status of command */
- return pclose(pipe);
-}
diff --git a/cman/tests/user_service.c b/cman/tests/user_service.c
deleted file mode 100644
index f47987b..0000000
--- a/cman/tests/user_service.c
+++ /dev/null
@@ -1,285 +0,0 @@
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include "cnxman-socket.h"
-
-static pthread_t recv_thread;
-static int cl_sock;
-static int quit = 0;
-static int leave_finished = 0;
-static pid_t our_pid;
-
-
-/* SIGUSR1 will cause this program to look for a new service event from SM
- using the GETEVENT ioctl.
-
- SIGTERM will cause this program to leave the service group cleanly; it will
- do a LEAVE ioctl, get a stop event and then exit.
-
- SIGKILL will cause the program to exit without first leaving the service
- group. In that case the kernel will clean up and leave the service group
- (as a part of cl_release on the cluster socket). */
-
-
-static void sigusr1_handler(int sig)
-{
-}
-
-static void sigterm_handler(int sig)
-{
- quit = 1;
-}
-
-/* This thread receives messages on the cluster socket and prints them. */
-
-static void *recv_thread_fn(void *arg)
-{
- struct iovec iov[2];
- struct msghdr msg;
- struct sockaddr_cl saddr;
- char buf[256];
- int len;
- int nodeid;
-
- for (;;) {
- memset(buf, 0, 256);
-
- msg.msg_control = NULL;
- msg.msg_controllen = 0;
- msg.msg_iovlen = 1;
- msg.msg_iov = iov;
- msg.msg_name = &saddr;
- msg.msg_flags = 0;
- msg.msg_namelen = sizeof(saddr);
- iov[0].iov_len = sizeof(buf);
- iov[0].iov_base = buf;
-
- len = recvmsg(cl_sock, &msg, MSG_OOB);
-
- if (len < 0 && errno == EAGAIN)
- continue;
-
- if (!len || len < 0)
- continue;
-
- nodeid = saddr.scl_nodeid;
-
- if (buf[0] == CLUSTER_OOB_MSG_PORTCLOSED)
- printf("message: oob port-closed from nodeid %d\n",
- nodeid);
-
- else if (buf[0] == CLUSTER_OOB_MSG_SERVICEEVENT)
- printf("message: oob service-event\n");
-
- else if (!strcmp(buf, "hello"))
- printf("message: \"%s\" from nodeid %d\n", buf, nodeid);
-
- else
- printf("message: unknown len %d byte0 %x nodeid %d\n",
- len, buf[0], nodeid);
- }
-}
-
-static void send_group_message(void)
-{
- struct iovec iov[2];
- struct msghdr msg;
- char buf[256];
- int len;
-
- strcpy(buf, "hello");
-
- iov[0].iov_len = strlen(buf);
- iov[0].iov_base = buf;
- msg.msg_control = NULL;
- msg.msg_controllen = 0;
- msg.msg_iovlen = 1;
- msg.msg_iov = iov;
- msg.msg_name = NULL;
- msg.msg_flags = O_NONBLOCK;
- msg.msg_namelen = 0;
-
- len = sendmsg(cl_sock, &msg, 0);
-}
-
-static void print_ev(struct cl_service_event *ev)
-{
- switch (ev->type) {
- case SERVICE_EVENT_STOP:
- printf("stop:\n");
- break;
- case SERVICE_EVENT_START:
- printf("start:\n");
- break;
- case SERVICE_EVENT_FINISH:
- printf("finish:\n");
- break;
- case SERVICE_EVENT_LEAVEDONE:
- printf("leavedone:\n");
- break;
- }
- printf(" event_id = %u\n", ev->event_id);
- printf(" last_stop = %u\n", ev->last_stop);
- printf(" last_start = %u\n", ev->last_start);
- printf(" last_finish = %u\n", ev->last_finish);
- printf(" node_count = %u\n", ev->node_count);
-}
-
-static void print_members(int count, struct cl_cluster_node *nodes)
-{
- int i;
-
- printf("members:\n");
- for (i = 0; i < count; i++) {
- printf(" nodeid = %u \"%s\"\n", nodes->node_id, nodes->name);
- nodes++;
- }
-}
-
-static int process_event(struct cl_service_event *ev)
-{
- struct cl_cluster_node *nodes;
- int error = 0;
-
- print_ev(ev);
-
- if (ev->type == SERVICE_EVENT_START) {
-
- nodes = malloc(ev->node_count * sizeof(struct cl_cluster_node));
- if (!nodes) {
- perror("process_event: malloc failed");
- return -ENOMEM;
- }
-
- memset(nodes, 0, ev->node_count*sizeof(struct cl_cluster_node));
-
- error = ioctl(cl_sock, SIOCCLUSTER_SERVICE_GETMEMBERS, nodes);
- if (error < 0)
- perror("process_event: service get members failed");
-
- print_members(ev->node_count, nodes);
-
- error = ioctl(cl_sock, SIOCCLUSTER_SERVICE_STARTDONE,
- ev->event_id);
- if (error < 0)
- perror("process_event: start done error");
-
- /* send_group_message(); */
-
- free(nodes);
- }
-
- if (ev->type == SERVICE_EVENT_LEAVEDONE)
- leave_finished = 1;
-
- return error;
-}
-
-int main(int argc, char **argv)
-{
- struct cl_service_event event;
- struct sockaddr_cl saddr;
- char *name;
- int error;
-
- our_pid = getpid();
-
- if (argc > 1)
- name = argv[1];
- else
- name = "example";
-
-
- cl_sock = socket(AF_CLUSTER, SOCK_DGRAM, CLPROTO_CLIENT);
- if (cl_sock < 0) {
- perror("main: can't create cluster socket");
- return -1;
- }
-
-
- error = ioctl(cl_sock, SIOCCLUSTER_SERVICE_REGISTER, name);
- if (error < 0) {
- perror("main: service register failed");
- return -1;
- }
-
-
- /* binding to an address is only needed if we want to send/recv
- messages to other nodes on the cluster socket. */
-
-#if 0
- saddr.scl_family = AF_CLUSTER;
- saddr.scl_port = 13; /* CLUSTER_PORT_USER_SERVICE */
-
- error = bind(cl_sock, (struct sockaddr *) &saddr,
- sizeof(struct sockaddr_cl));
- if (error < 0) {
- perror("main: can't bind to cluster socket");
- return -1;
- }
- pthread_create(&recv_thread, NULL, recv_thread_fn, 0);
-#endif
-
- signal(SIGUSR1, sigusr1_handler);
- signal(SIGTERM, sigterm_handler);
-
- error = ioctl(cl_sock, SIOCCLUSTER_SERVICE_SETSIGNAL, SIGUSR1);
- if (error < 0) {
- perror("main: service set signal failed");
- return -1;
- }
-
- error = ioctl(cl_sock, SIOCCLUSTER_SERVICE_JOIN, NULL);
- if (error < 0) {
- perror("main: service join failed");
- return -1;
- }
-
-
- for (;;) {
- memset(&event, 0, sizeof(struct cl_service_event));
-
- error = ioctl(cl_sock, SIOCCLUSTER_SERVICE_GETEVENT, &event);
- if (error < 0) {
- perror("main: service get event failed");
- return -1;
- }
-
- if (!error)
- pause();
- else
- process_event(&event);
-
-
- if (quit) {
- quit = 0;
- leave_finished = 0;
-
- error = ioctl(cl_sock, SIOCCLUSTER_SERVICE_LEAVE, NULL);
- if (error < 0) {
- perror("main: service leave failed");
- return -1;
- }
- }
-
- if (leave_finished)
- break;
- }
-
- error = ioctl(cl_sock, SIOCCLUSTER_SERVICE_UNREGISTER, NULL);
- if (error < 0)
- perror("main: unregister failed");
-
- return 0;
-}
diff --git a/common/Makefile b/common/Makefile
deleted file mode 100644
index 31fdfdb..0000000
--- a/common/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../make/defines.mk
-include $(OBJDIR)/make/passthrough.mk
-
-SUBDIRS=liblogthread
diff --git a/common/liblogthread/Makefile b/common/liblogthread/Makefile
deleted file mode 100644
index be072bf..0000000
--- a/common/liblogthread/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET= liblogthread
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/libs.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -I${incdir}
-
-LDFLAGS += -lpthread
diff --git a/common/liblogthread/liblogthread.c b/common/liblogthread/liblogthread.c
deleted file mode 100644
index b44f01a..0000000
--- a/common/liblogthread/liblogthread.c
+++ /dev/null
@@ -1,378 +0,0 @@
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <time.h>
-#include <syslog.h>
-#include <pthread.h>
-#include <sys/param.h>
-
-#include "liblogthread.h"
-
-#define DEFAULT_ENTRIES 4096
-#define ENTRY_STR_LEN 128
-
-struct entry {
- int level;
- char str[ENTRY_STR_LEN];
- time_t time;
-};
-
-static struct entry *ents;
-static unsigned int num_ents = DEFAULT_ENTRIES;
-static unsigned int head_ent, tail_ent; /* add at head, remove from tail */
-static unsigned int dropped;
-static unsigned int pending_ents;
-static unsigned int init;
-static unsigned int done;
-static pthread_t thread_handle;
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-
-static int logt_mode; /* LOG_MODE_ */
-static int logt_syslog_facility;
-static int logt_syslog_priority;
-static int logt_logfile_priority;
-static char logt_name[PATH_MAX];
-static char logt_logfile[PATH_MAX];
-static FILE *logt_logfile_fp;
-static FILE *new_logt_logfile_fp;
-
-static char *_time(time_t *t)
-{
- static char buf[64];
- struct tm *tm;
-
- tm = localtime(t);
- if (!tm) {
- strncpy(buf, "unknown time", sizeof(buf) - 1);
- } else {
- strftime(buf, sizeof(buf), "%b %d %T", tm);
- }
-
- return buf;
-}
-
-static void write_entry(int level, time_t *t, char *str)
-{
- if ((logt_mode & LOG_MODE_OUTPUT_FILE) &&
- (level <= logt_logfile_priority) && logt_logfile_fp) {
- fprintf(logt_logfile_fp, "%s %s %s", _time(t), logt_name, str);
- fflush(logt_logfile_fp);
- }
- if ((logt_mode & LOG_MODE_OUTPUT_SYSLOG) &&
- (level <= logt_syslog_priority))
- syslog(level, "%s", str);
-}
-
-static void write_dropped(int level, time_t *t, int num)
-{
- char str[ENTRY_STR_LEN];
- snprintf(str, sizeof(str) - 1, "dropped %d entries", num);
- write_entry(level, t, str);
-}
-
-static void *thread_fn(void *arg)
-{
- char str[ENTRY_STR_LEN];
- struct entry *e;
- time_t logtime;
- int level, prev_dropped = 0;
-
- while (1) {
- pthread_mutex_lock(&mutex);
- while (head_ent == tail_ent) {
- if (done) {
- pthread_mutex_unlock(&mutex);
- goto out;
- }
- pthread_cond_wait(&cond, &mutex);
- }
-
- e = &ents[tail_ent++];
- tail_ent = tail_ent % num_ents;
- pending_ents--;
-
- memcpy(str, e->str, ENTRY_STR_LEN);
- level = e->level;
- logtime = e->time;
-
- prev_dropped = dropped;
- dropped = 0;
-
- if (new_logt_logfile_fp) {
- fclose(logt_logfile_fp);
- logt_logfile_fp = new_logt_logfile_fp;
- new_logt_logfile_fp = NULL;
- }
-
- pthread_mutex_unlock(&mutex);
-
- if (prev_dropped) {
- write_dropped(level, &logtime, prev_dropped);
- prev_dropped = 0;
- }
-
- write_entry(level, &logtime, str);
- }
- out:
- pthread_exit(NULL);
-}
-
-static void _logt_print(int level, char *buf)
-{
- struct entry *e;
-
- pthread_mutex_lock(&mutex);
-
- if (pending_ents == num_ents) {
- dropped++;
- goto out;
- }
-
- e = &ents[head_ent++];
- head_ent = head_ent % num_ents;
- pending_ents++;
-
- strncpy(e->str, buf, ENTRY_STR_LEN - 1);
- e->level = level;
- e->time = time(NULL);
- out:
- pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
-}
-
-void logt_print(int level, const char *fmt, ...)
-{
- va_list ap;
- char buf[ENTRY_STR_LEN];
-
- if (!init)
- return;
-
- buf[sizeof(buf) - 1] = 0;
-
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
- va_end(ap);
-
- if (level > logt_syslog_priority && level > logt_logfile_priority)
- return;
-
- /* this stderr crap really doesn't belong in this lib, please
- feel free to not use it */
- if (logt_mode & LOG_MODE_OUTPUT_STDERR)
- fputs(buf, stderr);
-
- _logt_print(level, buf);
-}
-
-static void _conf(const char *name, int mode, int syslog_facility,
- int syslog_priority, int logfile_priority, const char *logfile)
-{
- int fd;
-
- logt_mode = mode;
- logt_syslog_facility = syslog_facility;
- logt_syslog_priority = syslog_priority;
- logt_logfile_priority = logfile_priority;
- if (name)
- strncpy(logt_name, name, PATH_MAX - 1);
- if (logfile)
- strncpy(logt_logfile, logfile, PATH_MAX - 1);
-
- if (logt_mode & LOG_MODE_OUTPUT_FILE && logt_logfile[0]) {
- /* Don't close the existing fp in this thread, let the main logthread do it later */
- if (!logt_logfile_fp) {
- logt_logfile_fp = fopen(logt_logfile, "a+");
- if (logt_logfile_fp != NULL) {
- fd = fileno(logt_logfile_fp);
- fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
- }
- }
- else {
- new_logt_logfile_fp = fopen(logt_logfile, "a+");
- if (new_logt_logfile_fp != NULL) {
- fd = fileno(new_logt_logfile_fp);
- fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
- }
- }
- } else {
- if (logt_logfile_fp) {
- fclose(logt_logfile_fp);
- logt_logfile_fp = NULL;
- }
- if (new_logt_logfile_fp) {
- fclose(new_logt_logfile_fp);
- new_logt_logfile_fp = NULL;
- }
- }
-
- if (logt_mode & LOG_MODE_OUTPUT_SYSLOG) {
- closelog();
- openlog(logt_name, LOG_CONS | LOG_PID, logt_syslog_facility);
- }
-}
-
-void logt_conf(const char *name, int mode, int syslog_facility, int syslog_priority,
- int logfile_priority, const char *logfile)
-{
- pthread_mutex_lock(&mutex);
- if (init)
- _conf(name, mode, syslog_facility, syslog_priority, logfile_priority,
- logfile);
-
- pthread_mutex_unlock(&mutex);
-}
-
-static int _init(const char *name, int mode, int syslog_facility, int syslog_priority,
- int logfile_priority, const char *logfile)
-{
- if (init)
- return -1;
-
- _conf(name, mode, syslog_facility, syslog_priority, logfile_priority,
- logfile);
-
- ents = malloc(num_ents * sizeof(struct entry));
- if (!ents)
- return -1;
-
- memset(ents, 0, num_ents * sizeof(struct entry));
-
- if (pthread_create(&thread_handle, NULL, thread_fn, NULL)) {
- free(ents);
- return -1;
- }
- done = 0;
- init = 1;
-
- return 0;
-}
-
-int logt_init(const char *name, int mode, int syslog_facility, int syslog_priority,
- int logfile_priority, const char *logfile)
-{
- int rv = 0;
-
- pthread_mutex_lock(&mutex);
- rv = _init(name, mode, syslog_facility, syslog_priority,
- logfile_priority, logfile);
- pthread_mutex_unlock(&mutex);
- return rv;
-}
-
-/*
- * Reinitialize logt w/ previous values (e.g. use after
- * a call to fork())
- *
- * Only works after you call logt_init and logt_exit
- */
-int logt_reinit(void)
-{
- char name_tmp[PATH_MAX];
- char file_tmp[PATH_MAX];
- int rv = 0;
-
- pthread_mutex_lock(&mutex);
- if (!done || init) {
- rv = -1;
- goto out;
- }
-
- /* Use copies on the stack for these */
- memset(name_tmp, 0, sizeof(name_tmp));
- memset(file_tmp, 0, sizeof(file_tmp));
-
- strncpy(name_tmp, logt_name, sizeof(name_tmp) - 1);
- if (!strlen(name_tmp)) {
- rv = -1;
- goto out;
- }
- if (strlen(logt_logfile))
- strncpy(file_tmp, logt_logfile, sizeof(file_tmp) - 1);
-
- rv = _init(name_tmp, logt_mode, logt_syslog_facility,
- logt_syslog_priority, logt_logfile_priority,
- file_tmp);
-
-out:
- pthread_mutex_unlock(&mutex);
- return rv;
-}
-
-
-void logt_exit(void)
-{
- pthread_mutex_lock(&mutex);
- done = 1;
- init = 0;
- pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
- pthread_join(thread_handle, NULL);
-
- pthread_mutex_lock(&mutex);
- /* close syslog + log file */
- closelog();
- if (logt_logfile_fp) {
- fclose(logt_logfile_fp);
- logt_logfile_fp = NULL;
- }
-
- /* clean up any pending log messages */
- dropped = 0;
- pending_ents = 0;
- head_ent = tail_ent = 0;
- free(ents);
- ents = NULL;
-
- pthread_mutex_unlock(&mutex);
-}
-
-#ifdef TEST
-int main(int argc, char **argv)
-{
- int pid;
-
- logt_init("test", LOG_MODE_OUTPUT_FILE|LOG_MODE_OUTPUT_SYSLOG,
- LOG_DAEMON, LOG_DEBUG, LOG_DEBUG, "/tmp/logthread");
- logt_print(LOG_DEBUG, "debugging message %d\n", argc);
- logt_print(LOG_ERR, "error message %d\n", argc);
- sleep(1);
- logt_print(LOG_DEBUG, "second debug message\n");
- logt_exit();
-
- logt_print(LOG_ERR, "If you see this, it's a bug\n");
-
- logt_init("test2", LOG_MODE_OUTPUT_FILE|LOG_MODE_OUTPUT_SYSLOG,
- LOG_DAEMON, LOG_DEBUG, LOG_DEBUG, "/tmp/logthread");
- logt_print(LOG_DEBUG, "after 2nd init %d\n", argc);
- logt_print(LOG_ERR, "error message %d\n", argc);
- logt_print(LOG_DEBUG, "third debug message\n");
- logt_exit();
-
- logt_print(LOG_ERR, "If you see this, it's a bug\n");
-
- logt_reinit();
- logt_print(LOG_DEBUG, "after reinit\n");
- logt_print(LOG_DEBUG, "<-- should say test2\n");
-
- logt_exit();
-
- if ((pid = fork()) < 0)
- return -1;
-
- if (pid)
- exit(0);
-
- /* child process */
- logt_reinit();
- logt_print(LOG_DEBUG, "HELLO from child process\n");
- logt_exit();
-
- return 0;
-}
-#endif
-
diff --git a/common/liblogthread/liblogthread.h b/common/liblogthread/liblogthread.h
deleted file mode 100644
index 3c17395..0000000
--- a/common/liblogthread/liblogthread.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef LOGTHREAD_DOT_H
-#define LOGTHREAD_DOT_H
-
-#include <syslog.h>
-
-#define LOG_MODE_OUTPUT_FILE 1
-#define LOG_MODE_OUTPUT_SYSLOG 2
-#define LOG_MODE_OUTPUT_STDERR 4
-
-int logt_init(const char *name, int mode, int syslog_facility, int syslog_priority,
- int logfile_priority, const char *logfile);
-void logt_conf(const char *name, int mode, int syslog_facility, int syslog_priority,
- int logfile_priority, const char *logfile);
-void logt_exit(void);
-int logt_reinit(void);
-void logt_print(int level, const char *fmt, ...)
- __attribute__((format(printf, 2, 3)));;
-
-#endif
diff --git a/common/liblogthread/liblogthread.pc.in b/common/liblogthread/liblogthread.pc.in
deleted file mode 100644
index 8ba8268..0000000
--- a/common/liblogthread/liblogthread.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@PREFIX@
-exec_prefix=${prefix}
-libdir=@LIBDIR@
-includedir=@INCDIR@
-
-Name: liblogthread
-Version: @VERSION@
-Description: Cluster threaded logging library
-Requires:
-Libs: -L${libdir} -llogthread
-Cflags: -I${includedir}
diff --git a/config/Makefile b/config/Makefile
deleted file mode 100644
index 50468ed..0000000
--- a/config/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../make/defines.mk
-include $(OBJDIR)/make/passthrough.mk
-
-SUBDIRS=libs plugins tools man
diff --git a/config/libs/Makefile b/config/libs/Makefile
deleted file mode 100644
index 8fd2879..0000000
--- a/config/libs/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../../make/defines.mk
-include $(OBJDIR)/make/passthrough.mk
-
-SUBDIRS = libccsconfdb
diff --git a/config/libs/libccsconfdb/Makefile b/config/libs/libccsconfdb/Makefile
deleted file mode 100644
index 2b233f3..0000000
--- a/config/libs/libccsconfdb/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-TARGET= libccs
-
-INCDIRT=ccs.h
-
-OBJS= $(TARGET).o \
- xpathlite.o \
- fullxpath.o \
- extras.o
-
-include ../../../make/defines.mk
-include $(OBJDIR)/make/libs.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-CFLAGS += -I${corosyncincdir} -I${logtincdir} `xml2-config --cflags`
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${corosynclibdir} -lconfdb
-LDFLAGS += `xml2-config --libs`
-LDFLAGS += -L${libdir}
diff --git a/config/libs/libccsconfdb/ccs.h b/config/libs/libccsconfdb/ccs.h
deleted file mode 100644
index 5c67735..0000000
--- a/config/libs/libccsconfdb/ccs.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __CCS_DOT_H__
-#define __CCS_DOT_H__
-
-int ccs_connect(void);
-int ccs_force_connect(const char *cluster_name, int blocking);
-int ccs_disconnect(int desc);
-int ccs_get(int desc, const char *query, char **rtn);
-int ccs_get_list(int desc, const char *query, char **rtn);
-int ccs_set(int desc, const char *path, char *val);
-int ccs_lookup_nodename(int desc, const char *nodename, char **rtn);
-void ccs_read_logging(int fd, const char *name, int *debug, int *mode,
- int *syslog_facility, int *syslog_priority,
- int *logfile_priority, char *logfile);
-extern int fullxpath;
-
-#endif /* __CCS_DOT_H__ */
diff --git a/config/libs/libccsconfdb/ccs_internal.h b/config/libs/libccsconfdb/ccs_internal.h
deleted file mode 100644
index 617f9e7..0000000
--- a/config/libs/libccsconfdb/ccs_internal.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __CCS_INTERNAL_DOT_H__
-#define __CCS_INTERNAL_DOT_H__
-
-/* NOTE: use __attribute__ to hide the internal API */
-
-/* from libccs.c */
-void reset_iterator(confdb_handle_t handle, hdb_handle_t connection_handle)
- __attribute__ ((visibility("hidden")));
-int get_previous_query(confdb_handle_t handle, hdb_handle_t connection_handle,
- char *previous_query, hdb_handle_t *query_handle)
- __attribute__ ((visibility("hidden")));
-int set_previous_query(confdb_handle_t handle, hdb_handle_t connection_handle,
- const char *previous_query, hdb_handle_t query_handle)
- __attribute__ ((visibility("hidden")));
-
-/* from xpathlite.c */
-char *_ccs_get_xpathlite(confdb_handle_t handle, hdb_handle_t connection_handle,
- const char *query, int list)
- __attribute__ ((visibility("hidden")));
-
-/* from fullxpath.c */
-char *_ccs_get_fullxpath(confdb_handle_t handle, hdb_handle_t connection_handle,
- const char *query, int list)
- __attribute__ ((visibility("hidden")));
-int xpathfull_init(confdb_handle_t handle)
- __attribute__ ((visibility("hidden")));
-void xpathfull_finish(void) __attribute__ ((visibility("hidden")));
-
-#endif /* __CCS_INTERNAL_DOT_H__ */
diff --git a/config/libs/libccsconfdb/extras.c b/config/libs/libccsconfdb/extras.c
deleted file mode 100644
index 34cbbae..0000000
--- a/config/libs/libccsconfdb/extras.c
+++ /dev/null
@@ -1,454 +0,0 @@
-#include <ctype.h>
-#include <errno.h>
-#include <string.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <limits.h>
-
-#define SYSLOG_NAMES
-#include <syslog.h>
-#include <liblogthread.h>
-
-#include "ccs.h"
-
-/**
- * ccs_lookup_nodename
- * @cd: ccs descriptor
- * @nodename: node name string
- * @retval: pointer to location to assign the result, if found
- *
- * This function takes any valid representation (FQDN, non-qualified
- * hostname, IP address, IPv6 address) of a node's name and finds its
- * canonical name (per cluster.conf). This function will find the primary
- * node name if passed a node's "altname" or any valid representation
- * of it.
- *
- * Returns: 0 on success, < 0 on failure
- */
-int ccs_lookup_nodename(int cd, const char *nodename, char **retval)
-{
- char path[256];
- char host_only[128];
- char *str;
- char *p;
- int error;
- int ret;
- unsigned int i;
- size_t nodename_len;
- struct addrinfo hints;
-
- if (nodename == NULL) {
- errno = EINVAL;
- return -1;
- }
-
- nodename_len = strlen(nodename);
- ret = snprintf(path, sizeof(path),
- "/cluster/clusternodes/clusternode[@name=\"%s\"]/@name",
- nodename);
- if (ret < 0 || (size_t) ret >= sizeof(path)) {
- errno = E2BIG;
- return -1;
- }
-
- str = NULL;
- error = ccs_get(cd, path, &str);
- if (!error) {
- *retval = str;
- return 0;
- }
-
- if (nodename_len >= sizeof(host_only)) {
- errno = E2BIG;
- return -1;
- }
-
- /* Try just the hostname */
- strncpy(host_only, nodename, sizeof(host_only) - 1);
- p = strchr(host_only, '.');
- if (p != NULL) {
- *p = '\0';
-
- ret = snprintf(path, sizeof(path),
- "/cluster/clusternodes/clusternode[@name=\"%s\"]/@name",
- host_only);
- if (ret < 0 || (size_t) ret >= sizeof(path)) {
- errno = E2BIG;
- return -1;
- }
-
- str = NULL;
- error = ccs_get(cd, path, &str);
- if (!error) {
- *retval = str;
- return 0;
- }
- }
-
- memset(&hints, 0, sizeof(hints));
- if (strchr(nodename, ':') != NULL)
- hints.ai_family = AF_INET6;
- else if (isdigit(nodename[nodename_len - 1]))
- hints.ai_family = AF_INET;
- else
- hints.ai_family = AF_UNSPEC;
-
- /*
- ** Try to match against each clusternode in cluster.conf.
- */
- for (i = 1;; i++) {
- char canonical_name[128];
- unsigned int altcnt;
-
- ret = snprintf(path, sizeof(path),
- "/cluster/clusternodes/clusternode[%u]/@name",
- i);
- if (ret < 0 || (size_t) ret >= sizeof(path))
- continue;
-
- for (altcnt = 0;; altcnt++) {
- size_t len;
- struct addrinfo *ai = NULL;
- char cur_node[128];
-
- if (altcnt != 0) {
- ret = snprintf(path, sizeof(path),
- "/cluster/clusternodes/clusternode[%u]/altname[%u]/@name",
- i, altcnt);
- if (ret < 0 || (size_t) ret >= sizeof(path))
- continue;
- }
-
- str = NULL;
- error = ccs_get(cd, path, &str);
- if (error || !str) {
- if (altcnt == 0)
- goto out_fail;
- break;
- }
-
- if (altcnt == 0) {
- if (strlen(str) >= sizeof(canonical_name)) {
- free(str);
- errno = E2BIG;
- return -1;
- }
- strncpy(canonical_name, str, sizeof(canonical_name) - 1);
- }
-
- if (strlen(str) >= sizeof(cur_node)) {
- free(str);
- errno = E2BIG;
- return -1;
- }
-
- strncpy(cur_node, str, sizeof(cur_node) - 1);
-
- p = strchr(cur_node, '.');
- if (p != NULL)
- len = p - cur_node;
- else
- len = strlen(cur_node);
-
- if (strlen(host_only) == len &&
- !strncasecmp(host_only, cur_node, len)) {
- free(str);
- *retval = strdup(canonical_name);
- if (*retval == NULL) {
- errno = ENOMEM;
- return -1;
- }
- return 0;
- }
-
- if (getaddrinfo(str, NULL, &hints, &ai) == 0) {
- struct addrinfo *cur;
-
- for (cur = ai; cur != NULL; cur = cur->ai_next) {
- char hostbuf[512];
- if (getnameinfo
- (cur->ai_addr, cur->ai_addrlen,
- hostbuf, sizeof(hostbuf), NULL, 0,
- hints.ai_family !=
- AF_UNSPEC ? NI_NUMERICHOST : 0)) {
- continue;
- }
-
- if (!strcasecmp(hostbuf, nodename)) {
- freeaddrinfo(ai);
- free(str);
- *retval =
- strdup(canonical_name);
- if (*retval == NULL) {
- errno = ENOMEM;
- return -1;
- }
- return 0;
- }
- }
- freeaddrinfo(ai);
- }
-
- free(str);
-
- /* Now try any altnames */
- }
- }
-
-out_fail:
- errno = EINVAL;
- *retval = NULL;
- return -1;
-}
-
-static int facility_id_get(char *name)
-{
- unsigned int i;
-
- for (i = 0; facilitynames[i].c_name != NULL; i++) {
- if (strcasecmp(name, facilitynames[i].c_name) == 0) {
- return (facilitynames[i].c_val);
- }
- }
- return (-1);
-}
-
-static int priority_id_get(char *name)
-{
- unsigned int i;
-
- for (i = 0; prioritynames[i].c_name != NULL; i++) {
- if (strcasecmp(name, prioritynames[i].c_name) == 0) {
- return (prioritynames[i].c_val);
- }
- }
- return (-1);
-}
-
-/* requires string buffer to be PATH_MAX */
-static void read_string(int fd, const char *path, char *string, size_t string_s)
-{
- char *str;
- int error;
-
- memset(string, 0, PATH_MAX);
-
- error = ccs_get(fd, path, &str);
- if (error || !str)
- return;
-
- strncpy(string, str, string_s - 1);
-
- free(str);
-}
-
-static void read_yesno(int fd, const char *path, int *yes, int *no)
-{
- char *str;
- int error;
-
- *yes = 0;
- *no = 0;
-
- error = ccs_get(fd, path, &str);
- if (error || !str)
- return;
-
- if (!strcmp(str, "yes"))
- *yes = 1;
- else if (!strcmp(str, "no"))
- *no = 1;
-
- free(str);
-}
-
-static void read_onoff(int fd, const char *path, int *on, int *off)
-{
- char *str;
- int error;
-
- *on = 0;
- *off = 0;
-
- error = ccs_get(fd, path, &str);
- if (error || !str)
- return;
-
- if (!strcmp(str, "on"))
- *on = 1;
- else if (!strcmp(str, "off"))
- *off = 1;
-
- free(str);
-}
-
-/* requires path buffer to be PATH_MAX */
-static void create_daemon_path(const char *name, const char *field, char *path)
-{
- memset(path, 0, PATH_MAX);
- snprintf(path, PATH_MAX,
- "/cluster/logging/logging_daemon[@name=\"%s\"]/@%s",
- name, field);
-}
-
-/* Values should be initialized to default values before calling
- this function; they are not changed if cluster.conf has nothing
- to say about them. If *debug is already set , then *logfile_priority
- is set to LOG_DEBUG; all debug and logfile_priority values from
- cluster.conf are ignored. */
-
-void ccs_read_logging(int fd, const char *name, int *debug, int *mode,
- int *syslog_facility, int *syslog_priority,
- int *logfile_priority, char *logfile)
-{
- char string[PATH_MAX];
- char path[PATH_MAX];
- int val, y, n, on, off;
-
- /*
- * to_syslog
- */
- create_daemon_path(name, "to_syslog", path);
-
- read_yesno(fd, "/cluster/logging/@to_syslog", &y, &n);
- if (y)
- *mode |= LOG_MODE_OUTPUT_SYSLOG;
- if (n)
- *mode &= ~LOG_MODE_OUTPUT_SYSLOG;
-
- read_yesno(fd, path, &y, &n);
- if (y)
- *mode |= LOG_MODE_OUTPUT_SYSLOG;
- if (n)
- *mode &= ~LOG_MODE_OUTPUT_SYSLOG;
-
- /*
- * to_logfile
- */
- create_daemon_path(name, "to_logfile", path);
-
- read_yesno(fd, "/cluster/logging/@to_logfile", &y, &n);
- if (y)
- *mode |= LOG_MODE_OUTPUT_FILE;
- if (n)
- *mode &= ~LOG_MODE_OUTPUT_FILE;
-
- read_yesno(fd, path, &y, &n);
- if (y)
- *mode |= LOG_MODE_OUTPUT_FILE;
- if (n)
- *mode &= ~LOG_MODE_OUTPUT_FILE;
-
- /*
- * syslog_facility
- */
- create_daemon_path(name, "syslog_facility", path);
-
- read_string(fd, "/cluster/logging/@syslog_facility",
- string, sizeof(string));
-
- if (string[0]) {
- val = facility_id_get(string);
- if (val >= 0)
- *syslog_facility = val;
- }
-
- read_string(fd, path, string, sizeof(string));
-
- if (string[0]) {
- val = facility_id_get(string);
- if (val >= 0)
- *syslog_facility = val;
- }
-
- /*
- * syslog_priority
- */
- create_daemon_path(name, "syslog_priority", path);
-
- read_string(fd, "/cluster/logging/@syslog_priority",
- string, sizeof(string));
-
- if (string[0]) {
- val = priority_id_get(string);
- if (val >= 0)
- *syslog_priority = val;
- }
-
- read_string(fd, path, string, sizeof(string));
-
- if (string[0]) {
- val = priority_id_get(string);
- if (val >= 0)
- *syslog_priority = val;
- }
-
- /*
- * logfile
- */
- create_daemon_path(name, "logfile", path);
-
- read_string(fd, "/cluster/logging/@logfile", string, sizeof(string));
-
- if (string[0])
- strcpy(logfile, string);
-
- read_string(fd, path, string, sizeof(string));
-
- if (string[0])
- strcpy(logfile, string);
-
- /*
- * debug is only ever turned on, not off, so if it's already on
- * (from the daemon), then just skip the debug lookups.
- */
- if (*debug) {
- *logfile_priority = LOG_DEBUG;
- return;
- }
-
- /*
- * debug
- * debug=on is a shortcut for logfile_priority=LOG_DEBUG
- */
- create_daemon_path(name, "debug", path);
-
- read_onoff(fd, "/cluster/logging/@debug", &on, &off);
- if (on)
- *debug = 1;
-
- read_onoff(fd, path, &on, &off);
- if (on)
- *debug = 1;
- else if (off)
- *debug = 0;
-
- if (*debug) {
- *logfile_priority = LOG_DEBUG;
- return;
- }
-
- /*
- * logfile_priority
- */
- create_daemon_path(name, "logfile_priority", path);
-
- read_string(fd, "/cluster/logging/@logfile_priority",
- string, sizeof(string));
-
- if (string[0]) {
- val = priority_id_get(string);
- if (val >= 0)
- *logfile_priority = val;
- }
-
- read_string(fd, path, string, sizeof(string));
-
- if (string[0]) {
- val = priority_id_get(string);
- if (val >= 0)
- *logfile_priority = val;
- }
-}
-
diff --git a/config/libs/libccsconfdb/fullxpath.c b/config/libs/libccsconfdb/fullxpath.c
deleted file mode 100644
index bffb9c3..0000000
--- a/config/libs/libccsconfdb/fullxpath.c
+++ /dev/null
@@ -1,361 +0,0 @@
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <corosync/corotypes.h>
-#include <corosync/confdb.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-
-#include "ccs.h"
-#include "ccs_internal.h"
-
-#ifndef XMLBUFSIZE
-#define XMLBUFSIZE 64000
-#endif
-
-int fullxpath = 0;
-
-static xmlDocPtr doc = NULL;
-static xmlXPathContextPtr ctx = NULL;
-
-static int add_to_buffer(char *data, char **buffer, int *bufsize)
-{
- int datalen = 0, bufferlen = 0;
- char *newbuf = NULL;
-
- datalen = strlen(data);
- bufferlen = strlen(*buffer);
-
- if (datalen) {
- if ((bufferlen + datalen) >= *bufsize) {
- newbuf = malloc((*bufsize * 2));
- if (!newbuf) {
- errno = ENOMEM;
- return -1;
- }
- *bufsize = *bufsize * 2;
- memset(newbuf, 0, *bufsize);
- memcpy(newbuf, *buffer, bufferlen);
- free(*buffer);
- *buffer = newbuf;
- }
- strncpy(*buffer + bufferlen, data, datalen);
- }
- return 0;
-}
-
-static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_handle,
- hdb_handle_t parent_object_handle, char **buffer,
- int *bufsize)
-{
- hdb_handle_t object_handle;
- char temp[PATH_MAX];
- char object_name[PATH_MAX];
- char key_name[PATH_MAX];
- char *key_value = NULL;
- size_t key_value_len = 0, object_name_len = 0;
- confdb_value_types_t type;
- int res;
-
- res = confdb_key_iter_start(dump_handle, parent_object_handle);
- if (res != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
-
- if (!strlen(*buffer)) {
- snprintf(temp, PATH_MAX - 1,
- "<?xml version=\"1.0\"?>\n<cluster");
- if (add_to_buffer(temp, buffer, bufsize))
- return -1;
- }
-
- while ((res =
- confdb_key_iter_typed2(dump_handle, parent_object_handle, key_name,
- (void **)&key_value,
- &key_value_len, &type)) == CS_OK) {
- int char_pos = 0;
- key_value[key_value_len] = '\0';
-
- snprintf(temp, PATH_MAX - 1, " %s=\"", key_name);
- if (add_to_buffer(temp, buffer, bufsize)) {
- free(key_value);
- return -1;
- }
-
- for (char_pos = 0; char_pos < key_value_len-1; char_pos++) {
- switch (key_value[char_pos]) {
-
- case '&':
- snprintf(temp, PATH_MAX - 1, "&");
- break;
- case '<':
- snprintf(temp, PATH_MAX - 1, "<");
- break;
- case '>':
- snprintf(temp, PATH_MAX - 1, ">");
- break;
- case '"':
- snprintf(temp, PATH_MAX - 1, """);
- break;
- case '\'':
- snprintf(temp, PATH_MAX - 1, "'");
- break;
- default:
- temp[0] = key_value[char_pos];
- temp[1] = '\0';
- break;
- }
- if (add_to_buffer(temp, buffer, bufsize)) {
- free(key_value);
- return -1;
- }
- }
- free(key_value);
- key_value = NULL;
-
- snprintf(temp, PATH_MAX - 1, "\"");
- if (add_to_buffer(temp, buffer, bufsize))
- return -1;
- }
-
- if (parent_object_handle > 0) {
- snprintf(temp, PATH_MAX - 1, ">\n");
- if (add_to_buffer(temp, buffer, bufsize))
- return -1;
- }
-
- res = confdb_object_iter_start(dump_handle, parent_object_handle);
- if (res != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
-
- while ((res =
- confdb_object_iter(dump_handle, parent_object_handle,
- &object_handle, object_name,
- &object_name_len)) == CS_OK) {
- hdb_handle_t parent;
-
- res =
- confdb_object_parent_get(dump_handle, object_handle,
- &parent);
- if (res != CS_OK) {
- errno = EINVAL;
- return -1;
- }
-
- object_name[object_name_len] = '\0';
-
- snprintf(temp, PATH_MAX - 1, "<%s", object_name);
- if (add_to_buffer(temp, buffer, bufsize))
- return -1;
-
- res =
- dump_objdb_buff(dump_handle, cluster_handle, object_handle, buffer,
- bufsize);
- if (res)
- return res;
-
- if (object_handle != parent_object_handle) {
- snprintf(temp, PATH_MAX - 1, "</%s>\n", object_name);
- if (add_to_buffer(temp, buffer, bufsize))
- return -1;
- } else {
- snprintf(temp, PATH_MAX - 1, ">\n");
- if (add_to_buffer(temp, buffer, bufsize))
- return -1;
- }
- }
-
- if (parent_object_handle == cluster_handle) {
- snprintf(temp, PATH_MAX - 1, "</cluster>\n");
- if (add_to_buffer(temp, buffer, bufsize))
- return -1;
- }
-
- return 0;
-}
-
-int xpathfull_init(confdb_handle_t handle)
-{
- int size = XMLBUFSIZE;
- char *buffer;
- hdb_handle_t cluster_handle;
-
- buffer = malloc(XMLBUFSIZE);
- if (!buffer) {
- errno = ENOMEM;
- goto fail;
- }
-
- memset(buffer, 0, XMLBUFSIZE);
-
- if (confdb_object_find_start(handle, OBJECT_PARENT_HANDLE) != CS_OK)
- goto fail;
-
- if (confdb_object_find(handle, OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &cluster_handle) != CS_OK)
- goto fail;
-
- if (dump_objdb_buff(handle, cluster_handle, cluster_handle, &buffer, &size))
- goto fail;
-
- doc = xmlParseMemory(buffer, strlen(buffer));
- if (!doc)
- goto fail;
-
- free(buffer);
-
- ctx = xmlXPathNewContext(doc);
- if (!ctx) {
- xmlFreeDoc(doc);
- goto fail;
- }
-
- return 0;
-
-fail:
- if (buffer)
- free(buffer);
-
- return -1;
-}
-
-void xpathfull_finish()
-{
- if (ctx) {
- xmlXPathFreeContext(ctx);
- ctx = NULL;
- }
- if (doc) {
- xmlFreeDoc(doc);
- doc = NULL;
- }
- return;
-}
-
-/**
- * _ccs_get_fullxpath
- * @desc:
- * @query:
- * @rtn: value returned
- * @list: 1 to operate in list fashion
- *
- * This function will allocate space for the value that is the result
- * of the given query. It is the user's responsibility to ensure that
- * the data returned is freed.
- *
- * Returns: char * to result or NULL in case of failure.
- */
-char *_ccs_get_fullxpath(confdb_handle_t handle, hdb_handle_t connection_handle,
- const char *query, int list)
-{
- xmlXPathObjectPtr obj = NULL;
- char previous_query[PATH_MAX];
- hdb_handle_t list_handle = 0;
- unsigned int xmllistindex = 0;
- int prev = 0;
- char *rtn = NULL;
- int myerrno;
-
- if (strncmp(query, "/", 1)) {
- errno = EINVAL;
- goto fail;
- }
-
- memset(previous_query, 0, PATH_MAX);
-
- prev =
- get_previous_query(handle, connection_handle, previous_query,
- &list_handle);
-
- if (list && !prev && !strcmp(query, previous_query)) {
- if (confdb_key_increment
- (handle, connection_handle, "iterator_tracker",
- strlen("iterator_tracker"), &xmllistindex) != CS_OK) {
- xmllistindex = 0;
- } else {
- xmllistindex--;
- }
- } else {
- reset_iterator(handle, connection_handle);
- xmllistindex = 0;
- }
-
- obj = xmlXPathEvalExpression((xmlChar *) query, ctx);
-
- if (!obj) {
- errno = EINVAL;
- goto fail;
- }
-
- if (obj->nodesetval && (obj->nodesetval->nodeNr > 0)) {
- xmlNodePtr node;
- int size = 0, nnv = 0;
-
- if (xmllistindex >= obj->nodesetval->nodeNr) {
- reset_iterator(handle, connection_handle);
- errno = ENODATA;
- goto fail;
- }
-
- node = obj->nodesetval->nodeTab[xmllistindex];
-
- if (!node) {
- errno = ENODATA;
- goto fail;
- }
-
- if (((node->type == XML_ATTRIBUTE_NODE) && strstr(query, "@*"))
- || ((node->type == XML_ELEMENT_NODE)
- && strstr(query, "child::*"))) {
- if (node->children && node->children->content)
- size = strlen((char *)node->children->content) +
- strlen((char *)node->name) + 2;
- else
- size = strlen((char *)node->name) + 2;
-
- nnv = 1;
- } else {
- if (node->children && node->children->content)
- size =
- strlen((char *)node->children->content) + 1;
-
- else {
- errno = ENODATA;
- goto fail;
- }
- }
-
- if (list)
- if (set_previous_query(handle, connection_handle,
- (char *)query, OBJECT_PARENT_HANDLE))
- goto fail;
-
- rtn = malloc(size);
-
- if (!rtn) {
- errno = ENOMEM;
- goto fail;
- }
-
- if (nnv)
- sprintf(rtn, "%s=%s", node->name,
- node->children ? (char *)node->children->
- content : "");
- else
- sprintf(rtn, "%s",
- node->children ? node->children->
- content : node->name);
-
- } else
- errno = EINVAL;
-
-fail:
- myerrno = errno;
- if (obj)
- xmlXPathFreeObject(obj);
-
- errno = myerrno;
- return rtn;
-}
diff --git a/config/libs/libccsconfdb/libccs.c b/config/libs/libccsconfdb/libccs.c
deleted file mode 100644
index bfc2d29..0000000
--- a/config/libs/libccsconfdb/libccs.c
+++ /dev/null
@@ -1,660 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <corosync/corotypes.h>
-#include <corosync/confdb.h>
-
-#include "ccs.h"
-#include "ccs_internal.h"
-
-/* Callbacks are not supported - we will use them to update fullxml doc/ctx */
-static confdb_callbacks_t callbacks = {
-};
-
-/* helper functions */
-
-static confdb_handle_t confdb_connect(void)
-{
- confdb_handle_t handle = 0;
-
- if (confdb_initialize(&handle, &callbacks) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
-
- return handle;
-}
-
-static int confdb_disconnect(confdb_handle_t handle)
-{
- if (confdb_finalize(handle) != CS_OK) {
- errno = EINVAL;
- return -1;
- }
- return 0;
-}
-
-static hdb_handle_t find_libccs_handle(confdb_handle_t handle)
-{
- hdb_handle_t libccs_handle = 0;
-
- if (confdb_object_find_start(handle, OBJECT_PARENT_HANDLE) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
-
- if (confdb_object_find
- (handle, OBJECT_PARENT_HANDLE, "libccs", strlen("libccs"),
- &libccs_handle) != CS_OK) {
- errno = ENOENT;
- return -1;
- }
-
- confdb_object_find_destroy(handle, OBJECT_PARENT_HANDLE);
-
- return libccs_handle;
-}
-
-static hdb_handle_t find_ccs_handle(confdb_handle_t handle, int ccs_handle)
-{
- int res, found = 0;
- hdb_handle_t libccs_handle = 0, connection_handle = 0;
- char data[128];
- size_t datalen = 0;
-
- libccs_handle = find_libccs_handle(handle);
- if (libccs_handle == -1)
- return -1;
-
- if (confdb_object_find_start(handle, libccs_handle) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
-
- while (confdb_object_find
- (handle, libccs_handle, "connection", strlen("connection"),
- &connection_handle) == CS_OK) {
- memset(data, 0, sizeof(data));
- if (confdb_key_get
- (handle, connection_handle, "ccs_handle",
- strlen("ccs_handle"), data, &datalen) == CS_OK) {
- res = atoi(data);
- if (res == ccs_handle) {
- found = 1;
- break;
- }
- }
- }
-
- confdb_object_find_destroy(handle, libccs_handle);
-
- if (found) {
- return connection_handle;
- } else {
- errno = ENOENT;
- return -1;
- }
-}
-
-static int destroy_ccs_handle(confdb_handle_t handle,
- hdb_handle_t connection_handle)
-{
- if (confdb_object_destroy(handle, connection_handle) != CS_OK) {
- errno = EINVAL;
- return -1;
- }
-
- return 0;
-}
-
-static int get_running_config_version(confdb_handle_t handle, int *config_version)
-{
- hdb_handle_t cluster_handle;
- char data[128];
- size_t datalen = 0;
- int ret = -1;
-
- if (confdb_object_find_start(handle, OBJECT_PARENT_HANDLE) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
-
- if (confdb_object_find
- (handle, OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"),
- &cluster_handle) == CS_OK) {
- memset(data, 0, sizeof(data));
- if (confdb_key_get
- (handle, cluster_handle, "config_version",
- strlen("config_version"), data, &datalen) == CS_OK) {
- *config_version = atoi(data);
- ret = 0;
- }
- }
-
- confdb_object_find_destroy(handle, OBJECT_PARENT_HANDLE);
-
- if (ret < 0)
- errno = ENODATA;
-
- return ret;
-}
-
-static int get_stored_config_version(confdb_handle_t handle,
- hdb_handle_t connection_handle, int *config_version)
-{
- char data[128];
- size_t datalen = 0;
- int ret = -1;
-
- if (confdb_key_get
- (handle, connection_handle, "config_version",
- strlen("config_version"), data, &datalen) == CS_OK) {
- *config_version = atoi(data);
- ret = 0;
- }
-
- if (ret < 0)
- errno = ENODATA;
-
- return ret;
-}
-
-static int set_stored_config_version(confdb_handle_t handle,
- hdb_handle_t connection_handle, int new_version)
-{
- char temp[PATH_MAX];
- size_t templen = 0;
- char data[128];
-
- memset(data, 0, sizeof(data));
- snprintf(data, sizeof(data), "%d", new_version);
-
- if (confdb_key_get
- (handle, connection_handle, "config_version",
- strlen("config_version"), temp, &templen) == CS_OK) {
- if (confdb_key_replace
- (handle, connection_handle, "config_version",
- strlen("config_version"), temp, templen, data,
- strlen(data) + 1) == CS_OK) {
- return 0;
- }
- }
-
- return -1;
-}
-
-static int config_reload(confdb_handle_t handle,
- hdb_handle_t connection_handle, int fullxpathint)
-{
- int running_version;
- int stored_version;
-
- if (get_running_config_version(handle, &running_version) < 0)
- return -1;
-
- if (get_stored_config_version(handle, connection_handle, &stored_version) < 0)
- return -1;
-
- if (running_version == stored_version)
- return 0;
-
- if (fullxpathint) {
- xpathfull_finish();
- if (xpathfull_init(handle))
- return -1;
- }
-
- reset_iterator(handle, connection_handle);
-
- if (set_previous_query(handle, connection_handle, "", 0))
- return -1;
-
- if (set_stored_config_version(handle, connection_handle, running_version))
- return -1;
-
- return 0;
-}
-
-static hdb_handle_t create_ccs_handle(confdb_handle_t handle, int ccs_handle,
- int xpath)
-{
- hdb_handle_t libccs_handle = 0, connection_handle = 0;
- char buf[128];
- int config_version = 0;
-
- libccs_handle = find_libccs_handle(handle);
- if (libccs_handle == -1)
- return -1;
-
- if (get_running_config_version(handle, &config_version) < 0)
- return -1;
-
- if (confdb_object_create
- (handle, libccs_handle, "connection", strlen("connection"),
- &connection_handle) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf), "%d", ccs_handle);
- if (confdb_key_create_typed
- (handle, connection_handle, "ccs_handle", buf,
- strlen(buf) + 1, CONFDB_VALUETYPE_STRING) != CS_OK) {
- destroy_ccs_handle(handle, connection_handle);
- errno = ENOMEM;
- return -1;
- }
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf), "%d", config_version);
- if (confdb_key_create_typed
- (handle, connection_handle, "config_version",
- buf, strlen(buf) + 1, CONFDB_VALUETYPE_STRING) != CS_OK) {
- destroy_ccs_handle(handle, connection_handle);
- errno = ENOMEM;
- return -1;
- }
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf), "%d", xpath);
- if (confdb_key_create_typed
- (handle, connection_handle, "fullxpath", buf,
- strlen(buf) + 1, CONFDB_VALUETYPE_STRING) != CS_OK) {
- destroy_ccs_handle(handle, connection_handle);
- errno = ENOMEM;
- return -1;
- }
-
- return connection_handle;
-}
-
-static hdb_handle_t get_ccs_handle(confdb_handle_t handle, int *ccs_handle,
- int xpath)
-{
- unsigned int next_handle;
- hdb_handle_t libccs_handle = 0;
- hdb_handle_t ret = 0;
-
- libccs_handle = find_libccs_handle(handle);
- if (libccs_handle == -1)
- return -1;
-
- if (confdb_key_increment
- (handle, libccs_handle, "next_handle", strlen("next_handle"),
- &next_handle) == CS_OK) {
- ret = create_ccs_handle(handle, (int)next_handle, xpath);
- if (ret == -1) {
- *ccs_handle = -1;
- return ret;
- }
-
- *ccs_handle = (int)next_handle;
- return ret;
- }
-
- *ccs_handle = -1;
- errno = ENOMEM;
- return -1;
-}
-
-int get_previous_query(confdb_handle_t handle, hdb_handle_t connection_handle,
- char *previous_query, hdb_handle_t *query_handle)
-{
- size_t datalen = 0;
-
- if (confdb_key_get
- (handle, connection_handle, "previous_query",
- strlen("previous_query"), previous_query, &datalen) == CS_OK) {
- if (confdb_key_get
- (handle, connection_handle, "query_handle",
- strlen("query_handle"), query_handle,
- &datalen) == CS_OK) {
- return 0;
- }
- }
- errno = ENOENT;
- return -1;
-}
-
-int set_previous_query(confdb_handle_t handle, hdb_handle_t connection_handle,
- const char *previous_query, hdb_handle_t query_handle)
-{
- char temp[PATH_MAX];
- size_t templen = 0;
- hdb_handle_t temphandle;
- unsigned int temptracker;
-
- if (confdb_key_get
- (handle, connection_handle, "previous_query",
- strlen("previous_query"), temp, &templen) == CS_OK) {
- if (strcmp(previous_query, temp)) {
- if (confdb_key_replace
- (handle, connection_handle, "previous_query",
- strlen("previous_query"), temp, templen,
- previous_query,
- strlen(previous_query) + 1) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
- }
- } else {
- if (confdb_key_create_typed
- (handle, connection_handle, "previous_query",
- previous_query,
- strlen(previous_query) + 1, CONFDB_VALUETYPE_STRING) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
- }
-
- if (confdb_key_get
- (handle, connection_handle, "query_handle", strlen("query_handle"),
- &temphandle, &templen) == CS_OK) {
- if (temphandle != query_handle) {
- if (confdb_key_replace
- (handle, connection_handle, "query_handle",
- strlen("query_handle"), &temphandle,
- sizeof(hdb_handle_t), &query_handle,
- sizeof(hdb_handle_t)) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
- }
- } else {
- if (confdb_key_create_typed
- (handle, connection_handle, "query_handle",
- &query_handle,
- sizeof(hdb_handle_t), CONFDB_VALUETYPE_UINT64) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
- }
-
- if (confdb_key_get
- (handle, connection_handle, "iterator_tracker",
- strlen("iterator_tracker"), &temptracker, &templen) != CS_OK) {
- temptracker = 1;
- if (confdb_key_create_typed
- (handle, connection_handle, "iterator_tracker",
- &temptracker, sizeof(unsigned int), CONFDB_VALUETYPE_UINT32) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
- }
-
- return 0;
-}
-
-void reset_iterator(confdb_handle_t handle, hdb_handle_t connection_handle)
-{
- unsigned int value = 0;
-
- if (confdb_key_increment
- (handle, connection_handle, "iterator_tracker",
- strlen("iterator_tracker"), &value) != CS_OK)
- return;
-
- confdb_key_delete(handle, connection_handle, "iterator_tracker",
- strlen("iterator_tracker"), &value,
- sizeof(unsigned int));
-
- return;
-}
-
-static int check_cluster_name(int ccs_handle, const char *cluster_name)
-{
- confdb_handle_t handle = 0;
- hdb_handle_t cluster_handle;
- char data[128];
- int found = 0;
- size_t datalen = 0;
-
- handle = confdb_connect();
- if (handle == -1)
- return -1;
-
- if (confdb_object_find_start(handle, OBJECT_PARENT_HANDLE) != CS_OK) {
- errno = ENOMEM;
- return -1;
- }
-
- while (confdb_object_find
- (handle, OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"),
- &cluster_handle) == CS_OK) {
- memset(data, 0, sizeof(data));
- if (confdb_key_get
- (handle, cluster_handle, "name", strlen("name"), data,
- &datalen) == CS_OK) {
- if (!strncmp(data, cluster_name, datalen)) {
- found = 1;
- break;
- }
- }
- }
-
- confdb_object_find_destroy(handle, OBJECT_PARENT_HANDLE);
-
- confdb_disconnect(handle);
-
- if (found) {
- return ccs_handle;
- } else {
- errno = ENOENT;
- return -1;
- }
-}
-
-/**
- * _ccs_get
- * @desc:
- * @query:
- * @rtn: value returned
- * @list: 1 to operate in list fashion
- *
- * This function will allocate space for the value that is the result
- * of the given query. It is the user's responsibility to ensure that
- * the data returned is freed.
- *
- * Returns: 0 on success, < 0 on failure
- */
-static int _ccs_get(int desc, const char *query, char **rtn, int list)
-{
- confdb_handle_t handle = 0;
- hdb_handle_t connection_handle = 0;
- char data[128];
- size_t datalen = 0;
- int fullxpathint = 0;
- int myerrno;
-
- *rtn = NULL;
-
- handle = confdb_connect();
- if (handle == -1)
- return -1;
-
- connection_handle = find_ccs_handle(handle, desc);
- if (connection_handle == -1)
- goto fail;
-
- memset(data, 0, sizeof(data));
- if (confdb_key_get
- (handle, connection_handle, "fullxpath", strlen("fullxpath"), &data,
- &datalen) != CS_OK) {
- errno = EINVAL;
- goto fail;
- } else
- fullxpathint = atoi(data);
-
- if (config_reload(handle, connection_handle, fullxpathint) < 0)
- goto fail;
-
- if (!fullxpathint)
- *rtn =
- _ccs_get_xpathlite(handle, connection_handle, query, list);
- else
- *rtn =
- _ccs_get_fullxpath(handle, connection_handle, query, list);
-
-fail:
- myerrno = errno;
-
- confdb_disconnect(handle);
-
- errno = myerrno;
- if (!*rtn)
- return -1;
-
- return 0;
-}
-
-/**** PUBLIC API ****/
-
-/**
- * ccs_connect
- *
- * Returns: ccs_desc on success, < 0 on failure
- */
-int ccs_connect(void)
-{
- confdb_handle_t handle = 0;
- int ccs_handle = 0;
- int myerrno;
-
- handle = confdb_connect();
- if (handle == -1)
- return handle;
-
- get_ccs_handle(handle, &ccs_handle, fullxpath);
- if (ccs_handle < 0)
- goto fail;
-
- if (fullxpath) {
- if (xpathfull_init(handle)) {
- ccs_disconnect(ccs_handle);
- return -1;
- }
- }
-
-fail:
- myerrno = errno;
-
- confdb_disconnect(handle);
-
- errno = myerrno;
-
- return ccs_handle;
-}
-
-/**
- * ccs_force_connect
- *
- * @cluster_name: verify that we are trying to connect to the requested cluster (tbd)
- * @blocking: retry connection forever
- *
- * Returns: ccs_desc on success, < 0 on failure
- */
-int ccs_force_connect(const char *cluster_name, int blocking)
-{
- int res = -1;
-
- if (blocking) {
- while (res < 0) {
- res = ccs_connect();
- if (res < 0)
- sleep(1);
- }
- } else {
- res = ccs_connect();
- if (res < 0)
- return res;
- }
- if (cluster_name)
- return check_cluster_name(res, cluster_name);
- else
- return res;
-}
-
-/**
- * ccs_disconnect
- *
- * @desc: the descriptor returned by ccs_connect
- *
- * Returns: 0 on success, < 0 on error
- */
-int ccs_disconnect(int desc)
-{
- confdb_handle_t handle = 0;
- hdb_handle_t connection_handle = 0;
- int ret;
- char data[128];
- size_t datalen = 0;
- int fullxpathint = 0;
- int myerrno;
-
- handle = confdb_connect();
- if (handle == -1)
- return handle;
-
- connection_handle = find_ccs_handle(handle, desc);
- if (connection_handle == -1) {
- ret = -1;
- goto fail;
- }
-
- memset(data, 0, sizeof(data));
- if (confdb_key_get
- (handle, connection_handle, "fullxpath", strlen("fullxpath"), &data,
- &datalen) != CS_OK) {
- errno = EINVAL;
- ret = -1;
- goto fail;
- } else
- fullxpathint = atoi(data);
-
- if (fullxpathint)
- xpathfull_finish();
-
- ret = destroy_ccs_handle(handle, connection_handle);
-
-fail:
- myerrno = errno;
- confdb_disconnect(handle);
- errno = myerrno;
- return ret;
-}
-
-/* see _ccs_get */
-int ccs_get(int desc, const char *query, char **rtn)
-{
- return _ccs_get(desc, query, rtn, 0);
-}
-
-/* see _ccs_get */
-int ccs_get_list(int desc, const char *query, char **rtn)
-{
- return _ccs_get(desc, query, rtn, 1);
-}
-
-/**
- * ccs_set: set an individual element's value in the config file.
- * @desc:
- * @path:
- * @val:
- *
- * This function is used to update individual elements in a config file.
- * It's effects are cluster wide. It only succeeds when the node is part
- * of a quorate cluster.
- *
- * Note currently implemented.
- *
- * Returns: 0 on success, < 0 on failure
- */
-int ccs_set(int desc, const char *path, char *val)
-{
- errno = ENOSYS;
- return -1;
-}
diff --git a/config/libs/libccsconfdb/libccs.pc.in b/config/libs/libccsconfdb/libccs.pc.in
deleted file mode 100644
index eddc87f..0000000
--- a/config/libs/libccsconfdb/libccs.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@PREFIX@
-exec_prefix=${prefix}
-libdir=@LIBDIR@
-includedir=@INCDIR@
-
-Name: libccs
-Version: @VERSION@
-Description: Cluster Config library
-Requires:
-Libs: -L${libdir} -lccs
-Cflags: -I${includedir}
diff --git a/config/libs/libccsconfdb/xpathlite.c b/config/libs/libccsconfdb/xpathlite.c
deleted file mode 100644
index 6ffbf63..0000000
--- a/config/libs/libccsconfdb/xpathlite.c
+++ /dev/null
@@ -1,454 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <corosync/corotypes.h>
-#include <corosync/confdb.h>
-
-#include "ccs.h"
-#include "ccs_internal.h"
-
-static int tokenizer(char *current_query)
-{
- int tokens = 0;
- char *curpos = current_query;
- char *next = NULL;
- char *end = NULL;
-
- end = current_query + strlen(current_query);
-
- while (curpos <= end) {
- tokens++;
-
- if (!curpos) {
- errno = EINVAL;
- return -1;
- }
-
- if (strncmp(curpos, "/", 1)) {
- errno = EINVAL;
- return -1;
- }
-
- memset(curpos, 0, 1);
- curpos = curpos + 1;
-
- next = strstr(curpos, "/");
- if (next == curpos) {
- errno = EINVAL;
- return -1;
- }
-
- if (!next)
- return tokens;
-
- if ((strstr(curpos, "[") > next) || !strstr(curpos, "[")) {
- curpos = next;
- } else {
- curpos = strstr(curpos, "]");
- if (!curpos) {
- errno = EINVAL;
- return -1;
- }
- curpos = strstr(curpos, "/");
- }
- }
- errno = EINVAL;
- return -1;
-}
-
-/*
- * return 0 on success
- * return -1 on errors
- */
-static int path_dive(confdb_handle_t handle, hdb_handle_t *query_handle,
- char *current_query, int tokens)
-{
- char *pos = NULL, *next = NULL;
- int i;
- hdb_handle_t new_obj_handle;
- confdb_value_types_t type;
-
- pos = current_query + 1;
-
- for (i = 1; i <= tokens; i++) {
- if (confdb_object_find_start(handle, *query_handle) !=
- CS_OK)
- goto fail;
-
- next = pos + strlen(pos) + 1;
-
- if (!strstr(pos, "[")) {
- /* straight path diving */
- if (confdb_object_find
- (handle, *query_handle, pos, strlen(pos),
- &new_obj_handle) != CS_OK)
- goto fail;
- else {
- confdb_object_find_destroy(handle,
- *query_handle);
- *query_handle = new_obj_handle;
- }
- } else {
- /*
- * /something[int]/ or /something[@foo="bar"]/
- * start and end will identify []
- * middle will point to the inside request
- */
-
- char *start = NULL, *middle = NULL, *end = NULL;
- char *key_value = NULL;
- size_t valuelen;
- char data[PATH_MAX];
- size_t datalen = 0;
-
- /*
- * those ones should be always good because
- * the tokenizer takes care of them
- */
-
- start = strstr(pos, "[");
- if (!start)
- goto fail;
-
- end = strstr(pos, "]");
- if (!end)
- goto fail;
-
- middle = start + 1;
- memset(start, 0, 1);
- memset(end, 0, 1);
-
- if (!strcmp(pos, "child::*")) {
- int val, j;
-
- val = atoi(middle);
-
- if (val < 1)
- goto fail;
-
- if (confdb_object_iter_start
- (handle, *query_handle) != CS_OK)
- goto fail;
-
- for (j = 1; j <= val; j++) {
- if (confdb_object_iter
- (handle, *query_handle,
- &new_obj_handle, data,
- &datalen) != CS_OK)
- goto fail;
- }
- confdb_object_iter_destroy(handle,
- *query_handle);
- confdb_object_find_destroy(handle,
- *query_handle);
- *query_handle = new_obj_handle;
-
- } else if (!strstr(middle, "@")) {
- /* lookup something with index num = int */
- int val, j;
-
- val = atoi(middle);
-
- if (val < 1)
- goto fail;
-
- for (j = 1; j <= val; j++) {
- if (confdb_object_find
- (handle, *query_handle, pos,
- strlen(pos),
- &new_obj_handle) != CS_OK)
- goto fail;
- }
- confdb_object_find_destroy(handle,
- *query_handle);
- *query_handle = new_obj_handle;
-
- } else {
- /* lookup something with obj foo = bar */
- char *equal = NULL, *value = NULL, *tmp = NULL;
- int goout = 0;
-
- equal = strstr(middle, "=");
- if (!equal)
- goto fail;
-
- memset(equal, 0, 1);
-
- value = strstr(equal + 1, "\"");
- if (!value)
- goto fail;
-
- value = value + 1;
-
- tmp = strstr(value, "\"");
- if (!tmp)
- goto fail;
-
- memset(tmp, 0, 1);
-
- middle = strstr(middle, "@") + 1;
- if (!middle)
- goto fail;
-
- // middle points to foo
- // value to bar
-
- memset(data, 0, PATH_MAX);
- while (!goout) {
- if (confdb_object_find
- (handle, *query_handle, pos,
- strlen(pos),
- &new_obj_handle) != CS_OK)
- goto fail;
- else {
- key_value = NULL;
- if (confdb_key_get_typed2
- (handle, new_obj_handle,
- middle,
- (void **) &key_value,
- &valuelen, &type) == CS_OK) {
- if (!strcmp
- (key_value, value))
- goout = 1;
- free(key_value);
- key_value = NULL;
- }
- }
- }
- free(key_value);
- key_value = NULL;
- confdb_object_find_destroy(handle,
- *query_handle);
- *query_handle = new_obj_handle;
- }
- }
-
- pos = next;
- }
-
- return 0;
-
-fail:
- errno = EINVAL;
- return -1;
-}
-
-static int get_data(confdb_handle_t handle, hdb_handle_t connection_handle,
- hdb_handle_t query_handle, hdb_handle_t *list_handle,
- char **rtn, char *curpos, int list, int is_oldlist)
-{
- int cmp;
- char data[PATH_MAX];
- char *resval;
- char *keyval;
- hdb_handle_t new_obj_handle;
- unsigned int value = 0;
- confdb_value_types_t type;
- size_t datalen = 0, keyvallen = PATH_MAX;
-
- memset(data, 0, PATH_MAX);
-
- // we need to handle child::*[int value] in non list mode.
- cmp = strcmp(curpos, "child::*");
- if (cmp >= 0) {
- char *start = NULL, *end = NULL;
-
- // a pure child::* request should come down as list
- if (!cmp && !list)
- goto fail;
-
- if (confdb_object_iter_start(handle, query_handle) != CS_OK)
- goto fail;
-
- if (!is_oldlist)
- *list_handle = query_handle;
-
- if (cmp) {
- start = strstr(curpos, "[");
- if (!start)
- goto fail;
-
- start = start + 1;
-
- end = strstr(start, "]");
- if (!end)
- goto fail;
-
- memset(end, 0, 1);
- value = atoi(start);
- if (value <= 0)
- goto fail;
- } else {
- if (confdb_key_increment
- (handle, connection_handle, "iterator_tracker",
- strlen("iterator_tracker"), &value) != CS_OK)
- value = 1;
- }
-
- while (value != 0) {
- memset(data, 0, PATH_MAX);
- if (confdb_object_iter
- (handle, query_handle, &new_obj_handle, data,
- &datalen) != CS_OK) {
- reset_iterator(handle, connection_handle);
- goto fail;
- }
-
- value--;
- }
-
- resval = malloc(datalen + 2);
- if (!resval)
- goto fail;
- snprintf(resval, datalen + 2, "%s=", data);
- *rtn = resval;
-
- } else if (!strncmp(curpos, "@*", strlen("@*"))) {
-
- // this query makes sense only if we are in list mode
- if (!list)
- goto fail;
-
- if (confdb_key_iter_start(handle, query_handle) != CS_OK)
- goto fail;
-
- *list_handle = query_handle;
-
- if (confdb_key_increment
- (handle, connection_handle, "iterator_tracker",
- strlen("iterator_tracker"), &value) != CS_OK)
- value = 1;
-
- while (value != 0) {
- memset(data, 0, PATH_MAX);
- keyval = NULL;
- if (confdb_key_iter_typed2
- (handle, query_handle, data, (void **)&keyval,
- &keyvallen, &type) != CS_OK) {
- reset_iterator(handle, connection_handle);
- goto fail;
- }
-
- value--;
- if (value != 0) {
- free(keyval);
- keyval = NULL;
- }
- }
- datalen = strlen(data);
- resval = malloc(datalen + keyvallen + 2);
- if (!resval)
- goto fail;
- snprintf(resval, datalen + keyvallen + 2, "%s=%s", data, keyval);
- *rtn = resval;
- free(keyval);
-
- } else { /* pure data request */
- char *query;
-
- // this query doesn't make sense in list mode
- if (list)
- goto fail;
-
- if (confdb_object_find_start(handle, query_handle) != CS_OK)
- goto fail;
-
- query = strstr(curpos, "@");
- if (!query)
- goto fail;
-
- query = query + 1;
-
- keyval = NULL;
- if (confdb_key_get_typed2
- (handle, query_handle, query, (void **)&keyval,
- &keyvallen, &type) != CS_OK)
- goto fail;
-
- *rtn = keyval;
- }
-
- return 0;
-
-fail:
- errno = EINVAL;
- return -1;
-}
-
-/**
- * _ccs_get_xpathlite
- * @handle:
- * @connection_handle:
- * @query:
- * @list: 1 to operate in list fashion
- *
- * This function will allocate space for the value that is the result
- * of the given query. It is the user's responsibility to ensure that
- * the data returned is freed.
- *
- * Returns: char * to result or NULL in case of failure.
- */
-char *_ccs_get_xpathlite(confdb_handle_t handle, hdb_handle_t connection_handle,
- const char *query, int list)
-{
- char current_query[PATH_MAX];
- char *datapos, *rtn = NULL;
- char previous_query[PATH_MAX];
- hdb_handle_t list_handle = 0;
- hdb_handle_t query_handle = 0;
- int prev = 0, is_oldlist = 0;
- int tokens, i;
-
- memset(current_query, 0, PATH_MAX);
- strncpy(current_query, query, PATH_MAX - 1);
-
- memset(previous_query, 0, PATH_MAX);
-
- datapos = current_query + 1;
-
- prev =
- get_previous_query(handle, connection_handle, previous_query,
- &list_handle);
-
- if (list && !prev && !strcmp(current_query, previous_query)) {
- query_handle = list_handle;
- is_oldlist = 1;
- } else {
- reset_iterator(handle, connection_handle);
- query_handle = OBJECT_PARENT_HANDLE;
- }
-
- if (confdb_object_find_start(handle, query_handle) != CS_OK) {
- errno = ENOENT;
- goto fail;
- }
-
- tokens = tokenizer(current_query);
- if (tokens < 1)
- goto fail;
-
- for (i = 1; i < tokens; i++)
- datapos = datapos + strlen(datapos) + 1;
-
- if (!is_oldlist)
- if (path_dive(handle, &query_handle, current_query, tokens - 1) < 0) /* path dive can mangle tokens */
- goto fail;
-
- if (get_data
- (handle, connection_handle, query_handle, &list_handle, &rtn,
- datapos, list, is_oldlist) < 0)
- goto fail;
-
- if (list)
- if (set_previous_query
- (handle, connection_handle, (char *)query, list_handle))
- goto fail;
-
- return rtn;
-
-fail:
- return NULL;
-}
diff --git a/config/man/Makefile b/config/man/Makefile
deleted file mode 100644
index 0c003af..0000000
--- a/config/man/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-MANTARGET= cluster.conf.5
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-all:
-
-clean:
diff --git a/config/man/cluster.conf.5 b/config/man/cluster.conf.5
deleted file mode 100644
index ad2cfee..0000000
--- a/config/man/cluster.conf.5
+++ /dev/null
@@ -1,237 +0,0 @@
-.TH CLUSTER.CONF 5 2010-01-12 cluster cluster
-
-.SH NAME
-cluster.conf \- configuration file for cman and related daemons
-
-.SH SYNOPSIS
-.B /etc/cluster/cluster.conf
-
-.SH DESCRIPTION
-When
-.BR cman_tool (8)
-starts the
-.BR corosync (8)
-daemon, the cluster.conf data is read into the corosync in-memory
-database (confdb). The configuration is used by corosync,
-cman and other related cluster daemons and programs. When cman
-configures corosync with cluster.conf, the
-.BR corosync.conf (5)
-file is not used.
-
-A basic cluster configuration is described below.
-Configuration options for other daemons/programs are described in
-their own man pages.
-.BR ccs_tool (8)
-can be used to do some basic cluster.conf editing.
-
-The cluster.rng schema is used to validate cluster.conf. Unrecognized
-items will produce a warning during cluster startup, and invalid xml
-structure will cause the cluster startup to fail. See
-.BR ccs_config_validate (8)
-and
-.BR ccs_config_dump (8).
-
-.SS Cluster
-The top level
-.B cluster
-section contains all other sections and has two required attributes:
-.TP 8
-.B name
-The name of the cluster can be up to 15 characters long (16 including
-terminating null). It is important that this name be unique among
-clusters on the same network.
-.TP 8
-.B config_version
-The config_version specifies the revision level of the file and should be
-increased each time the file is updated.
-.P
-.nf
-<cluster name="alpha" config_version="1">
-</cluster>
-.fi
-
-.SS Cluster Nodes
-The set of nodes that make up the cluster are defined in the
-.B clusternodes
-section which contains multiple
-.B clusternode
-sections. A clusternode has two required attributes:
-.TP 8
-.B name
-The node name should correspond to the hostname on the network interface
-to be used for cluster communication.
-.TP 8
-.B nodeid
-The node id must be greater than zero and unique.
-.P
-.nf
-<cluster name="alpha" config_version="1">
- <clusternodes>
- <clusternode name="node-01" nodeid="1">
- </clusternode>
-
- <clusternode name="node-02" nodeid="2">
- </clusternode>
-
- <clusternode name="node-03" nodeid="3">
- </clusternode>
- </clusternodes>
-</cluster>
-.fi
-
-.SS Logging
-Cluster daemons use a common
-.B logging
-section to configure their loggging behavior.
-.P
-.nf
-<cluster name="alpha" config_version="1">
- <logging/>
-</cluster>
-.fi
-.P
-
-Global settings apply to all:
-.P
-.nf
-<logging debug="on"/>
-.fi
-.P
-
-Per-daemon
-.B logging_daemon
-subsections override the global settings.
-Daemon names that can be configured include: corosync, qdiskd, groupd, fenced,
-dlm_controld, gfs_controld, rgmanager.
-.P
-.nf
-<logging>
- <logging_daemon name="qdiskd" debug="on"/>
- <logging_daemon name="fenced" debug="on"/>
-</logging>
-.fi
-.P
-
-Corosync daemon settings apply to all corosync subsystems by default, but
-subsystems can also be configured individually. These include CLM, CPG, MAIN,
-SERV, CMAN, TOTEM, QUORUM, CONFDB, CKPT, EVT.
-.P
-.nf
-<logging>
- <logging_daemon name="corosync" subsys="QUORUM" debug="on"/>
- <logging_daemon name="corosync" subsys="CONFDB" debug="on"/>
-</logging>
-.fi
-.P
-
-The attributes available at global, daemon and subsystem levels are:
-
-.TP 8
-.B to_syslog
-enable/disable messages to syslog (yes/no), default "yes"
-
-.TP 8
-.B to_logfile
-enable/disable messages to log file (yes/no), default "yes"
-
-.TP 8
-.B syslog_facility
-facility used for syslog messages, default "local4"
-
-.TP 8
-.B syslog_priority
-messages at this level and up will be sent to syslog, default "info"
-
-.TP 8
-.B logfile_priority
-messages at this level and up will be written to log file, default "info"
-
-.TP 8
-.B logfile "\ "
-the log file name, default /var/log/cluster/<daemon>.log
-
-.TP 8
-.B debug="on"
-a shortcut for logfile_priority="debug"
-
-.SH EXAMPLE
-An explicit configuration for the default settings would be:
-.P
-.nf
-<logging to_syslog="yes" to_logfile="yes" syslog_facility="local4"
- syslog_priority="info" logfile_priority="info">
- <logging_daemon name="qdiskd"
- logfile="/var/log/cluster/qdiskd.log"/>
- <logging_daemon name="fenced"
- logfile="/var/log/cluster/fenced.log"/>
- <logging_daemon name="dlm_controld"
- logfile="/var/log/cluster/dlm_controld.log"/>
- <logging_daemon name="gfs_controld"
- logfile="/var/log/cluster/gfs_controld.log"/>
- <logging_daemon name="rgmanager"
- logfile="/var/log/cluster/rgmanager.log"/>
- <logging_daemon name="corosync"
- logfile="/var/log/cluster/corosync.log"/>
-</logging>
-.fi
-.P
-
-To include debug messages (and above) from all daemons in their default
-log files, either of the following which are equivalent:
-.P
-.nf
-<logging debug="on"/>
-<logging logfile_priority="debug"/>
-.fi
-.P
-
-To exclude all log messages from syslog:
-.P
-.nf
-<logging to_syslog="no"/>
-.fi
-.P
-
-To disable logging to all log files:
-.P
-.nf
-<logging to_file="no"/>
-.fi
-.P
-
-To include debug messages (and above) from all daemons in syslog:
-.P
-.nf
-<logging syslog_priority="debug"/>
-.fi
-.P
-
-To limit syslog messages to error (and above), keeping info (and above) in
-log files (this logfile_priority setting is the default so could be omitted):
-.P
-.nf
-<logging syslog_priority="error" logfile_priority="info"/>
-.fi
-.P
-
-.SH FILES
-.TP
-.I /etc/cluster/cluster.conf
-standard location of cluster configuration file
-.TP
-.I /usr/share/cluster/cluster.rng
-standard location of cluster.conf schema
-
-.SH SEE ALSO
-.BR ccs_tool (8),
-.BR ccs_config_dump (8),
-.BR ccs_config_validate (8),
-.BR cman_tool (8),
-.BR cman (5),
-.BR qdisk (5),
-.BR fenced (8),
-.BR fence_node (8),
-.BR dlm_controld (8),
-.BR gfs_controld (8),
-.BR rgmanager (8)
-
diff --git a/config/plugins/Makefile b/config/plugins/Makefile
deleted file mode 100644
index d39b807..0000000
--- a/config/plugins/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../../make/defines.mk
-include $(OBJDIR)/make/passthrough.mk
-
-SUBDIRS = xml ldap
diff --git a/config/plugins/ldap/99cluster.ldif b/config/plugins/ldap/99cluster.ldif
deleted file mode 100644
index 5ad8f71..0000000
--- a/config/plugins/ldap/99cluster.ldif
+++ /dev/null
@@ -1,1899 +0,0 @@
-# Auto-generated @ 2010-09-02 09:59:03
-dn: cn=schema
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.1 NAME 'rhcsConfig-version'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.5 NAME 'rhcsTwo-node'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.6 NAME 'rhcsExpected-votes'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.241 NAME 'rhcsUpgrading'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.242 NAME 'rhcsDisallowed'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.16 NAME 'rhcsQuorum-dev-poll'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.17 NAME 'rhcsShutdown-timeout'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.18 NAME 'rhcsCcsd-poll'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.19 NAME 'rhcsDebug-mask'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.13 NAME 'rhcsPort'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.3 NAME 'rhcsCluster-id'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.274 NAME 'rhcsHash-cluster-id'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.45 NAME 'rhcsNodename'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.228 NAME 'rhcsBroadcast'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.86 NAME 'rhcsKeyfile'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.229 NAME 'rhcsDisable-openais'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.20 NAME 'rhcsAddr'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.81 NAME 'rhcsConsensus'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.82 NAME 'rhcsJoin'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.8 NAME 'rhcsToken'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.278 NAME 'rhcsFail-recv-const'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.83 NAME 'rhcsToken-retransmits-before-loss-const'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.84 NAME 'rhcsRrp-mode'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.85 NAME 'rhcsSecauth'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.230 NAME 'rhcsRingnumber'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.231 NAME 'rhcsBindnetaddr'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.232 NAME 'rhcsMcastaddr'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.233 NAME 'rhcsMcastport'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.112 NAME 'rhcsInterval'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.113 NAME 'rhcsTko'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.4 NAME 'rhcsVotes'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.114 NAME 'rhcsMin-score'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.39 NAME 'rhcsDevice'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.115 NAME 'rhcsLabel'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.280 NAME 'rhcsCman-label'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.116 NAME 'rhcsStatus-file'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.117 NAME 'rhcsScheduler'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.118 NAME 'rhcsReboot'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.96 NAME 'rhcsPriority'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.119 NAME 'rhcsStop-cman'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.120 NAME 'rhcsParanoid'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.121 NAME 'rhcsAllow-kill'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.122 NAME 'rhcsMax-error-cycles'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.243 NAME 'rhcsIo-timeout'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.244 NAME 'rhcsMaster-wins'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.124 NAME 'rhcsScore'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.123 NAME 'rhcsProgram'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.107 NAME 'rhcsPost-join-delay'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.108 NAME 'rhcsPost-fail-delay'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.109 NAME 'rhcsOverride-path'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.110 NAME 'rhcsOverride-time'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.111 NAME 'rhcsClean-start'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.239 NAME 'rhcsSkip-undefined'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.62 NAME 'rhcsDebug'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.70 NAME 'rhcsUse-uuid'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.64 NAME 'rhcsMulticast-address'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.43 NAME 'rhcsAuth'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.67 NAME 'rhcsHash'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.72 NAME 'rhcsUri'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.68 NAME 'rhcsKey-file'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.73 NAME 'rhcsMulticast-interface'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.23 NAME 'rhcsLog-debug'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.24 NAME 'rhcsTimewarn'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.25 NAME 'rhcsProtocol'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.26 NAME 'rhcsEnable-fencing'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.27 NAME 'rhcsEnable-quorum'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.28 NAME 'rhcsEnable-deadlk'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.29 NAME 'rhcsEnable-plock'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.30 NAME 'rhcsPlock-debug'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.31 NAME 'rhcsPlock-rate-limit'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.32 NAME 'rhcsPlock-ownership'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.33 NAME 'rhcsDrop-resources-time'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.34 NAME 'rhcsDrop-resources-count'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.35 NAME 'rhcsDrop-resources-age'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.37 NAME 'rhcsNodir'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.21 NAME 'rhcsWeight'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.36 NAME 'rhcsEnable-withdraw'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.38 NAME 'rhcsGroupd-compat'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.74 NAME 'rhcsTo-syslog'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.75 NAME 'rhcsTo-logfile'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.76 NAME 'rhcsSyslog-facility'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.77 NAME 'rhcsSyslog-priority'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.79 NAME 'rhcsLogfile-priority'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.78 NAME 'rhcsLogfile'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.80 NAME 'rhcsSubsys'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.2 NAME 'rhcsNodeid'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.22 NAME 'rhcsMcast'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.12 NAME 'rhcsIpaddr'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.40 NAME 'rhcsLogin'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.41 NAME 'rhcsPasswd'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.42 NAME 'rhcsPasswd-script'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.44 NAME 'rhcsLanplus'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.267 NAME 'rhcsKey'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.268 NAME 'rhcsDevices'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.50 NAME 'rhcsAction'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.269 NAME 'rhcsAptpl'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.47 NAME 'rhcsServers'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.48 NAME 'rhcsCserver'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.226 NAME 'rhcsPserver'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.225 NAME 'rhcsLpan'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.288 NAME 'rhcsEsh'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.219 NAME 'rhcsUser'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.286 NAME 'rhcsDelay'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.49 NAME 'rhcsRpowerpath'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.51 NAME 'rhcsOption'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.63 NAME 'rhcsIp-family'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.252 NAME 'rhcsIpport'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.66 NAME 'rhcsRetrans'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.69 NAME 'rhcsDomain'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.71 NAME 'rhcsTimeout'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.270 NAME 'rhcsSerial-device'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.271 NAME 'rhcsSerial-params'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.272 NAME 'rhcsChannel-address'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.289 NAME 'rhcsQuiet'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.59 NAME 'rhcsExec'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.60 NAME 'rhcsVmware-type'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.52 NAME 'rhcsSecure'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.55 NAME 'rhcsIdentity-file'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.61 NAME 'rhcsVmware-datacenter'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.53 NAME 'rhcsVerbose'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.245 NAME 'rhcsVersion'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.246 NAME 'rhcsHelp'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.247 NAME 'rhcsSeparator'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.281 NAME 'rhcsPower-timeout'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.282 NAME 'rhcsShell-timeout'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.283 NAME 'rhcsLogin-timeout'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.284 NAME 'rhcsPower-wait'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.285 NAME 'rhcsRetry-on'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.57 NAME 'rhcsPartition'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.58 NAME 'rhcsManaged'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.248 NAME 'rhcsHmc-version'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.249 NAME 'rhcsCmd-prompt'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.250 NAME 'rhcsInet4-only'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.251 NAME 'rhcsInet6-only'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.287 NAME 'rhcsMissing-as-off'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.253 NAME 'rhcsSnmp-version'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.254 NAME 'rhcsCommunity'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.255 NAME 'rhcsSnmp-auth-prot'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.256 NAME 'rhcsSnmp-sec-level'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.257 NAME 'rhcsSnmp-priv-prot'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.258 NAME 'rhcsSnmp-priv-passwd'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.259 NAME 'rhcsSnmp-priv-passwd-script'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.260 NAME 'rhcsUdpport'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.263 NAME 'rhcsDrac-version'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.264 NAME 'rhcsModule-name'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.54 NAME 'rhcsSwitch'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.265 NAME 'rhcsIo-fencing'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.56 NAME 'rhcsSsl'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.266 NAME 'rhcsRibcl'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.9 NAME 'rhcsAgent'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.87 NAME 'rhcsLog-level'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.88 NAME 'rhcsStatus-child-max'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.89 NAME 'rhcsStatus-poll-interval'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.90 NAME 'rhcsTransition-throttling'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.91 NAME 'rhcsCentral-processing'
- EQUALITY integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.92 NAME 'rhcsLog-facility'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.93 NAME 'rhcsOrdered'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.94 NAME 'rhcsRestricted'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.95 NAME 'rhcsNofailback'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.97 NAME 'rhcsFile'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.98 NAME 'rhcsClass'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.99 NAME 'rhcsService'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.100 NAME 'rhcsService-state'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.101 NAME 'rhcsService-owner'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.102 NAME 'rhcsNode'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.103 NAME 'rhcsNode-id'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.104 NAME 'rhcsNode-state'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.105 NAME 'rhcsNode-clean'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.106 NAME 'rhcsNode-local'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.273 NAME 'rhcsInterface'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.125 NAME 'rhcsRef'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.126 NAME 'rhcsAutostart'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.128 NAME 'rhcsExclusive'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.129 NAME 'rhcsNfslock'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.130 NAME 'rhcsNfs-client-cache'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.131 NAME 'rhcsRecovery'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.132 NAME 'rhcsDepend'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.133 NAME 'rhcsDepend-mode'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.134 NAME 'rhcsMax-restarts'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.135 NAME 'rhcsRestart-expire-time'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.136 NAME 'rhcs--independent-subtree'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.137 NAME 'rhcs--enforce-timeouts'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.275 NAME 'rhcs--max-failures'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.276 NAME 'rhcs--failure-expire-time'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.138 NAME 'rhcsAddress'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.139 NAME 'rhcsFamily'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.140 NAME 'rhcsMonitor-link'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.141 NAME 'rhcsSleeptime'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.142 NAME 'rhcsTarget'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.143 NAME 'rhcsPath'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.144 NAME 'rhcsSvcname'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.145 NAME 'rhcsFsid'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.146 NAME 'rhcsOptions'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.147 NAME 'rhcsAllow-recover'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.148 NAME 'rhcsService-name'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.149 NAME 'rhcsUse-cache'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.150 NAME 'rhcsMountpoint'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.151 NAME 'rhcsHost'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.152 NAME 'rhcsExport'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.153 NAME 'rhcsFstype'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.154 NAME 'rhcsNo-unmount'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.155 NAME 'rhcsForce-unmount'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.156 NAME 'rhcsSelf-fence'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.157 NAME 'rhcsWorkgroup'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.158 NAME 'rhcsServer-root'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.159 NAME 'rhcsConfig-file'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.160 NAME 'rhcsHttpd-options'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.161 NAME 'rhcsShutdown-wait'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.162 NAME 'rhcsUrl-list'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.163 NAME 'rhcsSlapd-options'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.164 NAME 'rhcsSmbd-options'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.165 NAME 'rhcsNmbd-options'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.166 NAME 'rhcsListen-address'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.167 NAME 'rhcsMysqld-options'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.168 NAME 'rhcsStartup-wait'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.169 NAME 'rhcsPostmaster-user'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.170 NAME 'rhcsPostmaster-options'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.171 NAME 'rhcsTomcat-user'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.172 NAME 'rhcsCatalina-options'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.173 NAME 'rhcsCatalina-base'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.174 NAME 'rhcsVg-name'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.175 NAME 'rhcsLv-name'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.177 NAME 'rhcsMigration-mapping'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.234 NAME 'rhcsUse-virsh'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.235 NAME 'rhcsXmlfile'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.184 NAME 'rhcsMigrate'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.185 NAME 'rhcsSnapshot'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.277 NAME 'rhcsStatus-program'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.236 NAME 'rhcsHypervisor'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.237 NAME 'rhcsHypervisor-uri'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.238 NAME 'rhcsMigration-uri'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.186 NAME 'rhcsInstanceName'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.187 NAME 'rhcsDIR-EXECUTABLE'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.188 NAME 'rhcsDIR-PROFILE'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.189 NAME 'rhcsSTART-PROFILE'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.190 NAME 'rhcsSTART-WAITTIME'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.191 NAME 'rhcsAUTOMATIC-RECOVER'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.192 NAME 'rhcsPRE-START-USEREXIT'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.193 NAME 'rhcsPOST-START-USEREXIT'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.194 NAME 'rhcsPRE-STOP-USEREXIT'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.195 NAME 'rhcsPOST-STOP-USEREXIT'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.196 NAME 'rhcsSID'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.197 NAME 'rhcsDBTYPE'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.198 NAME 'rhcsNETSERVICENAME'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.199 NAME 'rhcsDBJ2EE-ONLY'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.200 NAME 'rhcsJAVA-HOME'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.201 NAME 'rhcsSTRICT-MONITORING'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.202 NAME 'rhcsDIR-BOOTSTRAP'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.203 NAME 'rhcsDIR-SECSTORE'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.204 NAME 'rhcsDB-JARS'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.205 NAME 'rhcsNamed-sdb'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.206 NAME 'rhcsNamed-working-dir'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.207 NAME 'rhcsNamed-options'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.208 NAME 'rhcsSybase-home'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.209 NAME 'rhcsSybase-ase'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.210 NAME 'rhcsSybase-ocs'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.211 NAME 'rhcsServer-name'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.212 NAME 'rhcsLogin-file'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.213 NAME 'rhcsInterfaces-file'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.214 NAME 'rhcsSybase-user'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.215 NAME 'rhcsStart-timeout'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.216 NAME 'rhcsDeep-probe-timeout'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.240 NAME 'rhcsResource'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.279 NAME 'rhcsNfspath'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.227 NAME 'rhcsQuick-status'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.217 NAME 'rhcsForce-fsck'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.218 NAME 'rhcsListener-name'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.220 NAME 'rhcsHome'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.221 NAME 'rhcsType'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.222 NAME 'rhcsVhost'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.223 NAME 'rhcsDepth'
- EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
- SINGLE-VALUE
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.1 NAME 'rhcsCluster' SUP top STRUCTURAL
- MUST ( rhcsConfig-version $ name )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.3 NAME 'rhcsCman' SUP top STRUCTURAL
- MUST ( cn )
- MAY ( rhcsDisable-openais $ rhcsKeyfile $ rhcsBroadcast $ rhcsNodename $ rhcsHash-cluster-id $ rhcsCluster-id $ rhcsPort $ rhcsDebug-mask $ rhcsCcsd-poll $ rhcsShutdown-timeout $ rhcsQuorum-dev-poll $ rhcsDisallowed $ rhcsUpgrading $ rhcsExpected-votes $ rhcsTwo-node )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.8 NAME 'rhcsMulticast' SUP top STRUCTURAL
- MUST ( rhcsAddr )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.4 NAME 'rhcsTotem' SUP top STRUCTURAL
- MUST ( cn )
- MAY ( rhcsKeyfile $ rhcsSecauth $ rhcsRrp-mode $ rhcsToken-retransmits-before-loss-const $ rhcsFail-recv-const $ rhcsToken $ rhcsJoin $ rhcsConsensus )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.56 NAME 'rhcsInterface' SUP top STRUCTURAL
- MAY ( rhcsBroadcast $ rhcsMcastport $ rhcsMcastaddr $ rhcsBindnetaddr $ rhcsRingnumber )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.29 NAME 'rhcsQuorumd' SUP top STRUCTURAL
- MUST ( cn )
- MAY ( rhcsMaster-wins $ rhcsIo-timeout $ rhcsMax-error-cycles $ rhcsAllow-kill $ rhcsParanoid $ rhcsStop-cman $ rhcsPriority $ rhcsReboot $ rhcsScheduler $ rhcsStatus-file $ rhcsCman-label $ rhcsLabel $ rhcsDevice $ rhcsMin-score $ rhcsVotes $ rhcsTko $ rhcsInterval )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.30 NAME 'rhcsHeuristic' SUP top STRUCTURAL
- MUST ( rhcsProgram )
- MAY ( rhcsTko $ rhcsInterval $ rhcsScore )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.28 NAME 'rhcsFence-daemon' SUP top STRUCTURAL
- MAY ( rhcsSkip-undefined $ rhcsClean-start $ rhcsOverride-time $ rhcsOverride-path $ rhcsPost-fail-delay $ rhcsPost-join-delay )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.18 NAME 'rhcsFence-xvmd' SUP top STRUCTURAL
- MAY ( rhcsMulticast-interface $ rhcsKey-file $ rhcsUri $ rhcsHash $ rhcsAuth $ rhcsMulticast-address $ rhcsUse-uuid $ rhcsPort $ rhcsDebug )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.12 NAME 'rhcsDlm' SUP top STRUCTURAL
- MUST ( cn )
- MAY ( rhcsDrop-resources-age $ rhcsDrop-resources-count $ rhcsDrop-resources-time $ rhcsPlock-ownership $ rhcsPlock-rate-limit $ rhcsPlock-debug $ rhcsEnable-plock $ rhcsEnable-deadlk $ rhcsEnable-quorum $ rhcsEnable-fencing $ rhcsProtocol $ rhcsTimewarn $ rhcsLog-debug )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.14 NAME 'rhcsLockspace' SUP top STRUCTURAL
- MUST ( name )
- MAY ( rhcsNodir )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.15 NAME 'rhcsMaster' SUP top STRUCTURAL
- MUST ( name )
- MAY ( rhcsWeight )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.13 NAME 'rhcsGfs-controld' SUP top STRUCTURAL
- MAY ( rhcsDrop-resources-age $ rhcsDrop-resources-count $ rhcsDrop-resources-time $ rhcsPlock-ownership $ rhcsPlock-rate-limit $ rhcsPlock-debug $ rhcsEnable-plock $ rhcsEnable-withdraw )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.16 NAME 'rhcsGroup' SUP top STRUCTURAL
- MAY ( rhcsGroupd-compat )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.19 NAME 'rhcsLogging' SUP top STRUCTURAL
- MUST ( cn )
- MAY ( rhcsDebug $ rhcsLogfile $ rhcsLogfile-priority $ rhcsSyslog-priority $ rhcsSyslog-facility $ rhcsTo-logfile $ rhcsTo-syslog )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.57 NAME 'rhcsLogging-daemon' SUP top STRUCTURAL
- MUST ( name )
- MAY ( rhcsDebug $ rhcsLogfile $ rhcsLogfile-priority $ rhcsSyslog-priority $ rhcsSyslog-facility $ rhcsTo-logfile $ rhcsTo-syslog $ rhcsSubsys )
- )
-### Placeholder for rhcsClusternodes
-### This object class currently has no attributes
-#objectClasses: (
-# 1.3.6.1.4.1.2312.8.1.2.9 NAME 'rhcsClusternodes' SUP top STRUCTURAL
-# MUST ( cn )
-# )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.10 NAME 'rhcsClusternode' SUP top STRUCTURAL
- MUST ( rhcsNodeid $ name )
- MAY ( rhcsWeight $ rhcsVotes )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.11 NAME 'rhcsAltname' SUP top STRUCTURAL
- MUST ( name )
- MAY ( rhcsMcast $ rhcsPort )
- )
-### Placeholder for rhcsFencedevices
-### This object class currently has no attributes
-#objectClasses: (
-# 1.3.6.1.4.1.2312.8.1.2.17 NAME 'rhcsFencedevices' SUP top STRUCTURAL
-# MUST ( cn )
-# )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.5 NAME 'rhcsFencedevice' SUP top STRUCTURAL
- MUST ( rhcsAgent $ name )
- MAY ( rhcsRibcl $ rhcsSsl $ rhcsIo-fencing $ rhcsSwitch $ rhcsModule-name $ rhcsDrac-version $ rhcsUdpport $ rhcsSnmp-priv-passwd-script $ rhcsSnmp-priv-passwd $ rhcsSnmp-priv-prot $ rhcsSnmp-sec-level $ rhcsSnmp-auth-prot $ rhcsCommunity $ rhcsSnmp-version $ rhcsMissing-as-off $ rhcsInet6-only $ rhcsInet4-only $ rhcsCmd-prompt $ rhcsHmc-version $ rhcsManaged $ rhcsPartition $ rhcsRetry-on $ rhcsPower-wait $ rhcsLogin-timeout $ rhcsShell-timeout $ rhcsPower-timeout $ rhcsSeparator $ rhcsHelp $ rhcsVersion $ rhcsVerbose $ rhcsVmware-datacenter $ rhcsIdentity-file $ rhcsSecure $ rhcsVmware-type $ rhcsExec $ rhcsQuiet $ rhcsChannel-address $ rhcsSerial-params $ rhcsSerial-device $ rhcsTimeout $ rhcsUse-uuid $ rhcsDomain $ rhcsKey-file $ rhcsHash $ rhcsRetrans $ rhcsIpport $ rhcsMulticast-address $ rhcsIp-family $ rhcsDebug $ rhcsOption $ rhcsRpowerpath $ rhcsDelay $ rhcsUser $ rhcsEsh $ rhcsLpan $ rhcsPserver $ rhcsCserver $ rhcsServers $ rhcsAptpl $ rhcsLogfile $ rhcsActi
on $ rhcsDevices $ rhcsKey $ rhcsNodename $ rhcsLanplus $ rhcsAuth $ rhcsPasswd-script $ rhcsPasswd $ rhcsLogin $ rhcsIpaddr $ rhcsPort $ rhcsDevice )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.21 NAME 'rhcsRm' SUP top STRUCTURAL
- MUST ( cn )
- MAY ( rhcsLog-facility $ rhcsCentral-processing $ rhcsTransition-throttling $ rhcsStatus-poll-interval $ rhcsStatus-child-max $ rhcsLog-level )
- )
-### Placeholder for rhcsFailoverdomains
-### This object class currently has no attributes
-#objectClasses: (
-# 1.3.6.1.4.1.2312.8.1.2.22 NAME 'rhcsFailoverdomains' SUP top STRUCTURAL
-# MUST ( cn )
-# )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.23 NAME 'rhcsFailoverdomain' SUP top STRUCTURAL
- MUST ( name )
- MAY ( rhcsNofailback $ rhcsRestricted $ rhcsOrdered )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.24 NAME 'rhcsFailoverdomainnode' SUP top STRUCTURAL
- MUST ( name )
- MAY ( rhcsPriority )
- )
-### Placeholder for rhcsEvents
-### This object class currently has no attributes
-#objectClasses: (
-# 1.3.6.1.4.1.2312.8.1.2.25 NAME 'rhcsEvents' SUP top STRUCTURAL
-# MUST ( cn )
-# )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.26 NAME 'rhcsEvent' SUP top STRUCTURAL
- MUST ( name )
- MAY ( rhcsNode-local $ rhcsNode-clean $ rhcsNode-state $ rhcsNode-id $ rhcsNode $ rhcsService-owner $ rhcsService-state $ rhcsService $ rhcsClass $ rhcsPriority $ rhcsFile )
- )
-### Placeholder for rhcsResources
-### This object class currently has no attributes
-#objectClasses: (
-# 1.3.6.1.4.1.2312.8.1.2.27 NAME 'rhcsResources' SUP top STRUCTURAL
-# )
-### Placeholder for rhcsResource-defaults
-### This object class currently has no attributes
-#objectClasses: (
-# 1.3.6.1.4.1.2312.8.1.2.62 NAME 'rhcsResource-defaults' SUP top STRUCTURAL
-# )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.59 NAME 'rhcsClvmd' SUP top STRUCTURAL
- MAY ( rhcsInterface )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.31 NAME 'rhcsService' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsPriority $ rhcsRestart-expire-time $ rhcsMax-restarts $ rhcsDepend-mode $ rhcsDepend $ rhcsRecovery $ rhcsNfs-client-cache $ rhcsNfslock $ rhcsExclusive $ rhcsAutostart $ rhcsDomain $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.32 NAME 'rhcsIp' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsSleeptime $ rhcsNfslock $ rhcsMonitor-link $ rhcsFamily $ rhcsAddress $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.33 NAME 'rhcsNfsclient' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsUse-cache $ rhcsService-name $ rhcsAllow-recover $ rhcsOptions $ rhcsFsid $ rhcsSvcname $ rhcsPath $ rhcsTarget $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.34 NAME 'rhcsNfsexport' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsFsid $ rhcsPath $ rhcsDevice $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.35 NAME 'rhcsScript' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsFile $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.36 NAME 'rhcsNetfs' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsOptions $ rhcsForce-unmount $ rhcsNo-unmount $ rhcsFstype $ rhcsExport $ rhcsHost $ rhcsMountpoint $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.37 NAME 'rhcsClusterfs' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsNfslock $ rhcsFsid $ rhcsSelf-fence $ rhcsOptions $ rhcsForce-unmount $ rhcsFstype $ rhcsDevice $ rhcsMountpoint $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.38 NAME 'rhcsSmb' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsWorkgroup $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.39 NAME 'rhcsApache' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsShutdown-wait $ rhcsHttpd-options $ rhcsConfig-file $ rhcsServer-root $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.40 NAME 'rhcsOpenldap' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsShutdown-wait $ rhcsSlapd-options $ rhcsUrl-list $ rhcsConfig-file $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.41 NAME 'rhcsSamba' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsShutdown-wait $ rhcsNmbd-options $ rhcsSmbd-options $ rhcsConfig-file $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.42 NAME 'rhcsMysql' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsShutdown-wait $ rhcsStartup-wait $ rhcsMysqld-options $ rhcsListen-address $ rhcsConfig-file $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.43 NAME 'rhcsPostgres-8' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsShutdown-wait $ rhcsPostmaster-options $ rhcsPostmaster-user $ rhcsConfig-file $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.44 NAME 'rhcsTomcat-5' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsShutdown-wait $ rhcsCatalina-base $ rhcsCatalina-options $ rhcsTomcat-user $ rhcsConfig-file $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.61 NAME 'rhcsTomcat-6' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsShutdown-wait $ rhcsConfig-file $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.45 NAME 'rhcsLvm' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsNfslock $ rhcsSelf-fence $ rhcsLv-name $ rhcsVg-name $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.46 NAME 'rhcsVm' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsMigration-uri $ rhcsHypervisor-uri $ rhcsHypervisor $ rhcsStatus-program $ rhcsRestart-expire-time $ rhcsMax-restarts $ rhcsDepend-mode $ rhcsDepend $ rhcsSnapshot $ rhcsPath $ rhcsMigrate $ rhcsXmlfile $ rhcsUse-virsh $ rhcsMigration-mapping $ rhcsRecovery $ rhcsExclusive $ rhcsAutostart $ rhcsDomain $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.47 NAME 'rhcsSAPInstance' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsPOST-STOP-USEREXIT $ rhcsPRE-STOP-USEREXIT $ rhcsPOST-START-USEREXIT $ rhcsPRE-START-USEREXIT $ rhcsAUTOMATIC-RECOVER $ rhcsSTART-WAITTIME $ rhcsSTART-PROFILE $ rhcsDIR-PROFILE $ rhcsDIR-EXECUTABLE $ rhcsInstanceName $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.48 NAME 'rhcsSAPDatabase' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsPOST-STOP-USEREXIT $ rhcsPRE-STOP-USEREXIT $ rhcsPOST-START-USEREXIT $ rhcsPRE-START-USEREXIT $ rhcsDB-JARS $ rhcsDIR-SECSTORE $ rhcsDIR-BOOTSTRAP $ rhcsAUTOMATIC-RECOVER $ rhcsSTRICT-MONITORING $ rhcsJAVA-HOME $ rhcsDBJ2EE-ONLY $ rhcsNETSERVICENAME $ rhcsDBTYPE $ rhcsDIR-EXECUTABLE $ rhcsSID $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.49 NAME 'rhcsNamed' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsService-name $ rhcsShutdown-wait $ rhcsNamed-options $ rhcsNamed-working-dir $ rhcsNamed-sdb $ rhcsConfig-file $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.50 NAME 'rhcsASEHAagent' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsDeep-probe-timeout $ rhcsStart-timeout $ rhcsShutdown-timeout $ rhcsSybase-user $ rhcsInterfaces-file $ rhcsLogin-file $ rhcsServer-name $ rhcsSybase-ocs $ rhcsSybase-ase $ rhcsSybase-home $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.58 NAME 'rhcsDrbd' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsResource $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.60 NAME 'rhcsNfsserver' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsNfspath $ rhcsPath $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.51 NAME 'rhcsFs' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsOptions $ rhcsForce-fsck $ rhcsFsid $ rhcsNfslock $ rhcsSelf-fence $ rhcsQuick-status $ rhcsForce-unmount $ rhcsFstype $ rhcsDevice $ rhcsMountpoint $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.52 NAME 'rhcsOracledb' SUP top STRUCTURAL
- MAY ( rhcs--failure-expire-time $ rhcs--max-failures $ rhcs--enforce-timeouts $ rhcs--independent-subtree $ rhcsVhost $ rhcsType $ rhcsHome $ rhcsUser $ rhcsListener-name $ name $ rhcsRef )
- )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.53 NAME 'rhcsAction' SUP top STRUCTURAL
- MUST ( name )
- MAY ( rhcsTimeout $ rhcsInterval $ rhcsDepth )
- )
-### Placeholder for rhcsFence
-### This object class currently has no attributes
-#objectClasses: (
-# 1.3.6.1.4.1.2312.8.1.2.54 NAME 'rhcsFence' SUP top STRUCTURAL
-# MUST ( cn )
-# )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.7 NAME 'rhcsMethod' SUP top STRUCTURAL
- MUST ( name )
- )
-### Placeholder for rhcsUnfence
-### This object class currently has no attributes
-#objectClasses: (
-# 1.3.6.1.4.1.2312.8.1.2.55 NAME 'rhcsUnfence' SUP top STRUCTURAL
-# )
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.6 NAME 'rhcsDevice' SUP top STRUCTURAL
- MUST ( name )
- MAY ( rhcsRibcl $ rhcsSsl $ rhcsIo-fencing $ rhcsSwitch $ rhcsModule-name $ rhcsDrac-version $ rhcsUdpport $ rhcsSnmp-priv-passwd-script $ rhcsSnmp-priv-passwd $ rhcsSnmp-priv-prot $ rhcsSnmp-sec-level $ rhcsSnmp-auth-prot $ rhcsCommunity $ rhcsSnmp-version $ rhcsMissing-as-off $ rhcsInet6-only $ rhcsInet4-only $ rhcsCmd-prompt $ rhcsHmc-version $ rhcsManaged $ rhcsPartition $ rhcsRetry-on $ rhcsPower-wait $ rhcsLogin-timeout $ rhcsShell-timeout $ rhcsPower-timeout $ rhcsSeparator $ rhcsHelp $ rhcsVersion $ rhcsVerbose $ rhcsVmware-datacenter $ rhcsIdentity-file $ rhcsSecure $ rhcsVmware-type $ rhcsExec $ rhcsQuiet $ rhcsChannel-address $ rhcsSerial-params $ rhcsSerial-device $ rhcsTimeout $ rhcsUse-uuid $ rhcsDomain $ rhcsKey-file $ rhcsHash $ rhcsRetrans $ rhcsIpport $ rhcsMulticast-address $ rhcsIp-family $ rhcsDebug $ rhcsOption $ rhcsRpowerpath $ rhcsDelay $ rhcsUser $ rhcsEsh $ rhcsLpan $ rhcsPserver $ rhcsCserver $ rhcsServers $ rhcsAptpl $ rhcsLogfile $ rhcsActi
on $ rhcsDevices $ rhcsKey $ rhcsNodename $ rhcsLanplus $ rhcsAuth $ rhcsPasswd-script $ rhcsPasswd $ rhcsLogin $ rhcsIpaddr $ rhcsPort $ rhcsDevice )
- )
diff --git a/config/plugins/ldap/Makefile b/config/plugins/ldap/Makefile
deleted file mode 100644
index c8621ad..0000000
--- a/config/plugins/ldap/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-TARGET= config_ldap.lcrso
-
-LCRSOT=$(TARGET)
-
-DOCS = 99cluster.ldif \
- example.ldif
-
-all: ${TARGET}
-
-include ../../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -I${ldapincdir}
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${ldaplibdir} -lldap
-LDFLAGS += -L${libdir}
-
-OBJS= configldap.o
-
-${TARGET}: ${OBJS}
- $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
-
-clean: generalclean
-
--include $(OBJS:.o=.Tpo)
diff --git a/config/plugins/ldap/configldap.c b/config/plugins/ldap/configldap.c
deleted file mode 100644
index c9ba2bf..0000000
--- a/config/plugins/ldap/configldap.c
+++ /dev/null
@@ -1,295 +0,0 @@
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <arpa/inet.h>
-
-// CC: temp until I tame SASL ... is this necessary?
-#define LDAP_DEPRECATED 1
-#include <ldap.h>
-
-/* corosync headers */
-#include <corosync/lcr/lcr_comp.h>
-#include <corosync/engine/objdb.h>
-#include <corosync/engine/config.h>
-
-/* These are defaults. they can be overridden with environment variables
- * COROSYNC_LDAP_URL & COROSYNC_LDAP_BASEDN
- */
-#define DEFAULT_LDAP_URL "ldap:///"
-#define DEFAULT_LDAP_BASEDN "dc=chrissie,dc=net"
-
-static int ldap_readconfig(struct objdb_iface_ver0 *objdb, const char **error_string);
-static int ldap_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const char **error_string);
-static int init_config(struct objdb_iface_ver0 *objdb);
-static char error_reason[1024];
-static const char *ldap_url = DEFAULT_LDAP_URL;
-static const char *ldap_basedn = DEFAULT_LDAP_BASEDN;
-
-/*
- * Exports the interface for the service
- */
-
-static struct config_iface_ver0 ldapconfig_iface_ver0 = {
- .config_readconfig = ldap_readconfig,
- .config_reloadconfig = ldap_reloadconfig
-};
-
-static struct lcr_iface ifaces_ver0[2] = {
- {
- .name = "ldapconfig",
- .version = 0,
- .versions_replace = 0,
- .versions_replace_count = 0,
- .dependencies = 0,
- .dependency_count = 0,
- .constructor = NULL,
- .destructor = NULL,
- .interfaces = NULL,
- }
-};
-
-static struct lcr_comp ldap_comp_ver0 = {
- .iface_count = 1,
- .ifaces = ifaces_ver0,
-};
-
-
-
-__attribute__ ((constructor)) static void ldap_comp_register(void) {
- lcr_interfaces_set(&ifaces_ver0[0], &ldapconfig_iface_ver0);
- lcr_component_register(&ldap_comp_ver0);
-};
-
-static int ldap_readconfig(struct objdb_iface_ver0 *objdb, const char **error_string)
-{
- int ret;
-
- /* Read config tree from LDAP */
- if (!(ret = init_config(objdb)))
- snprintf(error_reason, sizeof(error_reason), "%s", "Successfully read config from LDAP\n");
-
- *error_string = error_reason;
-
- return ret;
-}
-
-static int ldap_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const char **error_string)
-{
- return ldap_readconfig(objdb, error_string);
-}
-
-/*
- * Convert hyphens to underscores in all attribute names
- */
-static void convert_underscores(char *s, int len)
-{
- int j;
-
- for (j=0; j < len; j++) {
- if (s[j] == '-')
- s[j] = '_';
- }
-}
-
-static void convert_dn_underscores(LDAPDN dn)
-{
- int i=0;
-
- while (dn[i]) {
- convert_underscores(dn[i][0][0].la_attr.bv_val, dn[i][0][0].la_attr.bv_len);
- i++;
- }
-}
-
-/*
- * Return the parent object of a DN.
- * Actually, this returns the LAST parent with that name. which should (!) be correct.
- */
-static hdb_handle_t find_parent(struct objdb_iface_ver0 *objdb, LDAPDN dn, int startdn, const char *parent)
-{
- int i=startdn;
- int gotstart=0;
- int start=0, end=startdn;
- hdb_handle_t parent_handle = OBJECT_PARENT_HANDLE;
- hdb_handle_t object_handle=0;
- hdb_handle_t find_handle;
-
- /*
- * Find the start and end positions first.
- * start is where the 'parent' entry is.
- * end is the end of the list
- */
- do {
- if (!gotstart && dn[i][0][0].la_value.bv_len == 7 &&
- !strncmp(parent, dn[i][0][0].la_value.bv_val, 7)) {
- gotstart = 1;
- start = i;
- }
- i++;
- } while (dn[i]);
- if (start <= 0)
- return parent_handle;
-
- for (i=start; i>=end; i--) {
- objdb->object_find_create(parent_handle,
- dn[i][0][0].la_value.bv_val, dn[i][0][0].la_value.bv_len,
- &find_handle);
- while (!objdb->object_find_next(find_handle, &object_handle)) {
- parent_handle = object_handle;
- }
- objdb->object_find_destroy(find_handle);
- }
- return object_handle;
-}
-
-
-
-static int read_config_for(LDAP *ld, struct objdb_iface_ver0 *objdb, hdb_handle_t parent,
- const char *object, const char *sub_dn)
-{
- char search_dn[4096];
- int rc;
- int first_entry = 1;
- char *dn;
- LDAPMessage *result, *e;
- hdb_handle_t parent_handle = OBJECT_PARENT_HANDLE;
- hdb_handle_t object_handle;
-
- snprintf(search_dn, sizeof(search_dn), "%s,%s", sub_dn, ldap_basedn);
-
- /* Search the whole tree from the base DN provided */
- rc = ldap_search_ext_s(ld, search_dn, LDAP_SCOPE_SUBTREE, "(objectClass=*)", NULL, 0,
- NULL, NULL, NULL, 0, &result);
- if (rc != LDAP_SUCCESS) {
- snprintf(error_reason, sizeof(error_reason), "ldap_search_ext_s: %s\n", ldap_err2string(rc));
- if (rc == LDAP_NO_SUCH_OBJECT)
- return 0;
- else
- return -1;
- }
- for (e = ldap_first_entry(ld, result); e != NULL;
- e = ldap_next_entry(ld, e)) {
- if ((dn = ldap_get_dn(ld, e)) != NULL) {
- char *attr;
- BerElement *attr_ber;
- LDAPDN parsed_dn;
-
- /* Make it parsable so we can discern the hierarchy */
- if (ldap_str2dn(dn, &parsed_dn, LDAP_DN_PEDANTIC)) {
- snprintf(error_reason, sizeof(error_reason), "ldap_str2dn failed: %s\n", ldap_err2string(rc));
- return -1;
- }
-
- /*
- * LDAP doesn't allow underscores in dn names so we replace hypens with
- * underscores so we can have thing like config_version, appear as
- * config-version in ldap
- */
- convert_dn_underscores(parsed_dn);
-
- /* Create a new object if the top-level is NOT name= OR we are the first "cluster" entry */
- if (strncmp(parsed_dn[0][0][0].la_attr.bv_val, "name", 4) || first_entry) {
- parent_handle = find_parent(objdb, parsed_dn, 0, object);
-
- objdb->object_create(parent_handle, &object_handle, parsed_dn[0][0][0].la_value.bv_val,
- parsed_dn[0][0][0].la_value.bv_len);
- first_entry = 0;
- }
- else {
- /* Remove redundant empty parent. */
- objdb->object_destroy(object_handle);
-
- parent_handle = find_parent(objdb, parsed_dn, 2, object);
- /* Create a new object with the same name as the current one */
- objdb->object_create(parent_handle, &object_handle, parsed_dn[1][0][0].la_value.bv_val,
- parsed_dn[1][0][0].la_value.bv_len);
- }
-
- /* Finished with the text representation */
- ldap_memfree(dn);
-
- /* Store the attributes as keys */
- attr = ldap_first_attribute(ld, e, &attr_ber);
- while (attr) {
- int i;
- struct berval **val_ber;
-
- val_ber = ldap_get_values_len(ld, e, attr);
- if (!val_ber)
- goto ldap_next;
- i=0;
- while (val_ber[i]) {
- /*
- * If the attribute starts "rhcs" then remove that bit
- * and make the first letter lower case so it matches the
- * cluster.conf entry.
- * so, after the above underscore change too:
- * eg 'rhcsConfig-version' becomes 'config_version'. magic!
- */
- if (strncmp(attr, "rhcs", 4) == 0) {
- memmove(attr, attr+4, strlen(attr+4)+1);
- attr[0] |= 0x60;
- }
- convert_underscores(attr, strlen(attr));
-
- /*
- * Add a key - but ignore "objectClass" & "cn" attributes
- * as they don't provide anything we can use
- */
- if (strcmp("objectClass", attr) &&
- strcmp("cn", attr)) {
- objdb->object_key_create_typed(object_handle, attr,
- val_ber[i]->bv_val,
- val_ber[i]->bv_len+1,
- OBJDB_VALUETYPE_STRING);
- }
- i++;
- }
- ldap_value_free_len(val_ber);
-ldap_next:
- ldap_memfree(attr);
- attr = ldap_next_attribute(ld, e, attr_ber);
- }
- ldap_memfree(attr);
- ber_free(attr_ber, 0);
- }
- }
- ldap_msgfree(result);
-
- return 0;
-}
-
-/* The real work starts here */
-static int init_config(struct objdb_iface_ver0 *objdb)
-{
- LDAP *ld;
- int version, rc;
-
- if (getenv("COROSYNC_LDAP_URL"))
- ldap_url = getenv("COROSYNC_LDAP_URL");
- if (getenv("COROSYNC_LDAP_BASEDN"))
- ldap_basedn = getenv("COROSYNC_LDAP_BASEDN");
-
- /* Connect to the LDAP server */
- if (ldap_initialize(&ld, ldap_url)) {
- snprintf(error_reason, sizeof(error_reason), "ldap_initialize failed: %s\n", strerror(errno));
- return -1;
- }
- version = LDAP_VERSION3;
- ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version);
-
- /*
- * CC: Do I need to use sasl ?!
- */
- rc = ldap_simple_bind_s(ld, getenv("COROSYNC_LDAP_BINDDN"), getenv("COROSYNC_LDAP_BINDPWD"));
- if (rc != LDAP_SUCCESS) {
- snprintf(error_reason, sizeof(error_reason), "ldap_simple_bind failed: %s\n", ldap_err2string(rc));
- return -1;
- }
-
- rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "cluster", "name=cluster");
-
- ldap_unbind(ld);
- return 0;
-}
diff --git a/config/plugins/ldap/example.ldif b/config/plugins/ldap/example.ldif
deleted file mode 100644
index 0182dcf..0000000
--- a/config/plugins/ldap/example.ldif
+++ /dev/null
@@ -1,137 +0,0 @@
-# Example cluster LDIF file
-# Christine Caulfield <ccaulfie(a)redhat.com>
-#
-# You WILL need to change this to suit your needs, in particular a search
-# and replace of dc=chrissie,dc=net with your own domanin name.
-#
-# Load with:
-# ldapmodify -x -a -D"cn=Directory Manager" -f example.ldif -c -v -W
-#
-#
-# What follows is the LDAP equivalent of the following cluster.conf file:
-#
-#<totem token="21000"/>
-#
-#<cluster config_version="1" name="cc_cluster">
-# <cman cluster_id="444"/>
-#
-# <fencedevices>
-# <fencedevice name="myapc"
-# password="apc"
-# username="apc"
-# ipaddr="myapc.chrissie.net"
-# agent="fence_apc"
-# </fencedevice>
-# </fencedevice>
-# <clusternodes>
-# <clusternode name="ford"
-# votes="1"
-# nodeid="32">
-# <fence>
-# <method name="apc">
-# <device name="myapc" port="4"/>
-# </method>
-# </fence>
-# </clusternode>
-#
-# <clusternode name="arthur"
-# votes="1"
-# nodeid="10">
-# </clusternode>
-#
-# <clusternode name="jeltz"
-# votes="2"
-# nodeid="1">
-# </clusternode>
-# </clusternodes>
-#</cluster>
-#
-#
-
-dn: cn=cluster,dc=chrissie,dc=net
-cn: cluster
-objectClass: rhcsCluster
-name: cc_cluster
-rhcsConfig-version: 1
-
-# Some cman parameters
-dn: cn=cman,cn=cluster,dc=chrissie,dc=net
-cn: cman
-objectClass: rhcsCman
-rhcsCluster-id: 444
-
-# Some totem parameters
-dn: cn=totem,cn=cluster,dc=chrissie,dc=net
-cn: totem
-objectClass: rhcsTotem
-rhcsToken: 21000
-
-# Define nodes
-dn: cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-cn: clusternodes
-objectClass: nsContainer
-
-
-dn: cn=clusternode,cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-cn: clusternode
-objectClass: nsContainer
-
-
-dn: name=jeltz,cn=clusternode,cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-objectClass: rhcsNode
-name: jeltz
-rhcsNodeid: 1
-rhcsVotes: 2
-
-# Define a fence agent for this node ...!
-dn: cn=fence,name=jeltz,cn=clusternode,cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-cn: fence
-objectclass: nsContainer
-
-dn: cn=method,cn=fence,name=jeltz,cn=clusternode,cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-cn: method
-objectclass: nsContainer
-
-dn: name=apc,cn=method,cn=fence,name=jeltz,cn=clusternode,cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-name: apc
-objectclass: rhcsFenceMethod
-
-dn: cn=device,name=apc,cn=method,cn=fence,name=jeltz,cn=clusternode,cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-cn: device
-objectclass: nsContainer
-
-dn: name=myapc,cn=device,name=apc,cn=method,cn=fence,name=jeltz,cn=clusternode,cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-name: myapc
-objectclass: rhcsFenceAgent
-rhcsPort: 4
-
-dn: name=arthur,cn=clusternode,cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-objectClass: rhcsNode
-name: arthur
-rhcsNodeid: 10
-rhcsVotes: 1
-
-dn: name=ford,cn=clusternode,cn=clusternodes,cn=cluster,dc=chrissie,dc=net
-objectClass: rhcsNode
-name: ford
-rhcsNodeid: 32
-rhcsVotes: 1
-
-# Fence agent
-
-dn: cn=fencedevices,cn=cluster,dc=chrissie,dc=net
-cn: fencedevices
-objectClass: nsContainer
-
-dn: cn=fencedevice,cn=fencedevices,cn=cluster,dc=chrissie,dc=net
-cn: fencedevice
-objectClass: nsContainer
-
-
-dn: name=myapc,cn=fencedevice,cn=fencedevices,cn=cluster,dc=chrissie,dc=net
-objectClass: rhcsFencedevice
-name: myapc
-rhcsAgent: fence_apc
-rhcsIpaddr: myapc.chrissie.net
-rhcsUsername: apc
-rhcsPassword: apc
diff --git a/config/plugins/ldap/ldap-base.csv b/config/plugins/ldap/ldap-base.csv
deleted file mode 100644
index ee8a560..0000000
--- a/config/plugins/ldap/ldap-base.csv
+++ /dev/null
@@ -1,352 +0,0 @@
-# Max attribute value: 289
-# Max object class value: 62
-obj,rhcsCluster,cluster,1
-obj,rhcsCman,cman,3
-obj,rhcsTotem,totem,4
-obj,rhcsFencedevice,fencedevice,5
-obj,rhcsDevice,device,6
-obj,rhcsMethod,method,7
-attr,rhcsConfig-version,config_version,1
-attr,rhcsNodeid,nodeid,2
-attr,rhcsCluster-id,cluster_id,3
-attr,rhcsVotes,votes,4
-attr,rhcsTwo-node,two_node,5
-attr,rhcsExpected-votes,expected_votes,6
-attr,rhcsMax-queued,max_queued,7
-attr,rhcsToken,token,8
-attr,rhcsAgent,agent,9
-attr,rhcsUsername,username,10
-attr,rhcsPassword,password,11
-attr,rhcsIpaddr,ipaddr,12
-attr,rhcsPort,port,13
-attr,name,name,14
-attr,rhcsAlias,alias,15
-attr,rhcsQuorum-dev-poll,quorum_dev_poll,16
-attr,rhcsShutdown-timeout,shutdown_timeout,17
-attr,rhcsCcsd-poll,ccsd_poll,18
-attr,rhcsDebug-mask,debug_mask,19
-obj,rhcsMulticast,multicast,8
-attr,rhcsAddr,addr,20
-obj,rhcsClusternodes,clusternodes,9
-obj,rhcsClusternode,clusternode,10
-attr,rhcsWeight,weight,21
-obj,rhcsAltname,altname,11
-attr,rhcsMcast,mcast,22
-obj,rhcsDlm,dlm,12
-attr,rhcsLog-debug,log_debug,23
-attr,rhcsTimewarn,timewarn,24
-attr,rhcsProtocol,protocol,25
-attr,rhcsEnable-fencing,enable_fencing,26
-attr,rhcsEnable-quorum,enable_quorum,27
-attr,rhcsEnable-deadlk,enable_deadlk,28
-attr,rhcsEnable-plock,enable_plock,29
-attr,rhcsPlock-debug,plock_debug,30
-attr,rhcsPlock-rate-limit,plock_rate_limit,31
-attr,rhcsPlock-ownership,plock_ownership,32
-attr,rhcsDrop-resources-time,drop_resources_time,33
-attr,rhcsDrop-resources-count,drop_resources_count,34
-attr,rhcsDrop-resources-age,drop_resources_age,35
-obj,rhcsGfs-controld,gfs_controld,13
-attr,rhcsEnable-withdraw,enable_withdraw,36
-obj,rhcsLockspace,lockspace,14
-attr,rhcsNodir,nodir,37
-obj,rhcsMaster,master,15
-obj,rhcsGroup,group,16
-attr,rhcsGroupd-compat,groupd_compat,38
-obj,rhcsFencedevices,fencedevices,17
-attr,rhcsDevice,device,39
-attr,rhcsLogin,login,40
-attr,rhcsPasswd,passwd,41
-attr,rhcsPasswd-script,passwd_script,42
-attr,rhcsAuth,auth,43
-attr,rhcsLanplus,lanplus,44
-attr,rhcsNodename,nodename,45
-attr,rhcsSelf,self,46
-attr,rhcsServers,servers,47
-attr,rhcsCserver,cserver,48
-attr,rhcsRpowerpath,rpowerpath,49
-attr,rhcsAction,action,50
-attr,rhcsOption,option,51
-attr,rhcsSecure,secure,52
-attr,rhcsVerbose,verbose,53
-attr,rhcsSwitch,switch,54
-attr,rhcsIdentity-file,identity_file,55
-attr,rhcsSsl,ssl,56
-attr,rhcsPartition,partition,57
-attr,rhcsManaged,managed,58
-attr,rhcsExec,exec,59
-attr,rhcsVmware-type,vmware_type,60
-attr,rhcsVmware-datacenter,vmware_datacenter,61
-attr,rhcsDebug,debug,62
-attr,rhcsIp-family,ip_family,63
-attr,rhcsMulticast-address,multicast_address,64
-attr,rhcsMulticast-ttl,multicast_ttl,65
-attr,rhcsRetrans,retrans,66
-attr,rhcsHash,hash,67
-attr,rhcsKey-file,key_file,68
-attr,rhcsDomain,domain,69
-attr,rhcsUse-uuid,use_uuid,70
-attr,rhcsTimeout,timeout,71
-obj,rhcsFence-xvmd,fence_xvmd,18
-attr,rhcsUri,uri,72
-attr,rhcsMulticast-interface,multicast_interface,73
-obj,rhcsLogging,logging,19
-attr,rhcsTo-syslog,to_syslog,74
-attr,rhcsTo-logfile,to_logfile,75
-attr,rhcsSyslog-facility,syslog_facility,76
-attr,rhcsSyslog-priority,syslog_priority,77
-attr,rhcsLogfile,logfile,78
-attr,rhcsLogfile-priority,logfile_priority,79
-obj,rhcsLogging-subsys,logging_subsys,20
-attr,rhcsSubsys,subsys,80
-attr,rhcsConsensus,consensus,81
-attr,rhcsJoin,join,82
-attr,rhcsToken-retransmits-before-loss-const,token_retransmits_before_loss_const,83
-attr,rhcsRrp-mode,rrp_mode,84
-attr,rhcsSecauth,secauth,85
-attr,rhcsKeyfile,keyfile,86
-obj,rhcsRm,rm,21
-attr,rhcsLog-level,log_level,87
-attr,rhcsStatus-child-max,status_child_max,88
-attr,rhcsStatus-poll-interval,status_poll_interval,89
-attr,rhcsTransition-throttling,transition_throttling,90
-attr,rhcsCentral-processing,central_processing,91
-attr,rhcsLog-facility,log_facility,92
-obj,rhcsFailoverdomains,failoverdomains,22
-obj,rhcsFailoverdomain,failoverdomain,23
-attr,rhcsOrdered,ordered,93
-attr,rhcsRestricted,restricted,94
-attr,rhcsNofailback,nofailback,95
-obj,rhcsFailoverdomainnode,failoverdomainnode,24
-attr,rhcsPriority,priority,96
-obj,rhcsEvents,events,25
-obj,rhcsEvent,event,26
-attr,rhcsFile,file,97
-attr,rhcsClass,class,98
-attr,rhcsService,service,99
-attr,rhcsService-state,service_state,100
-attr,rhcsService-owner,service_owner,101
-attr,rhcsNode,node,102
-attr,rhcsNode-id,node_id,103
-attr,rhcsNode-state,node_state,104
-attr,rhcsNode-clean,node_clean,105
-attr,rhcsNode-local,node_local,106
-obj,rhcsResources,resources,27
-obj,rhcsFence-daemon,fence_daemon,28
-attr,rhcsPost-join-delay,post_join_delay,107
-attr,rhcsPost-fail-delay,post_fail_delay,108
-attr,rhcsOverride-path,override_path,109
-attr,rhcsOverride-time,override_time,110
-attr,rhcsClean-start,clean_start,111
-obj,rhcsQuorumd,quorumd,29
-attr,rhcsInterval,interval,112
-attr,rhcsTko,tko,113
-attr,rhcsMin-score,min_score,114
-attr,rhcsLabel,label,115
-attr,rhcsStatus-file,status_file,116
-attr,rhcsScheduler,scheduler,117
-attr,rhcsReboot,reboot,118
-attr,rhcsStop-cman,stop_cman,119
-attr,rhcsParanoid,paranoid,120
-attr,rhcsAllow-kill,allow_kill,121
-attr,rhcsMax-error-cycles,max_error_cycles,122
-obj,rhcsHeuristic,heuristic,30
-attr,rhcsProgram,program,123
-attr,rhcsScore,score,124
-obj,rhcsService,service,31
-attr,rhcsRef,ref,125
-attr,rhcsAutostart,autostart,126
-attr,rhcsHardrecovery,hardrecovery,127
-attr,rhcsExclusive,exclusive,128
-attr,rhcsNfslock,nfslock,129
-attr,rhcsNfs-client-cache,nfs_client_cache,130
-attr,rhcsRecovery,recovery,131
-attr,rhcsDepend,depend,132
-attr,rhcsDepend-mode,depend_mode,133
-attr,rhcsMax-restarts,max_restarts,134
-attr,rhcsRestart-expire-time,restart_expire_time,135
-attr,rhcs--independent-subtree,__independent_subtree,136
-attr,rhcs--enforce-timeouts,__enforce_timeouts,137
-obj,rhcsIp,ip,32
-attr,rhcsAddress,address,138
-attr,rhcsFamily,family,139
-attr,rhcsMonitor-link,monitor_link,140
-attr,rhcsSleeptime,sleeptime,141
-obj,rhcsNfsclient,nfsclient,33
-attr,rhcsTarget,target,142
-attr,rhcsPath,path,143
-attr,rhcsSvcname,svcname,144
-attr,rhcsFsid,fsid,145
-attr,rhcsOptions,options,146
-attr,rhcsAllow-recover,allow_recover,147
-attr,rhcsService-name,service_name,148
-attr,rhcsUse-cache,use_cache,149
-obj,rhcsNfsexport,nfsexport,34
-obj,rhcsScript,script,35
-obj,rhcsNetfs,netfs,36
-attr,rhcsMountpoint,mountpoint,150
-attr,rhcsHost,host,151
-attr,rhcsExport,export,152
-attr,rhcsFstype,fstype,153
-attr,rhcsNo-unmount,no_unmount,154
-attr,rhcsForce-unmount,force_unmount,155
-obj,rhcsClusterfs,clusterfs,37
-attr,rhcsSelf-fence,self_fence,156
-obj,rhcsSmb,smb,38
-attr,rhcsWorkgroup,workgroup,157
-obj,rhcsApache,apache,39
-attr,rhcsServer-root,server_root,158
-attr,rhcsConfig-file,config_file,159
-attr,rhcsHttpd-options,httpd_options,160
-attr,rhcsShutdown-wait,shutdown_wait,161
-obj,rhcsOpenldap,openldap,40
-attr,rhcsUrl-list,url_list,162
-attr,rhcsSlapd-options,slapd_options,163
-obj,rhcsSamba,samba,41
-attr,rhcsSmbd-options,smbd_options,164
-attr,rhcsNmbd-options,nmbd_options,165
-obj,rhcsMysql,mysql,42
-attr,rhcsListen-address,listen_address,166
-attr,rhcsMysqld-options,mysqld_options,167
-attr,rhcsStartup-wait,startup_wait,168
-obj,rhcsPostgres-8,postgres-8,43
-attr,rhcsPostmaster-user,postmaster_user,169
-attr,rhcsPostmaster-options,postmaster_options,170
-obj,rhcsTomcat-5,tomcat-5,44
-attr,rhcsTomcat-user,tomcat_user,171
-attr,rhcsCatalina-options,catalina_options,172
-attr,rhcsCatalina-base,catalina_base,173
-obj,rhcsLvm,lvm,45
-attr,rhcsVg-name,vg_name,174
-attr,rhcsLv-name,lv_name,175
-obj,rhcsVm,vm,46
-attr,rhcsMemory,memory,176
-attr,rhcsMigration-mapping,migration_mapping,177
-attr,rhcsBootloader,bootloader,178
-attr,rhcsRootdisk-physical,rootdisk_physical,179
-attr,rhcsRootdisk-virtual,rootdisk_virtual,180
-attr,rhcsSwapdisk-physical,swapdisk_physical,181
-attr,rhcsSwapdisk-virtual,swapdisk_virtual,182
-attr,rhcsVif,vif,183
-attr,rhcsMigrate,migrate,184
-attr,rhcsSnapshot,snapshot,185
-obj,rhcsSAPInstance,SAPInstance,47
-attr,rhcsInstanceName,InstanceName,186
-attr,rhcsDIR-EXECUTABLE,DIR_EXECUTABLE,187
-attr,rhcsDIR-PROFILE,DIR_PROFILE,188
-attr,rhcsSTART-PROFILE,START_PROFILE,189
-attr,rhcsSTART-WAITTIME,START_WAITTIME,190
-attr,rhcsAUTOMATIC-RECOVER,AUTOMATIC_RECOVER,191
-attr,rhcsPRE-START-USEREXIT,PRE_START_USEREXIT,192
-attr,rhcsPOST-START-USEREXIT,POST_START_USEREXIT,193
-attr,rhcsPRE-STOP-USEREXIT,PRE_STOP_USEREXIT,194
-attr,rhcsPOST-STOP-USEREXIT,POST_STOP_USEREXIT,195
-obj,rhcsSAPDatabase,SAPDatabase,48
-attr,rhcsSID,SID,196
-attr,rhcsDBTYPE,DBTYPE,197
-attr,rhcsNETSERVICENAME,NETSERVICENAME,198
-attr,rhcsDBJ2EE-ONLY,DBJ2EE_ONLY,199
-attr,rhcsJAVA-HOME,JAVA_HOME,200
-attr,rhcsSTRICT-MONITORING,STRICT_MONITORING,201
-attr,rhcsDIR-BOOTSTRAP,DIR_BOOTSTRAP,202
-attr,rhcsDIR-SECSTORE,DIR_SECSTORE,203
-attr,rhcsDB-JARS,DB_JARS,204
-obj,rhcsNamed,named,49
-attr,rhcsNamed-sdb,named_sdb,205
-attr,rhcsNamed-working-dir,named_working_dir,206
-attr,rhcsNamed-options,named_options,207
-obj,rhcsASEHAagent,ASEHAagent,50
-attr,rhcsSybase-home,sybase_home,208
-attr,rhcsSybase-ase,sybase_ase,209
-attr,rhcsSybase-ocs,sybase_ocs,210
-attr,rhcsServer-name,server_name,211
-attr,rhcsLogin-file,login_file,212
-attr,rhcsInterfaces-file,interfaces_file,213
-attr,rhcsSybase-user,sybase_user,214
-attr,rhcsStart-timeout,start_timeout,215
-attr,rhcsDeep-probe-timeout,deep_probe_timeout,216
-obj,rhcsFs,fs,51
-attr,rhcsForce-fsck,force_fsck,217
-obj,rhcsOracledb,oracledb,52
-attr,rhcsListener-name,listener_name,218
-attr,rhcsUser,user,219
-attr,rhcsHome,home,220
-attr,rhcsType,type,221
-attr,rhcsVhost,vhost,222
-obj,rhcsAction,action,53
-attr,rhcsDepth,depth,223
-obj,rhcsFence,fence,54
-obj,rhcsUnfence,unfence,55
-attr,rhcsBlade,blade,224
-attr,rhcsLpan,lpan,225
-attr,rhcsPserver,pserver,226
-attr,rhcsQuick-status,quick_status,227
-attr,rhcsBroadcast,broadcast,228
-attr,rhcsDisable-openais,disable_openais,229
-obj,rhcsInterface,interface,56
-attr,rhcsRingnumber,ringnumber,230
-attr,rhcsBindnetaddr,bindnetaddr,231
-attr,rhcsMcastaddr,mcastaddr,232
-attr,rhcsMcastport,mcastport,233
-attr,rhcsUse-virsh,use_virsh,234
-attr,rhcsXmlfile,xmlfile,235
-attr,rhcsHypervisor,hypervisor,236
-attr,rhcsHypervisor-uri,hypervisor_uri,237
-attr,rhcsMigration-uri,migration_uri,238
-attr,rhcsSkip-undefined,skip_undefined,239
-obj,rhcsLogging-daemon,logging_daemon,57
-obj,rhcsDrbd,drbd,58
-attr,rhcsResource,resource,240
-attr,rhcsUpgrading,upgrading,241
-attr,rhcsDisallowed,disallowed,242
-attr,rhcsIo-timeout,io_timeout,243
-attr,rhcsMaster-wins,master_wins,244
-attr,rhcsVersion,version,245
-attr,rhcsHelp,help,246
-attr,rhcsSeparator,separator,247
-attr,rhcsHmc-version,hmc_version,248
-attr,rhcsCmd-prompt,cmd_prompt,249
-attr,rhcsInet4-only,inet4_only,250
-attr,rhcsInet6-only,inet6_only,251
-attr,rhcsIpport,ipport,252
-attr,rhcsSnmp-version,snmp_version,253
-attr,rhcsCommunity,community,254
-attr,rhcsSnmp-auth-prot,snmp_auth_prot,255
-attr,rhcsSnmp-sec-level,snmp_sec_level,256
-attr,rhcsSnmp-priv-prot,snmp_priv_prot,257
-attr,rhcsSnmp-priv-passwd,snmp_priv_passwd,258
-attr,rhcsSnmp-priv-passwd-script,snmp_priv_passwd_script,259
-attr,rhcsUdpport,udpport,260
-attr,rhcsCipher,cipher,261
-attr,rhcsMethod,method,262
-attr,rhcsDrac-version,drac_version,263
-attr,rhcsModule-name,module_name,264
-attr,rhcsIo-fencing,io_fencing,265
-attr,rhcsRibcl,ribcl,266
-attr,rhcsKey,key,267
-attr,rhcsDevices,devices,268
-attr,rhcsAptpl,aptpl,269
-attr,rhcsSerial-device,serial_device,270
-attr,rhcsSerial-params,serial_params,271
-attr,rhcsChannel-address,channel_address,272
-obj,rhcsClvmd,clvmd,59
-attr,rhcsInterface,interface,273
-attr,rhcsHash-cluster-id,hash_cluster_id,274
-attr,rhcs--max-failures,__max_failures,275
-attr,rhcs--failure-expire-time,__failure_expire_time,276
-attr,rhcsStatus-program,status_program,277
-attr,rhcsFail-recv-const,fail_recv_const,278
-obj,rhcsNfsserver,nfsserver,60
-attr,rhcsNfspath,nfspath,279
-attr,rhcsCman-label,cman_label,280
-obj,rhcsTomcat-6,tomcat-6,61
-attr,rhcsPower-timeout,power_timeout,281
-attr,rhcsShell-timeout,shell_timeout,282
-attr,rhcsLogin-timeout,login_timeout,283
-attr,rhcsPower-wait,power_wait,284
-attr,rhcsRetry-on,retry_on,285
-attr,rhcsDelay,delay,286
-attr,rhcsMissing-as-off,missing_as_off,287
-attr,rhcsEsh,esh,288
-attr,rhcsQuiet,quiet,289
-obj,rhcsResource-defaults,resource-defaults,62
diff --git a/config/plugins/xml/Makefile b/config/plugins/xml/Makefile
deleted file mode 100644
index 8853317..0000000
--- a/config/plugins/xml/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-TARGET= config_xml.lcrso
-
-LCRSOT=$(TARGET)
-
-all: ${TARGET}
-
-include ../../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC -D_GNU_SOURCE
-CFLAGS += `xml2-config --cflags`
-CFLAGS += -I${incdir}
-
-LDFLAGS += `xml2-config --libs`
-LDFLAGS += -L${libdir}
-
-OBJS= config.o
-
-${TARGET}: ${OBJS}
- $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
-
-clean: generalclean
-
--include $(OBJS:.o=.Tpo)
diff --git a/config/plugins/xml/config.c b/config/plugins/xml/config.c
deleted file mode 100644
index a25df09..0000000
--- a/config/plugins/xml/config.c
+++ /dev/null
@@ -1,149 +0,0 @@
-#include <string.h>
-#include <syslog.h>
-
-#include <libxml/tree.h>
-
-#include <corosync/lcr/lcr_comp.h>
-#include <corosync/engine/objdb.h>
-#include <corosync/engine/config.h>
-
-static int xml_readconfig(struct objdb_iface_ver0 *objdb, const char **error_string);
-static int xml_reloadconfig(struct objdb_iface_ver0 *objdb, int flush,
- const char **error_string);
-static int init_config(struct objdb_iface_ver0 *objdb, const char *configfile,
- const char *error_string);
-static char error_reason[1024];
-
-#define DEFAULT_CONFIG DEFAULT_CONFIG_DIR "/" DEFAULT_CONFIG_FILE
-
-/*
- * Exports the interface for the service
- */
-
-static struct config_iface_ver0 xmlconfig_iface_ver0 = {
- .config_readconfig = xml_readconfig,
- .config_reloadconfig = xml_reloadconfig
-};
-
-static struct lcr_iface ifaces_ver0[2] = {
- {
- .name = "xmlconfig",
- .version = 0,
- .versions_replace = 0,
- .versions_replace_count = 0,
- .dependencies = 0,
- .dependency_count = 0,
- .constructor = NULL,
- .destructor = NULL,
- .interfaces = NULL,
- }
-};
-
-static struct lcr_comp xml_comp_ver0 = {
- .iface_count = 1,
- .ifaces = ifaces_ver0,
-};
-
-__attribute__ ((constructor))
-static void xml_comp_register(void)
-{
- lcr_interfaces_set(&ifaces_ver0[0], &xmlconfig_iface_ver0);
- lcr_component_register(&xml_comp_ver0);
-};
-
-static void addkeys(xmlAttrPtr tmpattr_in, struct objdb_iface_ver0 *objdb,
- hdb_handle_t object_handle)
-{
- xmlAttrPtr tmpattr;
-
- for (tmpattr = tmpattr_in; tmpattr; tmpattr = tmpattr->next) {
- if (tmpattr->type == XML_ATTRIBUTE_NODE)
- objdb->object_key_create_typed(object_handle,
- (char *)tmpattr->name,
- (char *)tmpattr->children->
- content,
- strlen((char *)tmpattr->
- children->content) + 1,
- OBJDB_VALUETYPE_STRING);
- }
-}
-
-static void xml2objdb(xmlNodePtr tmpnode_in, struct objdb_iface_ver0 *objdb,
- hdb_handle_t parent)
-{
- hdb_handle_t object_handle = 0;
- xmlNodePtr tmpnode;
-
- for (tmpnode = tmpnode_in; tmpnode; tmpnode = tmpnode->next) {
- if (tmpnode->type == XML_ELEMENT_NODE) {
- objdb->object_create(parent, &object_handle,
- (char *)tmpnode->name,
- strlen((char *)tmpnode->name));
- if (tmpnode->properties)
- addkeys(tmpnode->properties, objdb,
- object_handle);
- }
- xml2objdb(tmpnode->children, objdb, object_handle);
- }
-}
-
-static int xml_reloadconfig(struct objdb_iface_ver0 *objdb, int flush,
- const char **error_string)
-{
- return xml_readconfig(objdb, error_string);
-}
-
-static int xml_readconfig(struct objdb_iface_ver0 *objdb, const char **error_string)
-{
- int ret = 0;
- const char *configfile = DEFAULT_CONFIG;
-
- /* We need to set this up to internal defaults too early */
- openlog("corosync", LOG_CONS | LOG_PID, SYSLOGFACILITY);
-
- if (getenv("COROSYNC_CLUSTER_CONFIG_FILE"))
- configfile = getenv("COROSYNC_CLUSTER_CONFIG_FILE");
-
- /* Read low-level totem/aisexec etc config from cluster.conf */
- if (!(ret = init_config(objdb, configfile, error_reason)))
- snprintf(error_reason, sizeof(error_reason),
- "Successfully read config from %s\n", configfile);
- else
- snprintf(error_reason, sizeof(error_reason),
- "Unable to read config from %s\n", configfile);
-
- *error_string = error_reason;
-
- return ret;
-}
-
-static int init_config(struct objdb_iface_ver0 *objdb, const char *configfile,
- const char *error_string)
-{
- int err = 0;
- xmlDocPtr doc = NULL;
- xmlNodePtr root_node = NULL;
-
- /* openfile */
-
- doc = xmlParseFile(configfile);
- if (!doc) {
- err = -1;
- goto fail;
- }
-
- root_node = xmlDocGetRootElement(doc);
- if (!root_node) {
- err = -1;
- goto fail;
- }
-
- /* load it in objdb */
- xml2objdb(root_node, objdb, OBJECT_PARENT_HANDLE);
-
-fail:
- if (doc)
- xmlFreeDoc(doc);
-
- return err;
-}
diff --git a/config/tools/Makefile b/config/tools/Makefile
deleted file mode 100644
index e695417..0000000
--- a/config/tools/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../../make/defines.mk
-include $(OBJDIR)/make/passthrough.mk
-
-SUBDIRS=ccs_tool ldap xml man
diff --git a/config/tools/ccs_tool/Makefile b/config/tools/ccs_tool/Makefile
deleted file mode 100644
index 223a41f..0000000
--- a/config/tools/ccs_tool/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-TARGET1 = ccs_tool
-TARGET2 = ccs_test
-
-SBINDIRT = $(TARGET1)
-SBINSYMT = $(TARGET2)
-
-include ../../../make/defines.mk
-
-all: depends ${TARGET1} ${TARGET2}
-
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-OBJS = ccs_tool.o \
- editconf.o
-
-CFLAGS += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
-CFLAGS += `xml2-config --cflags`
-CFLAGS += -I${ccsincdir}
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${ccslibdir} -lccs
-LDFLAGS += `xml2-config --libs`
-LDFLAGS += -L${libdir}
-
-${TARGET1}: ${OBJS} ${LDDEPS}
- $(CC) -o $@ $^ $(LDFLAGS)
-
-${TARGET2}: ${TARGET1}
- ln -sf ${TARGET1} ${TARGET2}
-
-depends:
- $(MAKE) -C $(OBJDIR)/config/libs/libccsconfdb all
-
-clean: generalclean
-
--include $(OBJS:.o=.Tpo)
diff --git a/config/tools/ccs_tool/ccs_tool.c b/config/tools/ccs_tool/ccs_tool.c
deleted file mode 100644
index 34c4c1e..0000000
--- a/config/tools/ccs_tool/ccs_tool.c
+++ /dev/null
@@ -1,380 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <errno.h>
-
-#include "copyright.cf"
-#include "editconf.h"
-#include "ccs.h"
-
-
-static void tool_print_usage(FILE *stream);
-
-int globalverbose=0;
-
-static void test_print_usage(FILE *stream);
-
-static int test_main(int argc, char *argv[], int old_format){
- int desc=0;
- int i=0;
- int force = 0, blocking = 0;
- char *str=NULL;
- char *cluster_name = NULL;
-
- if(argc <= 1){
- test_print_usage(stderr);
- exit(EXIT_FAILURE);
- }
-
- for(i=1; i < argc; i++){
- if(!strcmp(argv[i], "-h")){
- test_print_usage(stdout);
- exit(EXIT_SUCCESS);
- }
- if(!strcmp(argv[i], "-V")){
- printf("%s %s (built %s %s)\n", argv[0], RELEASE_VERSION, __DATE__, __TIME__);
- printf("%s\n", REDHAT_COPYRIGHT);
- exit(EXIT_SUCCESS);
- }
- }
-
- if(!strcmp(argv[1], "connect")){
- for(i=2; i < argc; i++){
- if(!strcmp(argv[i], "force")){
- printf("Force is set.\n");
- force = 1;
- } else if(!strcmp(argv[i], "block")){
- printf("Blocking is set.\n");
- blocking = 1;
- } else {
- cluster_name = argv[i];
- printf("Setting cluster name to %s\n", cluster_name);
- }
- }
- if(blocking && !force){
- fprintf(stderr, "Blocking can only be used with \"force\".\n");
- exit(EXIT_FAILURE);
- }
- if(force){
- desc = ccs_force_connect(cluster_name, blocking);
- } else {
- if(cluster_name){
- fprintf(stderr, "A cluster name can only be specified when using 'force'.\n");
- exit(EXIT_FAILURE);
- }
- desc = ccs_connect();
- }
- if(desc < 0){
- fprintf(stderr, "ccs_connect failed: %s\n", strerror(errno));
- exit(EXIT_FAILURE);
- } else {
- printf("Connect successful.\n");
- printf(" Connection descriptor = %d\n", desc);
- ccs_disconnect(desc);
- }
- }
- else if(!strcmp(argv[1], "disconnect")){
- if(argc < 3){
- fprintf(stderr, "Wrong number of arguments.\n");
- exit(EXIT_FAILURE);
- }
- desc = ccs_connect();
- if (desc < 0) {
- fprintf(stderr, "ccs_disconnect failed: unable to communicate with ccs\n");
- exit(EXIT_FAILURE);
- }
- if(ccs_disconnect(desc)){
- fprintf(stderr, "ccs_disconnect failed: %s\n", strerror(errno));
- exit(EXIT_FAILURE);
- } else {
- printf("Disconnect successful.\n");
- }
- }
- else if(!strcmp(argv[1], "get")){
- if(argc < 4){
- fprintf(stderr, "Wrong number of arguments.\n");
- exit(EXIT_FAILURE);
- }
- desc = ccs_connect();
- if((desc < 0) || ccs_get(desc, argv[3], &str)){
- fprintf(stderr, "ccs_get failed: %s\n", strerror(errno));
- exit(EXIT_FAILURE);
- } else {
- if (old_format) {
- printf("Get successful.\n");
- printf(" Value = <%s>\n", str);
- }
- else {
- printf("%s\n", str);
- }
- if(str)free(str);
- ccs_disconnect(desc);
- }
- }
- else {
- fprintf(stderr, "Unknown command: %s\n", argv[1]);
- exit(EXIT_FAILURE);
- }
-
- exit(EXIT_SUCCESS);
-}
-
-static void test_print_usage(FILE *stream)
-{
- fprintf(stream,
- "Usage:\n"
- "\n"
- "ccs_test [Options] <Command>\n"
- "\n"
- "Options:\n"
- " -h Print usage.\n"
- " -V Print version information.\n"
- "\n"
- "Commands:\n"
- " connect <force> <block> Connect to CCS and return connection descriptor.\n"
- " disconnect <desc> Disconnect from CCS.\n"
- " get <desc> <request> Get a value from CCS.\n"
- );
-}
-
-static int xpath_query(int argc, char **argv)
-{
- int handle;
- char *ret;
- int i;
-
- if (argc < 2) {
- fprintf(stderr,
- "Usage:\n"
- "\n"
- "ccs_tool query [-n] <xpath query>\n"
- "\n"
- "options\n"
- " -n disable full XPath parsing\n");
- return 1;
- }
-
- /* Tell the library we want full XPath parsing */
- fullxpath = 1;
-
- if (strcmp(argv[1], "-n") == 0) {
- argv++;
- argc--;
-
- /* Actually ... no we don't */
- fullxpath = 0;
- }
-
- handle = ccs_connect();
- if (handle < 0) {
- fprintf(stderr, "Unable to connect to ccs\n");
- exit(EXIT_FAILURE);
- }
-
- /* Process all the queries on the command-line */
- for (i=1; i<argc; i++) {
- if (!ccs_get(handle, argv[1], &ret)) {
- printf("%s\n", ret);
- free(ret);
- }
- else {
- fprintf(stderr, "Query failed: %s\n", strerror(errno));
- ccs_disconnect(handle);
- return -1;
- }
- }
- ccs_disconnect(handle);
- return 0;
-}
-
-static int tool_main(int argc, char *argv[])
-{
- optind = 1;
-
- if (argc < 2 || !strcmp(argv[optind], "-h")) {
- tool_print_usage(stdout);
- exit(EXIT_SUCCESS);
- }
- if (!strcmp(argv[optind], "-V")) {
- printf("%s %s (built %s %s)\n", argv[0], RELEASE_VERSION,
- __DATE__, __TIME__);
- printf("%s\n", REDHAT_COPYRIGHT);
- exit(EXIT_SUCCESS);
- }
-
- if(optind < argc){
- if(!strcmp(argv[optind], "-verbose")){
- optind++;
- globalverbose=1;
- }
- if(!strcmp(argv[optind], "help")){
- tool_print_usage(stdout);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "query")){
- return xpath_query(argc-1, argv+1);
- }
- else if(!strcmp(argv[optind], "addnode")){
- add_node(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "delnode")){
- del_node(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "addservice")){
- add_service(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "delservice")){
- del_node(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "addscript")){
- add_script(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "delscript")){
- del_node(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "addip")){
- add_ip(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "delip")){
- del_node(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "addfs")){
- add_fs(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "delfs")){
- del_node(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "addfdomain")){
- add_fdomain(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "delfdomain")){
- del_node(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "addfence")){
- add_fence(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "delfence")){
- del_fence(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "lsnode")){
- list_nodes(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "lsservice")){
- list_services(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "lsfence")){
- list_fences(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "lsscript")){
- list_scripts(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "lsip")){
- list_ips(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "lsfs")){
- list_fs(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "lsfdomains")){
- list_fdomains(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "create")){
- create_skeleton(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
- else if(!strcmp(argv[optind], "addnodeids")){
- add_nodeids(argc-1, argv+1);
- exit(EXIT_SUCCESS);
- }
-
- else {
- fprintf(stderr, "Unknown command, %s.\n"
- "Try 'ccs_tool help' for help.\n", argv[optind]);
- exit(EXIT_FAILURE);
- }
- } else {
- fprintf(stderr, "Too few arguments.\n"
- "Try 'ccs_tool help' for help.\n");
- exit(EXIT_FAILURE);
- }
- exit(EXIT_SUCCESS);
-}
-
-static void tool_print_usage(FILE *stream){
- fprintf(stream,
- "Usage:\n"
- " ccs_tool [options] <command>\n"
- "\n"
- "Options:\n"
- " -verbose Make some operations print more details.\n"
- " -h Print this usage and exit.\n"
- " -V Print version information and exit.\n"
- "\n"
- "Commands:\n"
- " help Print this usage and exit.\n"
- " query <xpath query> Query the cluster configuration.\n"
- " addnode <node> Add a node\n"
- " delnode <node> Delete a node\n"
- " lsnode List nodes\n"
- " addservice <name> Add a service\n"
- " delservice <name> Delete a service\n"
- " lsservice List services\n"
- " lsfence List fence devices\n"
- " addfence <fencedev> Add a new fence device\n"
- " delfence <fencedev> Delete a fence device\n"
- " addscript <name> Add a script resource\n"
- " delscript <name> Delete a script resource\n"
- " lsscript List script resources\n"
- " addip <name> Add an IP address resource\n"
- " delip <name> Delete an IP address resource\n"
- " lsip List IP address resources\n"
- " addfs <name> Add an filesystem resource\n"
- " delfs <name> Delete an filesystem resource\n"
- " lsfs List filesystem resources\n"
- " addfdomain <name> Add an failover domain\n"
- " delfdomain <name> Delete an failover domain\n"
- " lsfdomains List failover domains\n"
- " create Create a skeleton config file\n"
- " addnodeids Assign node ID numbers to all nodes\n"
- "\n");
-}
-
-
-int main(int argc, char *argv[])
-{
- char *name = strdup(argv[0]);
-
- /*
- * Don't be anal about the binary name.
- * We expect either 'ccs_tool' or 'ccs_test',
- * but interpret anything other than 'ccs_test'
- * as 'ccs_tool'.
- * That's not a bug, it's a feature.
- */
-
- if (strcmp(basename(name), "ccs_test") == 0)
- return test_main(argc, argv, 1);
- else
- return tool_main(argc, argv);
-}
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
deleted file mode 100644
index c4dcb9c..0000000
--- a/config/tools/ccs_tool/editconf.c
+++ /dev/null
@@ -1,2395 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <getopt.h>
-#include <errno.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
-#include <libxml/tree.h>
-
-#include "editconf.h"
-
-#define MAX_NODES 256
-
-const char *prog_name = "ccs_tool";
-
-#define die(fmt, args...) \
-do { \
- fprintf(stderr, "%s: ", prog_name); \
- fprintf(stderr, fmt "\n", ##args); \
- exit(EXIT_FAILURE); \
-} while (0)
-
-
-#define INT_TO_CHAR(x, str) \
- if (str && atoi((const char *)str)) \
- x = '*'; \
- else \
- x = ' ';
-
-struct option_info
-{
- const char *name;
- const char *altname;
- const char *votes;
- const char *nodeid;
- const char *mcast_addr;
- const char *ip_addr;
- const char *fence_type;
- const char *autostart;
- const char *exclusive;
- const char *recovery;
- const char *fs;
- const char *domain;
- const char *script;
- const char *mountpoint;
- const char *type;
- const char *device;
- const char *options;
- const char *configfile;
- const char *outputfile;
- const char **failover_nodes;
- int do_delete;
- int force_fsck;
- int force_unmount;
- int self_fence;
- int ordered;
- int restricted;
-};
-
-static void config_usage(int rw)
-{
- fprintf(stderr, " -c --configfile Name of configuration file (" DEFAULT_CONFIG_DIR "/" DEFAULT_CONFIG_FILE ")\n");
- if (rw)
- {
- fprintf(stderr, " -o --outputfile Name of output file (defaults to same as --configfile)\n");
- }
-}
-
-static void help_usage(void)
-{
- fprintf(stderr, " -h --help Display this help text\n");
-}
-
-static void list_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options]\n", prog_name, name);
- fprintf(stderr, " -v --verbose Print all properties of the item\n");
- config_usage(0);
- help_usage();
-
- exit(0);
-}
-
-static void create_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [-2] <clustername>\n", prog_name, name);
- fprintf(stderr, " -2 Create a 2-node cman cluster config file\n");
- fprintf(stderr, " -n <num> Create skeleton entries for <num> nodes\n");
- fprintf(stderr, " -f <device> Add a fence device to the node skeletons\n");
- config_usage(0);
- help_usage();
- fprintf(stderr, "\n"
- "Note that \"create\" on its own will not create a valid configuration file.\n"
- "Fence agents and nodes will need to be added to it before handing it over\n"
- "to cman.\n"
- "\n"
- "eg:\n"
- " ccs_tool create MyCluster\n"
- " ccs_tool addfence apc fence_apc ipaddr=apc.domain.net login=apc password=apc\n"
- " ccs_tool addnode node1 -n 1 -f apc port=1\n"
- " ccs_tool addnode node2 -n 2 -f apc port=2\n"
- " ccs_tool addnode node3 -n 3 -f apc port=3\n"
- " ccs_tool addnode node4 -n 4 -f apc port=4\n"
- "\n");
- fprintf(stderr, "If you add -n <numbner> to the command then %s will add skeleton entries for\n", name);
- fprintf(stderr, "that many nodes. This file WILL NEED EDITTING MANUALLY before it can be used\n");
- fprintf(stderr, "by cman.\n");
-
- exit(0);
-}
-
-static void addfence_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <name> <agent> [param=value]\n", prog_name, name);
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
-static void delfence_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <name>\n", prog_name, name);
- config_usage(1);
- help_usage();
- fprintf(stderr, "\n");
- fprintf(stderr, "%s will allow you to remove a fence device that is in use by nodes.\n", name);
- fprintf(stderr, "This is to allow changes to be made, but be aware that it may produce an\n");
- fprintf(stderr, "invalid configuration file if you don't add it back in again.\n");
-
- exit(0);
-}
-
-static void delnode_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <name>\n", prog_name, name);
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
-static void addscript_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <name> <path_to_script>\n",
- prog_name, name);
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
-static void addip_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <IP_address>\n",
- prog_name, name);
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
-static void addfs_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <name> <device> <mountpoint>\n",
- prog_name, name);
- fprintf(stderr, " -t --type Type of the filesystem (ext3, ext4, etc.)\n");
- fprintf(stderr, " Default type is ext3.\n");
- fprintf(stderr, " -p --options Mount options\n");
- fprintf(stderr, " -k --force_fsck Force fsck before mount\n");
- fprintf(stderr, " -u --force_unmount Call umount with force flag\n");
- fprintf(stderr, " -s --self_fence Use 'self_fence' feature\n");
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
-static void addfdomain_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <name> <node1> ... <nodeN>\n",
- prog_name, name);
- fprintf(stderr, " -p --ordered Allows you to specify a preference order\n");
- fprintf(stderr, " among the members of a failover domain\n");
- fprintf(stderr, " -r --restricted Allows you to restrict the members that can\n");
- fprintf(stderr, " run a particular cluster service.\n");
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
-static void addnodeid_usage(const char *name)
-{
- fprintf(stderr, "Add node IDs to all nodes in the config file that don't have them.\n");
- fprintf(stderr, "Nodes with IDs will not be afftected, so you can run this as many times\n");
- fprintf(stderr, "as you like without doing any harm.\n");
- fprintf(stderr, "It will optionally add a multicast address to the cluster config too.\n");
- fprintf(stderr, "\n");
- fprintf(stderr, "Usage: %s %s [options] <name>\n", prog_name, name);
- fprintf(stderr, " -n --nodeid Nodeid to start with (default 1)\n");
- fprintf(stderr, " -m --multicast Set or change the multicast address\n");
- fprintf(stderr, " -v --verbose Print nodeids that are assigned\n");
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
-static void addnode_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <nodename> [<fencearg>=<value>]...\n", prog_name, name);
- fprintf(stderr, " -n --nodeid Nodeid (required)\n");
- fprintf(stderr, " -v --votes Number of votes for this node (default 1)\n");
- fprintf(stderr, " -a --altname Alternative name/interface for multihomed hosts\n");
- fprintf(stderr, " -f --fence_type Type of fencing to use\n");
- config_usage(1);
- help_usage();
-
- fprintf(stderr, "\n");
- fprintf(stderr, "Examples:\n");
- fprintf(stderr, "\n");
- fprintf(stderr, "Add a new node to default configuration file:\n");
- fprintf(stderr, " %s %s newnode1 -n 1 -f wti ipaddr=newnode\n", prog_name, name);
- fprintf(stderr, "\n");
- fprintf(stderr, "Add a new node and dump config file to stdout rather than save it\n");
- fprintf(stderr, " %s %s newnode2 -n 2 -f apc -o- newnode.temp.net port=1\n", prog_name, name);
-
- exit(0);
-}
-
-static void addservice_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <servicename>\n", prog_name, name);
- fprintf(stderr, " -a --autostart Start the service on boot\n");
- fprintf(stderr, " -d --domain Failover domain for the service\n");
- fprintf(stderr, " -x --exclusive Do not run other services on the same server\n");
- fprintf(stderr, " -r --recovery Recovery policy\n");
- fprintf(stderr, " -f --fs Filesystem resource for the service\n");
- fprintf(stderr, " -s --script Script resource for the service\n");
- fprintf(stderr, " -i --ip IP address resource for the service\n");
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
-/* Is it really ?
- * Actually, we don't check that this is a valid multicast address(!),
- * merely that it is a valid IP[46] address.
- */
-static int valid_mcast_addr(char *mcast)
-{
- struct addrinfo *ainfo;
- struct addrinfo ahints;
- int ret;
-
- memset(&ahints, 0, sizeof(ahints));
-
- ret = getaddrinfo(mcast, NULL, &ahints, &ainfo);
- if (ret) {
- freeaddrinfo(ainfo);
- return 0;
- }
- return 1;
-}
-
-static void save_file(xmlDoc *doc, struct option_info *ninfo)
-{
- char tmpconffile[strlen(ninfo->outputfile)+5];
- char oldconffile[strlen(ninfo->outputfile)+5];
- int using_stdout = 0;
- mode_t old_mode;
- int ret;
-
- old_mode = umask(026);
-
- if (strcmp(ninfo->outputfile, "-") == 0)
- using_stdout = 1;
-
- /*
- * Save it to a temp file before moving the old one out of the way
- */
- if (!using_stdout)
- {
- snprintf(tmpconffile, sizeof(tmpconffile), "%s.tmp", ninfo->outputfile);
- snprintf(oldconffile, sizeof(oldconffile), "%s.old", ninfo->outputfile);
- }
- else
- {
- strncpy(tmpconffile, ninfo->outputfile, sizeof(tmpconffile));
- }
-
- xmlKeepBlanksDefault(0);
- ret = xmlSaveFormatFile(tmpconffile, doc, 1);
- if (ret == -1)
- die("Error writing new config file %s", ninfo->outputfile);
-
- if (!using_stdout)
- {
- if (rename(ninfo->outputfile, oldconffile) == -1 && errno != ENOENT)
- die("Can't move old config file out of the way\n");
-
- if (rename(tmpconffile, ninfo->outputfile))
- {
- perror("Error renaming new file to its real filename");
-
- /* Drat, that failed, try to put the old one back */
- if (rename(oldconffile, ninfo->outputfile))
- die("Can't move old config fileback in place - clean up after me please\n");
- }
- }
-
- /* free the document */
- xmlFreeDoc(doc);
-
- umask(old_mode);
-}
-
-static void validate_int_arg(char argopt, char *arg)
-{
- char *tmp;
- int val;
-
- val = strtol(arg, &tmp, 10);
- if (tmp == arg || tmp != arg + strlen(arg))
- die("argument to %c (%s) is not an integer", argopt, arg);
-
- if (val < 0)
- die("argument to %c cannot be negative", argopt);
-}
-
-/* Get the config_version string from the file */
-static xmlChar *find_version(xmlNode *root)
-{
- if (xmlHasProp(root, BAD_CAST "config_version"))
- {
- xmlChar *ver;
-
- ver = xmlGetProp(root, BAD_CAST "config_version");
- return ver;
- }
- return NULL;
-}
-
-/* Get the cluster name string from the file */
-static xmlChar *cluster_name(xmlNode *root)
-{
- if (xmlHasProp(root, BAD_CAST "name"))
- {
- xmlChar *ver;
-
- ver = xmlGetProp(root, BAD_CAST "name");
- return ver;
- }
- return NULL;
-}
-
-static void increment_version(xmlNode *root_element)
-{
- int ver;
- unsigned char *version_string;
- char newver[32];
-
- /* Increment version */
- version_string = find_version(root_element);
- if (!version_string)
- die("Can't find \"config_version\" in config file\n");
-
- ver = atoi((char *)version_string);
- snprintf(newver, sizeof(newver), "%d", ++ver);
- xmlSetProp(root_element, BAD_CAST "config_version", BAD_CAST newver);
-}
-
-static void _xmlSetIntProp(xmlNode *element, const char *property, const int value)
-{
- char buf[32];
- snprintf(buf, sizeof(buf), "%d", value);
- xmlSetProp(element, BAD_CAST property, BAD_CAST buf);
-}
-
-static xmlNode *findnode(xmlNode *root, const char *name)
-{
- xmlNode *cur_node;
-
- for (cur_node = root->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE && strcmp((char *)cur_node->name, name)==0)
- {
- return cur_node;
- }
- }
- return NULL;
-}
-
-/* Return the fence type name (& node) for a cluster node */
-static xmlChar *get_fence_type(xmlNode *clusternode, xmlNode **fencenode)
-{
- xmlNode *f;
-
- f = findnode(clusternode, "fence");
- if (f)
- {
- f = findnode(f, "method");
- if (f)
- {
- f = findnode(f, "device");
- *fencenode = f;
- return xmlGetProp(f, BAD_CAST "name");
- }
- }
- return NULL;
-}
-
-/* Check the fence type exists under <fencedevices> */
-static xmlNode *valid_fence_type(xmlNode *root, const char *fencetype)
-{
- xmlNode *devs;
- xmlNode *cur_node;
-
- devs = findnode(root, "fencedevices");
- if (!devs)
- return NULL;
-
- for (cur_node = devs->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE && strcmp((char *)cur_node->name, "fencedevice") == 0)
- {
- xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
- assert(name);
- if (strcmp((char *)name, fencetype) == 0)
- return cur_node;
- }
- }
- return NULL;
-}
-
-/* Check the nodeid is not already in use by another node */
-static xmlNode *get_by_nodeid(xmlNode *root, int nodeid)
-{
- xmlNode *cnodes;
- xmlNode *cur_node;
-
- cnodes = findnode(root, "clusternodes");
- if (!cnodes)
- return NULL;
-
- for (cur_node = cnodes->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE && strcmp((char *)cur_node->name, "clusternode") == 0)
- {
- xmlChar *idstring = xmlGetProp(cur_node, BAD_CAST "nodeid");
- if (idstring && atoi((char *)idstring) == nodeid)
- return cur_node;
- }
- }
- return NULL;
-}
-
-
-/* Get the multicast address node.
- */
-static xmlNode *find_multicast_addr(xmlNode *clusternodes)
-{
- xmlNode *clnode = findnode(clusternodes, "cman");
- if (clnode)
- {
- xmlNode *mcast = findnode(clnode, "multicast");
- return mcast;
- }
- return NULL;
-}
-
-static xmlNode *do_find_node(xmlNode *root, const char *nodename,
- const char *elem_name, const char *attrib_name)
-{
- xmlNode *cur_node;
-
- for (cur_node = root->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE &&
- strcmp((char *)cur_node->name, elem_name) == 0)
- {
- xmlChar *name = xmlGetProp(cur_node, BAD_CAST attrib_name);
- if (name && strcmp((char *)name, nodename) == 0)
- return cur_node;
- }
- }
- return NULL;
-}
-
-static xmlNode *do_find_resource_ref(xmlNode *root, const char *name,
- const char *res_type)
-{
- xmlNode *cur_node;
- xmlNode *res = NULL;
-
- for (cur_node = root->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE &&
- strcmp((char *)cur_node->name, "service") == 0)
- {
- res = do_find_node(cur_node, name, res_type, "ref");
- if (res)
- break;
- }
- }
-
- return res;
-}
-
-static xmlNode *find_node(xmlNode *clusternodes, const char *nodename)
-{
- return do_find_node(clusternodes, nodename, "clusternode", "name");
-}
-
-static xmlNode *find_service(xmlNode *root, const char *servicename)
-{
- return do_find_node(root, servicename, "service", "name");
-}
-
-static xmlNode *find_fs_resource(xmlNode *root, const char *name)
-{
- return do_find_node(root, name, "fs", "name");
-}
-
-static xmlNode *find_fdomain_resource(xmlNode *root, const char *name)
-{
- return do_find_node(root, name, "failoverdomain", "name");
-}
-
-static xmlNode *find_script_resource(xmlNode *root, const char *name)
-{
- return do_find_node(root, name, "script", "name");
-}
-
-static xmlNode *find_script_ref(xmlNode *root, const char *name)
-{
- return do_find_resource_ref(root, name, "script");
-}
-
-static xmlNode *find_ip_resource(xmlNode *root, const char *name)
-{
- return do_find_node(root, name, "ip", "address");
-}
-
-static xmlNode *find_ip_ref(xmlNode *root, const char *name)
-{
- return do_find_resource_ref(root, name, "ip");
-}
-
-static xmlNode *find_fs_ref(xmlNode *root, const char *name)
-{
- return do_find_resource_ref(root, name, "fs");
-}
-
-static xmlNode *find_fdomain_ref(xmlNode *root, const char *name)
-{
- xmlNode *cur_node;
-
- for (cur_node = root->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE &&
- strcmp((char *)cur_node->name, "service") == 0)
- {
- xmlChar *domain = xmlGetProp(cur_node, BAD_CAST "domain");
- if (domain && strcmp(name, (char *)domain) == 0)
- return cur_node;
- }
- }
-
- return NULL;
-}
-
-/* Print name=value pairs for a (n XML) node.
- * "ignore" is a string to ignore if present as a property (probably already printed on the main line)
- */
-static int print_properties(xmlNode *node, const char *prefix, const char *ignore, const char *ignore2)
-{
- xmlAttr *attr;
- int done_prefix = 0;
-
- for (attr = node->properties; attr; attr = attr->next)
- {
- /* Don't print "name=" */
- if (strcmp((char *)attr->name, "name") &&
- strcmp((char *)attr->name, ignore) &&
- strcmp((char *)attr->name, ignore2)
- )
- {
- if (!done_prefix)
- {
- done_prefix = 1;
- printf("%s", prefix);
- }
- printf(" %s=%s", attr->name, xmlGetProp(node, attr->name));
- }
- }
- if (done_prefix)
- printf("\n");
- return done_prefix;
-}
-
-/* Add name=value pairs from the commandline as properties to a node */
-static void add_fence_args(xmlNode *fencenode, int argc, char **argv, int optindex)
-{
- int i;
-
- for (i = optindex; i<argc; i++)
- {
- char *prop;
- char *value;
- char *equals;
-
- prop = strdup(argv[i]);
- // FIXME: handle failed strdup
- equals = strchr(prop, '=');
- if (!equals)
- die("option '%s' is not opt=value pair\n", prop);
-
- value = equals+1;
- *equals = '\0';
-
- /* "name" is used for the fence type itself, so this is just
- * to protect the user from their own stupidity
- */
- if (strcmp(prop, "name") == 0)
- die("Can't use \"name\" as a fence argument name\n");
-
- xmlSetProp(fencenode, BAD_CAST prop, BAD_CAST value);
- free(prop);
- }
-}
-
-static void add_clusternode(xmlNode *root_element, struct option_info *ninfo,
- int argc, char **argv, int optindex)
-{
- xmlNode *clusternodes;
- xmlNode *newnode;
-
- xmlNode *newfence;
- xmlNode *newfencemethod;
- xmlNode *newfencedevice;
-
- clusternodes = findnode(root_element, "clusternodes");
- if (!clusternodes)
- die("Can't find \"clusternodes\" in %s\n", ninfo->configfile);
-
- /* Don't allow duplicate node names */
- if (find_node(clusternodes, ninfo->name))
- die("node %s already exists in %s\n", ninfo->name, ninfo->configfile);
-
- /* Check for duplicate node ID */
- if (!ninfo->nodeid)
- die("nodeid not specified\n");
-
- if (get_by_nodeid(root_element, atoi((char *)ninfo->nodeid)))
- die("nodeid %s already in use\n", ninfo->nodeid);
-
- /* Don't allow random fence types */
- if (ninfo->fence_type && !valid_fence_type(root_element, ninfo->fence_type))
- die("fence type '%s' not known\n", ninfo->fence_type);
-
- /* Add the new node */
- newnode = xmlNewNode(NULL, BAD_CAST "clusternode");
- xmlSetProp(newnode, BAD_CAST "name", BAD_CAST ninfo->name);
- xmlSetProp(newnode, BAD_CAST "votes", BAD_CAST ninfo->votes);
- xmlSetProp(newnode, BAD_CAST "nodeid", BAD_CAST ninfo->nodeid);
- xmlAddChild(clusternodes, newnode);
-
- if (ninfo->altname)
- {
- xmlNode *altnode;
-
- altnode = xmlNewNode(NULL, BAD_CAST "altname");
- xmlSetProp(altnode, BAD_CAST "name", BAD_CAST ninfo->altname);
- xmlAddChild(newnode, altnode);
- }
-
- /* Add the fence attributes */
- if (ninfo->fence_type)
- {
- newfence = xmlNewNode(NULL, BAD_CAST "fence");
- newfencemethod = xmlNewNode(NULL, BAD_CAST "method");
- xmlSetProp(newfencemethod, BAD_CAST "name", BAD_CAST "single");
-
- newfencedevice = xmlNewNode(NULL, BAD_CAST "device");
- xmlSetProp(newfencedevice, BAD_CAST "name", BAD_CAST ninfo->fence_type);
-
- /* Add name=value options */
- add_fence_args(newfencedevice, argc, argv, optindex+1);
-
- xmlAddChild(newnode, newfence);
- xmlAddChild(newfence, newfencemethod);
- xmlAddChild(newfencemethod, newfencedevice);
- }
-}
-
-static void add_clusterservice(xmlNode *root_element, struct option_info *ninfo,
- int argc, char **argv, int optindex)
-{
- xmlNode *rm;
- xmlNode *rs;
- xmlNode *fdomains;
- xmlNode *newnode;
-
- xmlNode *newfs = NULL;
- xmlNode *newfsscript;
- xmlNode *newfsip;
-
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" in %s\n", ninfo->configfile);
-
- /* Don't allow duplicate service names */
- if (find_service(rm, ninfo->name))
- die("service %s already exists in %s\n", ninfo->name,
- ninfo->configfile);
-
- rs = findnode(rm, "resources");
- fdomains = findnode(rm, "failoverdomains");
- if (ninfo->fs && (!rs || !find_fs_resource(rs, ninfo->fs)))
- die("fs resource %s doesn't exist in %s\n", ninfo->fs,
- ninfo->configfile);
- if (ninfo->script && (!rs || !find_script_resource(rs, ninfo->script)))
- die("script resource %s doesn't exist in %s\n", ninfo->script,
- ninfo->configfile);
- if (ninfo->ip_addr && (!rs || !find_ip_resource(rs, ninfo->ip_addr)))
- die("ip resource %s doesn't exist in %s\n", ninfo->ip_addr,
- ninfo->configfile);
- if (ninfo->domain && (!fdomains || !find_fdomain_resource(fdomains, ninfo->domain)))
- die("failover domain %s doesn't exist in %s\n", ninfo->domain,
- ninfo->configfile);
-
- /* Add the new service */
- newnode = xmlNewNode(NULL, BAD_CAST "service");
- xmlSetProp(newnode, BAD_CAST "name", BAD_CAST ninfo->name);
- xmlSetProp(newnode, BAD_CAST "autostart", BAD_CAST ninfo->autostart);
- if (ninfo->domain)
- xmlSetProp(newnode, BAD_CAST "domain", BAD_CAST ninfo->domain);
- if (ninfo->exclusive)
- xmlSetProp(newnode, BAD_CAST "exclusive",
- BAD_CAST ninfo->exclusive);
- xmlSetProp(newnode, BAD_CAST "recovery", BAD_CAST ninfo->recovery);
- xmlAddChild(rm, newnode);
-
- /* Add the fs reference */
- if (ninfo->fs)
- {
- newfs = xmlNewNode(NULL, BAD_CAST "fs");
- xmlSetProp(newfs, BAD_CAST "ref", BAD_CAST ninfo->fs);
- xmlAddChild(newnode, newfs);
- }
-
- /* Add the script reference */
- if (ninfo->script)
- {
- newfsscript = xmlNewNode(NULL, BAD_CAST "script");
- xmlSetProp(newfsscript, BAD_CAST "ref", BAD_CAST ninfo->script);
- if (newfs)
- xmlAddChild(newfs, newfsscript);
- else
- xmlAddChild(newnode, newfsscript);
- }
-
- /* Add the ip reference */
- if (ninfo->ip_addr)
- {
- newfsip = xmlNewNode(NULL, BAD_CAST "ip");
- xmlSetProp(newfsip, BAD_CAST "ref", BAD_CAST
- ninfo->ip_addr);
- if (newfs)
- xmlAddChild(newfs, newfsip);
- else
- xmlAddChild(newnode, newfsip);
- }
-}
-
-static void add_clusterfs(xmlNode *root_element, struct option_info *ninfo,
- int argc, char **argv, int optindex)
-{
- xmlNode *rm;
- xmlNode *rs;
- xmlNode *node;
-
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" in %s\n", ninfo->configfile);
-
- rs = findnode(rm, "resources");
- if (!rs)
- die("Can't find \"resources\" %s\n", ninfo->configfile);
-
- /* Check it doesn't already exist */
- if (find_fs_resource(rs, ninfo->name))
- die("fs %s already exists\n", ninfo->name);
-
- /* Add the new fs resource */
- node = xmlNewNode(NULL, BAD_CAST "fs");
- xmlSetProp(node, BAD_CAST "device", BAD_CAST ninfo->device);
- _xmlSetIntProp(node, "force_fsck", ninfo->force_fsck);
- _xmlSetIntProp(node, "force_unmount", ninfo->force_unmount);
- xmlSetProp(node, BAD_CAST "fstype", BAD_CAST ninfo->type);
- xmlSetProp(node, BAD_CAST "mountpoint", BAD_CAST ninfo->mountpoint);
- xmlSetProp(node, BAD_CAST "name", BAD_CAST ninfo->name);
- xmlSetProp(node, BAD_CAST "options", (ninfo->options) ?
- BAD_CAST ninfo->options : BAD_CAST "");
- _xmlSetIntProp(node, "self_fence", ninfo->self_fence);
- xmlAddChild(rs, node);
-}
-
-static void add_clusterfdomain(xmlNode *root_element, struct option_info *ninfo,
- int argc, char **argv, int optindex)
-{
- xmlNode *rm;
- xmlNode *fdomains;
- xmlNode *node;
- xmlNode *cn;
- int i = 0;
-
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" in %s\n", ninfo->configfile);
-
- fdomains = findnode(rm, "failoverdomains");
- if (!fdomains)
- die("Can't find \"failoverdomains\" %s\n", ninfo->configfile);
-
- cn = findnode(root_element, "clusternodes");
- if (!cn)
- die("Can't find \"clusternodes\" in %s\n", ninfo->configfile);
-
- /* Check it doesn't already exist */
- if (find_fdomain_resource(fdomains, ninfo->name))
- die("failover domain %s already exists\n", ninfo->name);
-
- /* Check that nodes are defined */
- while (ninfo->failover_nodes[i]) {
- if (!find_node(cn, ninfo->failover_nodes[i]))
- die("Can't find node %s in %s.\n",
- ninfo->failover_nodes[i], ninfo->configfile);
- i++;
- }
-
- /* Add the new failover domain */
- node = xmlNewNode(NULL, BAD_CAST "failoverdomain");
- xmlSetProp(node, BAD_CAST "name", BAD_CAST ninfo->name);
- _xmlSetIntProp(node, "ordered", ninfo->ordered);
- _xmlSetIntProp(node, "restricted", ninfo->restricted);
-
- i = 0;
- while (ninfo->failover_nodes[i]) {
- xmlNode *fnode = xmlNewNode(NULL, BAD_CAST "failoverdomainnode");
- xmlSetProp(fnode, BAD_CAST "name", BAD_CAST ninfo->failover_nodes[i]);
- _xmlSetIntProp(fnode, "priority", i + 1);
- xmlAddChild(node, fnode);
- i++;
- }
- xmlAddChild(fdomains, node);
-}
-
-static xmlDoc *open_configfile(struct option_info *ninfo)
-{
- xmlDoc *doc;
-
- /* Init libxml */
- xmlInitParser();
- LIBXML_TEST_VERSION;
-
- if (!ninfo->configfile)
- ninfo->configfile = DEFAULT_CONFIG_DIR "/" DEFAULT_CONFIG_FILE;
- if (!ninfo->outputfile)
- ninfo->outputfile = ninfo->configfile;
-
- /* Load XML document */
- doc = xmlParseFile(ninfo->configfile);
- if (doc == NULL)
- die("Error: unable to parse requested configuration file\n");
-
- return doc;
-
-}
-
-static void del_clusternode(xmlNode *root_element, struct option_info *ninfo)
-{
- xmlNode *clusternodes;
- xmlNode *oldnode;
-
- clusternodes = findnode(root_element, "clusternodes");
- if (!clusternodes)
- {
- fprintf(stderr, "Can't find \"clusternodes\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- oldnode = find_node(clusternodes, ninfo->name);
- if (!oldnode)
- {
- fprintf(stderr, "node %s does not exist in %s\n", ninfo->name, ninfo->configfile);
- exit(1);
- }
-
- xmlUnlinkNode(oldnode);
-}
-
-static void del_clusterservice(xmlNode *root_element, struct option_info *ninfo)
-{
- xmlNode *rm;
- xmlNode *oldnode;
-
- rm = findnode(root_element, "rm");
- if (!rm)
- {
- fprintf(stderr, "Can't find \"rm\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- oldnode = find_service(rm, ninfo->name);
- if (!oldnode)
- {
- fprintf(stderr, "service %s does not exist in %s\n", ninfo->name, ninfo->configfile);
- exit(1);
- }
-
- xmlUnlinkNode(oldnode);
-}
-
-static void del_clusterscript(xmlNode *root_element, struct option_info *ninfo)
-{
- xmlNode *rm, *rs;
- xmlNode *node;
-
- rm = findnode(root_element, "rm");
- if (!rm)
- {
- fprintf(stderr, "Can't find \"rm\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- rs = findnode(rm, "resources");
- if (!rs)
- {
- fprintf(stderr, "Can't find \"resources\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- /* Check that not used */
- node = find_script_ref(rm, ninfo->name);
- if (node)
- {
- fprintf(stderr, "Script %s is referenced in service in %s,"
- " please remove reference first.\n", ninfo->name,
- ninfo->configfile);
- exit(1);
- }
-
- node = find_script_resource(rs, ninfo->name);
- if (!node)
- {
- fprintf(stderr, "Script %s does not exist in %s\n", ninfo->name, ninfo->configfile);
- exit(1);
- }
-
- xmlUnlinkNode(node);
-}
-
-static void del_clusterip(xmlNode *root_element, struct option_info *ninfo)
-{
- xmlNode *rm, *rs;
- xmlNode *node;
-
- rm = findnode(root_element, "rm");
- if (!rm)
- {
- fprintf(stderr, "Can't find \"rm\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- rs = findnode(rm, "resources");
- if (!rs)
- {
- fprintf(stderr, "Can't find \"resources\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- /* Check that not used */
- node = find_ip_ref(rm, ninfo->name);
- if (node)
- {
- fprintf(stderr, "IP %s is referenced in service in %s,"
- " please remove reference first.\n", ninfo->name,
- ninfo->configfile);
- exit(1);
- }
-
- node = find_ip_resource(rs, ninfo->name);
- if (!node)
- {
- fprintf(stderr, "IP %s does not exist in %s\n", ninfo->name, ninfo->configfile);
- exit(1);
- }
-
- xmlUnlinkNode(node);
-}
-
-static void del_clusterfs(xmlNode *root_element, struct option_info *ninfo)
-{
- xmlNode *rm, *rs;
- xmlNode *node;
-
- rm = findnode(root_element, "rm");
- if (!rm)
- {
- fprintf(stderr, "Can't find \"rm\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- rs = findnode(rm, "resources");
- if (!rs)
- {
- fprintf(stderr, "Can't find \"resources\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- /* Check that not used */
- node = find_fs_ref(rm, ninfo->name);
- if (node)
- {
- fprintf(stderr, "fs %s is referenced in service in %s,"
- " please remove reference first.\n", ninfo->name,
- ninfo->configfile);
- exit(1);
- }
-
- node = find_fs_resource(rs, ninfo->name);
- if (!node)
- {
- fprintf(stderr, "fs %s does not exist in %s\n", ninfo->name, ninfo->configfile);
- exit(1);
- }
-
- xmlUnlinkNode(node);
-}
-
-static void del_clusterfdomain(xmlNode *root_element, struct option_info *ninfo)
-{
- xmlNode *rm, *fdomains;
- xmlNode *node;
-
- rm = findnode(root_element, "rm");
- if (!rm)
- {
- fprintf(stderr, "Can't find \"rm\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- fdomains = findnode(rm, "failoverdomains");
- if (!fdomains)
- {
- fprintf(stderr, "Can't find \"failoverdomains\" in %s\n", ninfo->configfile);
- exit(1);
- }
-
- /* Check that not used */
- node = find_fdomain_ref(rm, ninfo->name);
- if (node)
- {
- fprintf(stderr, "failover domain %s is referenced in service in %s,"
- " please remove reference first.\n", ninfo->name,
- ninfo->configfile);
- exit(1);
- }
-
- node = find_fdomain_resource(fdomains, ninfo->name);
- if (!node)
- {
- fprintf(stderr, "failover domain %s does not exist in %s\n", ninfo->name, ninfo->configfile);
- exit(1);
- }
-
- xmlUnlinkNode(node);
-}
-
-struct option addnode_options[] =
-{
- { "votes", required_argument, NULL, 'v'},
- { "nodeid", required_argument, NULL, 'n'},
- { "altname", required_argument, NULL, 'a'},
- { "fence_type", required_argument, NULL, 'f'},
- { "outputfile", required_argument, NULL, 'o'},
- { "configfile", required_argument, NULL, 'c'},
- { NULL, 0, NULL, 0 },
-};
-
-struct option addfs_options[] =
-{
- { "type", required_argument, NULL, 't'},
- { "options", required_argument, NULL, 'p'},
- { "outputfile", required_argument, NULL, 'o'},
- { "configfile", required_argument, NULL, 'c'},
- { "force_fsck", no_argument, NULL, 'k'},
- { "force_unmount", no_argument, NULL, 'u'},
- { "self_fence", no_argument, NULL, 's'},
- { NULL, 0, NULL, 0 },
-};
-
-struct option addfdomain_options[] =
-{
- { "outputfile", required_argument, NULL, 'o'},
- { "configfile", required_argument, NULL, 'c'},
- { "ordered", no_argument, NULL, 'p'},
- { "restricted", no_argument, NULL, 'r'},
- { NULL, 0, NULL, 0 },
-};
-
-struct option commonw_options[] =
-{
- { "outputfile", required_argument, NULL, 'o'},
- { "configfile", required_argument, NULL, 'c'},
- { NULL, 0, NULL, 0 },
-};
-
-struct option addnodeid_options[] =
-{
- { "outputfile", required_argument, NULL, 'o'},
- { "configfile", required_argument, NULL, 'c'},
- { "multicast", required_argument, NULL, 'm'},
- { "nodeid", no_argument, NULL, 'n'},
- { "verbose", no_argument, NULL, 'v'},
- { NULL, 0, NULL, 0 },
-};
-
-struct option list_options[] =
-{
- { "configfile", required_argument, NULL, 'c'},
- { "verbose", no_argument, NULL, 'v'},
- { NULL, 0, NULL, 0 },
-};
-
-struct option create_options[] =
-{
- { "configfile", required_argument, NULL, 'c'},
- { "nodes", required_argument, NULL, 'n'},
- { "fence", required_argument, NULL, 'f'},
- { "verbose", no_argument, NULL, 'v'},
- { NULL, 0, NULL, 0 },
-};
-
-struct option addservice_options[] =
-{
- { "autostart", required_argument, NULL, 'a'},
- { "domain", required_argument, NULL, 'd'},
- { "exclusive", required_argument, NULL, 'x'},
- { "recovery", required_argument, NULL, 'r'},
- { "fs", required_argument, NULL, 'f'},
- { "script", required_argument, NULL, 's'},
- { "ip", required_argument, NULL, 'i'},
- { "outputfile", required_argument, NULL, 'o'},
- { "configfile", required_argument, NULL, 'c'},
- { NULL, 0, NULL, 0 },
-};
-
-static int parse_commonw_options(int argc, char **argv,
- struct option_info *ninfo)
-{
- int opt;
-
- memset(ninfo, 0, sizeof(*ninfo));
-
- while ( (opt = getopt_long(argc, argv, "o:c:h?", commonw_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo->configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo->outputfile = strdup(optarg);
- break;
-
- case '?':
- default:
- return 1;
- }
- }
- return 0;
-}
-
-static int next_nodeid(int startid, int *nodeids, int nodecount)
-{
- int i;
- int nextid = startid;
-
-retry:
- for (i=0; i<nodecount; i++)
- {
- if (nodeids[i] == nextid)
- {
- nextid++;
- goto retry;
- }
- }
-
- return nextid;
-}
-
-void add_nodeids(int argc, char **argv)
-{
- struct option_info ninfo;
- unsigned char *nodenames[MAX_NODES];
- xmlDoc *doc;
- xmlNode *root_element;
- xmlNode *clusternodes;
- xmlNode *cur_node;
- xmlNode *mcast;
- int verbose = 0;
- int opt;
- int i;
- int nodenumbers[MAX_NODES];
- int nodeidx;
- int totalnodes;
- int nextid;
-
- memset(nodenames, 0, sizeof(nodenames));
- memset(nodenumbers, 0, sizeof(nodenumbers));
- memset(&ninfo, 0, sizeof(ninfo));
- ninfo.nodeid = "1";
-
- while ( (opt = getopt_long(argc, argv, "n:o:c:m:vh?", addnodeid_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'n':
- validate_int_arg(opt, optarg);
- ninfo.nodeid = strdup(optarg);
- break;
-
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case 'm':
- if (!valid_mcast_addr(optarg)) {
- fprintf(stderr, "%s is not a valid multicast address\n", optarg);
- return;
- }
- ninfo.mcast_addr = strdup(optarg);
- break;
-
- case 'v':
- verbose++;
- break;
-
- case '?':
- default:
- addnodeid_usage(argv[0]);
- }
- }
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- increment_version(root_element);
-
- /* Warn if the cluster doesn't have a multicast address */
- mcast = find_multicast_addr(root_element);
- if (!mcast & !ninfo.mcast_addr) {
- fprintf(stderr, "\nWARNING: The cluster does not have a multicast address.\n");
- fprintf(stderr, "A default will be assigned a run-time which might not suit your installation\n\n");
- }
-
- if (ninfo.mcast_addr) {
- if (!mcast) {
- xmlNode *cman = xmlNewNode(NULL, BAD_CAST "cman");
- mcast = xmlNewNode(NULL, BAD_CAST "multicast");
-
- xmlAddChild(cman, mcast);
- xmlAddChild(root_element, cman);
- }
- xmlSetProp(mcast, BAD_CAST "addr", BAD_CAST ninfo.mcast_addr);
- }
-
- /* Get a list of nodes that /do/ have nodeids so we don't generate
- any duplicates */
- nodeidx=0;
- clusternodes = findnode(root_element, "clusternodes");
- if (!clusternodes)
- die("Can't find \"clusternodes\" in %s\n", ninfo.configfile);
-
-
- for (cur_node = clusternodes->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE && strcmp((char *)cur_node->name, "clusternode") == 0)
- {
- xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
- xmlChar *nodeid = xmlGetProp(cur_node, BAD_CAST "nodeid");
- nodenames[nodeidx] = name;
- if (nodeid)
- nodenumbers[nodeidx] = atoi((char*)nodeid);
- nodeidx++;
- }
- }
- totalnodes = nodeidx;
-
- /* Loop round nodes adding nodeIDs where they don't exist. */
- nextid = next_nodeid(atoi(ninfo.nodeid), nodenumbers, totalnodes);
- for (i=0; i<totalnodes; i++)
- {
- if (nodenumbers[i] == 0)
- {
- nodenumbers[i] = nextid;
- nextid = next_nodeid(nextid, nodenumbers, totalnodes);
- if (verbose)
- fprintf(stderr, "Node %s now has id %d\n", nodenames[i], nodenumbers[i]);
- }
- }
-
- /* Now write them into the tree */
- nodeidx = 0;
- for (cur_node = clusternodes->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE && strcmp((char *)cur_node->name, "clusternode") == 0)
- {
- char tmp[80];
- xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
- assert(name);
-
- assert(strcmp((char*)nodenames[nodeidx], (char*)name) == 0);
-
- snprintf(tmp, sizeof(tmp), "%d", nodenumbers[nodeidx]);
- xmlSetProp(cur_node, BAD_CAST "nodeid", BAD_CAST tmp);
- nodeidx++;
- }
- }
-
-
- /* Write it out */
- save_file(doc, &ninfo);
-
- /* Shutdown libxml */
- xmlCleanupParser();
-}
-
-void add_node(int argc, char **argv)
-{
- struct option_info ninfo;
- int opt;
- xmlDoc *doc;
- xmlNode *root_element;
-
- memset(&ninfo, 0, sizeof(ninfo));
- ninfo.votes = "1";
-
- while ( (opt = getopt_long(argc, argv, "v:n:a:f:o:c:h?", addnode_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'v':
- validate_int_arg(opt, optarg);
- ninfo.votes = optarg;
- break;
-
- case 'n':
- validate_int_arg(opt, optarg);
- ninfo.nodeid = optarg;
- break;
-
- case 'a':
- ninfo.altname = strdup(optarg);
- break;
-
- case 'f':
- ninfo.fence_type = strdup(optarg);
- break;
-
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case '?':
- default:
- addnode_usage(argv[0]);
- }
- }
-
- /* Get node name parameter */
- if (optind < argc)
- ninfo.name = strdup(argv[optind]);
- else
- addnode_usage(argv[0]);
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- increment_version(root_element);
-
- add_clusternode(root_element, &ninfo, argc, argv, optind);
-
- /* Write it out */
- save_file(doc, &ninfo);
- /* Shutdown libxml */
- xmlCleanupParser();
-
-}
-
-void del_node(int argc, char **argv)
-{
- struct option_info ninfo;
- xmlDoc *doc;
- xmlNode *root_element;
-
- if (parse_commonw_options(argc, argv, &ninfo))
- delnode_usage(argv[0]);
-
- /* Get node name parameter */
- if (optind < argc)
- ninfo.name = strdup(argv[optind]);
- else
- delnode_usage(argv[0]);
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- increment_version(root_element);
-
- if (!strcmp(argv[0], "delnode"))
- del_clusternode(root_element, &ninfo);
- else if (!strcmp(argv[0], "delservice"))
- del_clusterservice(root_element, &ninfo);
- else if (!strcmp(argv[0], "delscript"))
- del_clusterscript(root_element, &ninfo);
- else if (!strcmp(argv[0], "delip"))
- del_clusterip(root_element, &ninfo);
- else if (!strcmp(argv[0], "delfs"))
- del_clusterfs(root_element, &ninfo);
- else if (!strcmp(argv[0], "delfdomain"))
- del_clusterfdomain(root_element, &ninfo);
-
- /* Write it out */
- save_file(doc, &ninfo);
-}
-
-void list_nodes(int argc, char **argv)
-{
- xmlNode *cur_node;
- xmlNode *root_element;
- xmlNode *clusternodes;
- xmlNode *fencenode = NULL;
- xmlDocPtr doc;
- xmlNode *mcast;
- struct option_info ninfo;
- int opt;
- int verbose = 0;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "c:vh?", list_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
- case 'v':
- verbose++;
- break;
- case '?':
- default:
- list_usage(argv[0]);
- }
- }
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- printf("\nCluster name: %s, config_version: %s\n\n",
- (char *)cluster_name(root_element),
- (char *)find_version(root_element));
-
- clusternodes = findnode(root_element, "clusternodes");
- if (!clusternodes)
- die("Can't find \"clusternodes\" in %s\n", ninfo.configfile);
-
- mcast = find_multicast_addr(root_element);
- if (mcast)
- printf("Multicast address for cluster: %s\n\n", xmlGetProp(mcast, BAD_CAST "addr"));
-
- printf("Nodename Votes Nodeid Fencetype\n");
- for (cur_node = clusternodes->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE && strcmp((char *)cur_node->name, "clusternode") == 0)
- {
- xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
- xmlChar *votes = xmlGetProp(cur_node, BAD_CAST "votes");
- xmlChar *nodeid = xmlGetProp(cur_node, BAD_CAST "nodeid");
- xmlChar *ftype = get_fence_type(cur_node, &fencenode);
-
- if (!nodeid)
- nodeid=(unsigned char *)"0";
- if (!votes)
- votes = (unsigned char *)"1";
-
- printf("%-32s %3d %3d %s\n", name, atoi((char *)votes),
- atoi((char *)nodeid),
- ftype?ftype:(xmlChar *)"");
- if (verbose)
- {
- xmlNode *a = findnode(cur_node, "altname");
- if (a)
- {
- printf(" altname %s=%s", "name", xmlGetProp(a, BAD_CAST "name"));
- if (!print_properties(a, "","",""))
- printf("\n");
- }
- print_properties(cur_node, " Node properties: ", "votes", "nodeid");
- print_properties(fencenode, " Fence properties: ", "agent", "");
- }
-
- }
- }
-}
-
-void add_service(int argc, char **argv)
-{
- struct option_info ninfo;
- int opt;
- xmlDoc *doc;
- xmlNode *root_element;
-
- memset(&ninfo, 0, sizeof(ninfo));
- ninfo.autostart = "1";
- ninfo.recovery = "relocate";
-
- while ( (opt = getopt_long(argc, argv, "a:d:x:r:f:o:c:s:i:h?", addservice_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'a':
- validate_int_arg(opt, optarg);
- ninfo.autostart = optarg;
- break;
-
- case 'd':
- ninfo.domain = strdup(optarg);
- break;
-
- case 'x':
- validate_int_arg(opt, optarg);
- ninfo.exclusive = optarg;
- break;
-
- case 'r':
- ninfo.recovery = strdup(optarg);
- break;
-
- case 'f':
- ninfo.fs = strdup(optarg);
- break;
-
- case 's':
- ninfo.script = strdup(optarg);
- break;
-
- case 'i':
- ninfo.ip_addr = strdup(optarg);
- break;
-
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case '?':
- default:
- addservice_usage(argv[0]);
- }
- }
-
- /* Get service name parameter */
- if (optind < argc)
- ninfo.name = strdup(argv[optind]);
- else
- addservice_usage(argv[0]);
-
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- increment_version(root_element);
-
- add_clusterservice(root_element, &ninfo, argc, argv, optind);
-
- /* Write it out */
- save_file(doc, &ninfo);
- /* Shutdown libxml */
- xmlCleanupParser();
-
-}
-
-void list_services(int argc, char **argv)
-{
- xmlNode *cur_service;
- xmlNode *root_element;
- xmlNode *rm;
- xmlDocPtr doc;
- struct option_info ninfo;
- int opt;
- int verbose = 0;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "c:vh?", list_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
- case 'v':
- verbose++;
- break;
- case '?':
- default:
- list_usage(argv[0]);
- }
- }
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- printf("\nCluster name: %s, config_version: %s\n\n",
- (char *)cluster_name(root_element),
- (char *)find_version(root_element));
-
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" in %s\n", ninfo.configfile);
-
- printf("Name Autostart Exclusive Recovery\n");
- for (cur_service = rm->children; cur_service;
- cur_service = cur_service->next)
- {
- xmlChar *name, *autostart, *exclusive, *recovery;
-
- if (!cur_service->type == XML_ELEMENT_NODE ||
- strcmp((char *)cur_service->name, "service") != 0)
- continue;
-
- name = xmlGetProp(cur_service, BAD_CAST "name");
- autostart = xmlGetProp(cur_service, BAD_CAST "autostart");
- exclusive = xmlGetProp(cur_service, BAD_CAST "exclusive");
- recovery = xmlGetProp(cur_service, BAD_CAST "recovery");
-
- if (!autostart)
- autostart = (unsigned char *)"0";
- if (!exclusive)
- exclusive = (unsigned char *)"0";
- if (!recovery)
- recovery = (unsigned char *)"-";
-
- printf("%-32s %3d %3d %s\n", name,
- atoi((char *)autostart), atoi((char *)exclusive),
- (char *)recovery);
- }
-}
-
-void add_script(int argc, char **argv)
-{
- struct option_info ninfo;
- xmlDoc *doc;
- xmlNode *root_element;
- xmlNode *rm, *rs, *node;
- char *name;
- char *sc_file;
-
- if (parse_commonw_options(argc, argv, &ninfo))
- addscript_usage(argv[0]);
-
- if (argc - optind < 2)
- addscript_usage(argv[0]);
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- increment_version(root_element);
-
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" %s\n", ninfo.configfile);
-
- rs = findnode(rm, "resources");
- if (!rs)
- die("Can't find \"resources\" %s\n", ninfo.configfile);
-
- /* First param is the script name - check it doesn't already exist */
- name = argv[optind++];
- if (find_script_resource(rs, name))
- die("Script %s already exists\n", name);
- sc_file = argv[optind++];
-
- /* Add it */
- node = xmlNewNode(NULL, BAD_CAST "script");
- xmlSetProp(node, BAD_CAST "file", BAD_CAST sc_file);
- xmlSetProp(node, BAD_CAST "name", BAD_CAST name);
- xmlAddChild(rs, node);
-
- /* Write it out */
- save_file(doc, &ninfo);
-
- /* Shutdown libxml */
- xmlCleanupParser();
-}
-
-void add_ip(int argc, char **argv)
-{
- struct option_info ninfo;
- xmlDoc *doc;
- xmlNode *root_element;
- xmlNode *rm, *rs, *node;
-
- if (parse_commonw_options(argc, argv, &ninfo))
- addip_usage(argv[0]);
-
- if (optind < argc)
- ninfo.ip_addr = strdup(argv[optind]);
- else
- addip_usage(argv[0]);
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- increment_version(root_element);
-
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" %s\n", ninfo.configfile);
-
- rs = findnode(rm, "resources");
- if (!rs)
- die("Can't find \"resources\" %s\n", ninfo.configfile);
-
- /* Check it doesn't already exist */
- if (find_ip_resource(rs, ninfo.ip_addr))
- die("IP %s already exists\n", ninfo.ip_addr);
-
- /* Add it */
- node = xmlNewNode(NULL, BAD_CAST "ip");
- xmlSetProp(node, BAD_CAST "address", BAD_CAST ninfo.ip_addr);
- xmlSetProp(node, BAD_CAST "monitor_link", BAD_CAST "1");
- xmlAddChild(rs, node);
-
- /* Write it out */
- save_file(doc, &ninfo);
-
- /* Shutdown libxml */
- xmlCleanupParser();
-}
-
-void add_fs(int argc, char **argv)
-{
- struct option_info ninfo;
- xmlDoc *doc;
- xmlNode *root_element;
- int opt;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "t:p:o:c:h?kus", addfs_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 't':
- ninfo.type = strdup(optarg);
- break;
-
- case 'p':
- ninfo.options = strdup(optarg);
- break;
-
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case 'k':
- ninfo.force_fsck = 1;
- break;
-
- case 'u':
- ninfo.force_unmount = 1;
- break;
-
- case 's':
- ninfo.self_fence = 1;
- break;
-
- case '?':
- default:
- addfs_usage(argv[0]);
- }
- }
-
- if (optind < argc - 2) {
- ninfo.name = strdup(argv[optind]);
- ninfo.device = strdup(argv[optind + 1]);
- ninfo.mountpoint = strdup(argv[optind + 2]);
- } else
- addfs_usage(argv[0]);
-
- if (!ninfo.type)
- ninfo.type = "ext3";
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- increment_version(root_element);
-
- add_clusterfs(root_element, &ninfo, argc, argv, optind);
-
- /* Write it out */
- save_file(doc, &ninfo);
- /* Shutdown libxml */
- xmlCleanupParser();
-}
-
-void add_fdomain(int argc, char **argv)
-{
- struct option_info ninfo;
- xmlDoc *doc;
- xmlNode *root_element;
- int opt, i;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "pro:c:h?", addfdomain_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'p':
- ninfo.ordered = 1;
- break;
-
- case 'r':
- ninfo.restricted = 1;
- break;
-
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case '?':
- default:
- addfdomain_usage(argv[0]);
- }
- }
-
- if (optind < argc - 1) {
- ninfo.name = strdup(argv[optind]);
- ninfo.failover_nodes = (const char **)malloc(sizeof(char *) * (argc - optind));
- if (!ninfo.failover_nodes) {
- fprintf(stdout, "Out of mem!\n");
- exit(EXIT_FAILURE);
- }
- for (i = 0; i < argc - optind - 1; i++) {
- ninfo.failover_nodes[i] = strdup(argv[i + optind + 1]);
- assert(ninfo.failover_nodes[i]);
- }
- ninfo.failover_nodes[i] = NULL;
- } else
- addfdomain_usage(argv[0]);
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- increment_version(root_element);
-
- add_clusterfdomain(root_element, &ninfo, argc, argv, optind);
-
- /* Write it out */
- save_file(doc, &ninfo);
- /* Shutdown libxml */
- xmlCleanupParser();
-
- for (i = 0; i < argc - optind - 1; i++)
- free((void *)ninfo.failover_nodes[i]);
-
- free(ninfo.failover_nodes);
-}
-
-void create_skeleton(int argc, char **argv)
-{
- char *fencename = NULL;
- char *clustername;
- struct option_info ninfo;
- struct stat st;
- FILE *outfile;
- int i;
- int twonode = 0;
- int numnodes=0;
- int opt;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "c:2hn:f:?", create_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case '2':
- twonode = 1;
- numnodes = 2;
- break;
- case 'n':
- numnodes = atoi(optarg);
- break;
- case 'f':
- fencename = strdup(optarg);
- break;
-
- case '?':
- default:
- create_usage(argv[0]);
- }
- }
- if (!ninfo.outputfile)
- ninfo.outputfile = DEFAULT_CONFIG_DIR "/" DEFAULT_CONFIG_FILE;
- ninfo.configfile = "-";
-
- if (argc - optind < 1)
- create_usage(argv[0]);
-
- clustername = argv[optind];
-
- if (stat(ninfo.outputfile, &st) == 0)
- die("%s already exists", ninfo.outputfile);
-
- /* Init libxml */
- outfile = fopen(ninfo.outputfile, "w+");
- if (!outfile) {
- perror(" Can't open output file");
- return;
- }
-
- fprintf(outfile, "<?xml version=\"1.0\"?>\n");
- fprintf(outfile, "<cluster name=\"%s\" config_version=\"1\">\n", clustername);
- fprintf(outfile, "\n");
- if (twonode) {
- fprintf(outfile, " <cman two_node=\"1\" expected_votes=\"1\"/>\n");
- }
-
- fprintf(outfile, " <clusternodes>\n");
- for (i=1; i <= numnodes; i++) {
- fprintf(outfile, " <clusternode name=\"NEEDNAME-%02d\" votes=\"1\" nodeid=\"%d\">\n", i, i);
- fprintf(outfile, " <fence>\n");
- fprintf(outfile, " <method name=\"single\">\n");
- if (fencename) {
- fprintf(outfile, " <device name=\"fence1\" ADDARGS/>\n");
- }
- fprintf(outfile, " </method>\n");
- fprintf(outfile, " </fence>\n");
- fprintf(outfile, " </clusternode>\n");
- }
- fprintf(outfile, " </clusternodes>\n");
- fprintf(outfile, "\n");
- fprintf(outfile, " <fencedevices>\n");
- if (fencename) {
- fprintf(outfile, " <fencedevice name=\"fence1\" agent=\"%s\" ADDARGS/>\n", fencename);
- }
- fprintf(outfile, " </fencedevices>\n");
- fprintf(outfile, "\n");
- fprintf(outfile, " <rm>\n");
- fprintf(outfile, " <failoverdomains/>\n");
- fprintf(outfile, " <resources/>\n");
- fprintf(outfile, " </rm>\n");
- fprintf(outfile, "</cluster>\n");
-
- fclose(outfile);
-}
-
-void add_fence(int argc, char **argv)
-{
- xmlNode *root_element;
- xmlNode *fencedevices;
- xmlNode *fencenode = NULL;
- xmlDocPtr doc;
- char *fencename;
- char *agentname;
- struct option_info ninfo;
-
- if (parse_commonw_options(argc, argv, &ninfo))
- addfence_usage(argv[0]);
-
- if (argc - optind < 2)
- addfence_usage(argv[0]);
-
- doc = open_configfile(&ninfo);
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- increment_version(root_element);
-
- fencedevices = findnode(root_element, "fencedevices");
- if (!fencedevices)
- die("Can't find \"fencedevices\" %s\n", ninfo.configfile);
-
- /* First param is the fence name - check it doesn't already exist */
- fencename = argv[optind++];
-
- if (valid_fence_type(root_element, fencename))
- die("fence type %s already exists\n", fencename);
-
- agentname = argv[optind++];
-
- /* Add it */
- fencenode = xmlNewNode(NULL, BAD_CAST "fencedevice");
- xmlSetProp(fencenode, BAD_CAST "name", BAD_CAST fencename);
- xmlSetProp(fencenode, BAD_CAST "agent", BAD_CAST agentname);
-
- /* Add name=value options */
- add_fence_args(fencenode, argc, argv, optind);
-
- xmlAddChild(fencedevices, fencenode);
-
- save_file(doc, &ninfo);
-}
-
-void del_fence(int argc, char **argv)
-{
- xmlNode *root_element;
- xmlNode *fencedevices;
- xmlNode *fencenode;
- xmlDocPtr doc;
- char *fencename;
- struct option_info ninfo;
-
- if (parse_commonw_options(argc, argv, &ninfo))
- delfence_usage(argv[0]);
-
- if (argc - optind < 1)
- delfence_usage(argv[0]);
-
- fencename = argv[optind];
-
- doc = open_configfile(&ninfo);
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
- increment_version(root_element);
-
- fencedevices = findnode(root_element, "fencedevices");
- if (!fencedevices)
- die("Can't find \"fencedevices\" in %s\n", ninfo.configfile);
-
- fencenode = valid_fence_type(root_element, fencename);
- if (!fencenode)
- die("fence type %s does not exist\n", fencename);
-
- xmlUnlinkNode(fencenode);
-
- save_file(doc, &ninfo);
-}
-
-void list_fences(int argc, char **argv)
-{
- xmlNode *cur_node;
- xmlNode *root_element;
- xmlNode *fencedevices;
- xmlDocPtr doc;
- struct option_info ninfo;
- int opt;
- int verbose=0;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "c:hv?", list_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
- case 'v':
- verbose++;
- break;
- case '?':
- default:
- list_usage(argv[0]);
- }
- }
- doc = open_configfile(&ninfo);
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- fencedevices = findnode(root_element, "fencedevices");
- if (!fencedevices)
- die("Can't find \"fencedevices\" in %s\n", ninfo.configfile);
-
-
- printf("Name Agent\n");
- for (cur_node = fencedevices->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE && strcmp((char *)cur_node->name, "fencedevice") == 0)
- {
- xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
- xmlChar *agent = xmlGetProp(cur_node, BAD_CAST "agent");
-
- printf("%-16s %s\n", name, agent);
- if (verbose)
- print_properties(cur_node, " Properties: ", "agent", "");
- }
- }
-}
-
-void list_scripts(int argc, char **argv)
-{
- xmlNode *cur_node;
- xmlNode *root_element;
- xmlNode *rm, *rs;
- xmlDocPtr doc;
- struct option_info ninfo;
- int opt;
- int verbose=0;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "c:hv?", list_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
- case 'v':
- verbose++;
- break;
- case '?':
- default:
- list_usage(argv[0]);
- }
- }
- doc = open_configfile(&ninfo);
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" in %s\n", ninfo.configfile);
-
- rs = findnode(rm, "resources");
- if (!rs)
- die("Can't find \"resources\" in %s\n", ninfo.configfile);
-
- printf("Name Path\n");
- for (cur_node = rs->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE && strcmp((char *)cur_node->name, "script") == 0)
- {
- xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
- xmlChar *path = xmlGetProp(cur_node, BAD_CAST "file");
-
- printf("%-16s %s\n", name, path);
- }
- }
-}
-
-void list_ips(int argc, char **argv)
-{
- xmlNode *cur_node;
- xmlNode *root_element;
- xmlNode *rm, *rs;
- xmlDocPtr doc;
- struct option_info ninfo;
- int opt;
- int verbose=0;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "c:hv?", list_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
- case 'v':
- verbose++;
- break;
- case '?':
- default:
- list_usage(argv[0]);
- }
- }
- doc = open_configfile(&ninfo);
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" in %s\n", ninfo.configfile);
-
- rs = findnode(rm, "resources");
- if (!rs)
- die("Can't find \"resources\" in %s\n", ninfo.configfile);
-
- printf("IP\n");
- for (cur_node = rs->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE &&
- strcmp((char *)cur_node->name, "ip") == 0)
- {
- xmlChar *ip = xmlGetProp(cur_node, BAD_CAST "address");
-
- printf("%s\n", ip);
- }
- }
-}
-
-void list_fs(int argc, char **argv)
-{
- xmlNode *cur_node;
- xmlNode *root_element;
- xmlNode *rm, *rs;
- xmlDocPtr doc;
- struct option_info ninfo;
- int opt;
- int verbose=0;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "c:hv?", list_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
- case 'v':
- verbose++;
- break;
- case '?':
- default:
- list_usage(argv[0]);
- }
- }
- doc = open_configfile(&ninfo);
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
-
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" in %s\n", ninfo.configfile);
-
- rs = findnode(rm, "resources");
- if (!rs)
- die("Can't find \"resources\" in %s\n", ninfo.configfile);
-
- printf("Name Type FUS Device Mountpoint\n");
- for (cur_node = rs->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE &&
- strcmp((char *)cur_node->name, "fs") == 0)
- {
- xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
- xmlChar *type = xmlGetProp(cur_node, BAD_CAST "fstype");
- xmlChar *force_fsck = xmlGetProp(cur_node,
- BAD_CAST "force_fsck");
- xmlChar *force_unmount = xmlGetProp(cur_node,
- BAD_CAST "force_unmount");
- xmlChar *self_fence = xmlGetProp(cur_node,
- BAD_CAST "self_fence");
- xmlChar *device = xmlGetProp(cur_node,
- BAD_CAST "device");
- xmlChar *mnt = xmlGetProp(cur_node,
- BAD_CAST "mountpoint");
-
- char f, u, s;
- INT_TO_CHAR(f, force_fsck)
- INT_TO_CHAR(u, force_unmount)
- INT_TO_CHAR(s, self_fence)
- printf("%-16.16s %-5.5s %c%c%c %-19.19s %s\n", name, type, f, u,
- s, device, mnt);
- }
- }
-}
-
-void list_fdomains(int argc, char **argv)
-{
- xmlNode *cur_node, *fnode;
- xmlNode *root_element;
- xmlNode *rm, *fdomains;
- xmlDocPtr doc;
- struct option_info ninfo;
- int opt;
- int verbose=0;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "c:hv?", list_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
- case 'v':
- verbose++;
- break;
- case '?':
- default:
- list_usage(argv[0]);
- }
- }
- doc = open_configfile(&ninfo);
- root_element = xmlDocGetRootElement(doc);
- assert(root_element);
- rm = findnode(root_element, "rm");
- if (!rm)
- die("Can't find \"rm\" in %s\n", ninfo.configfile);
-
- fdomains = findnode(rm, "failoverdomains");
- if (!fdomains)
- die("Can't find \"failoverdomains\" in %s\n", ninfo.configfile);
-
- printf("Name OR Nodes\n");
- for (cur_node = fdomains->children; cur_node; cur_node = cur_node->next)
- {
- if (cur_node->type == XML_ELEMENT_NODE &&
- strcmp((char *)cur_node->name, "failoverdomain") == 0)
- {
- xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
- xmlChar *ordered = xmlGetProp(cur_node, BAD_CAST "ordered");
- xmlChar *restricted = xmlGetProp(cur_node, BAD_CAST "restricted");
- char o, r;
- int first_node = 1;
-
- INT_TO_CHAR(o, ordered)
- INT_TO_CHAR(r, restricted)
- printf("%-16.16s %c%c ", name, o, r);
- for (fnode = cur_node->children; fnode; fnode = fnode->next)
- if (fnode->type == XML_ELEMENT_NODE &&
- strcmp((char *)fnode->name, "failoverdomainnode") == 0)
- {
- xmlChar *fname = xmlGetProp(fnode, BAD_CAST "name");
- if (first_node) {
- printf("%s", fname);
- first_node = 0;
- } else
- printf(",%s", fname);
- }
- printf("\n");
- }
- }
-}
diff --git a/config/tools/ccs_tool/editconf.h b/config/tools/ccs_tool/editconf.h
deleted file mode 100644
index 7edd52f..0000000
--- a/config/tools/ccs_tool/editconf.h
+++ /dev/null
@@ -1,18 +0,0 @@
-void add_node(int argc, char **argv);
-void add_nodeids(int argc, char **argv);
-void add_service(int argc, char **argv);
-void add_script(int argc, char **argv);
-void add_ip(int argc, char **argv);
-void add_fs(int argc, char **argv);
-void add_fdomain(int argc, char **argv);
-void add_fence(int argc, char **argv);
-void del_node(int argc, char **argv);
-void del_fence(int argc, char **argv);
-void list_nodes(int argc, char **argv);
-void list_services(int argc, char **argv);
-void list_fences(int argc, char **argv);
-void list_scripts(int argc, char **argv);
-void list_ips(int argc, char **argv);
-void list_fs(int argc, char **argv);
-void list_fdomains(int argc, char **argv);
-void create_skeleton(int argc, char **argv);
diff --git a/config/tools/ldap/Makefile b/config/tools/ldap/Makefile
deleted file mode 100644
index 1f0da3f..0000000
--- a/config/tools/ldap/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-TARGET= confdb2ldif
-
-SBINDIRT=$(TARGET)
-
-SUBDIRS=rng2ldif
-
-all: ${TARGET}
-
-include ../../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-include $(OBJDIR)/make/passthrough.mk
-
-OBJS= confdb2ldif.o
-
-CFLAGS += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
-CFLAGS += -I${corosyncincdir}
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${corosynclibdir} -lconfdb
-LDFLAGS += -L${libdir}
-
-${TARGET}: ${OBJS}
- $(CC) -o $@ $^ $(LDFLAGS)
-
-clean: generalclean
-
--include $(OBJS:.o=.Tpo)
diff --git a/config/tools/ldap/confdb2ldif.c b/config/tools/ldap/confdb2ldif.c
deleted file mode 100644
index 8ab45b5..0000000
--- a/config/tools/ldap/confdb2ldif.c
+++ /dev/null
@@ -1,180 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/un.h>
-
-#include <corosync/confdb.h>
-
-confdb_callbacks_t callbacks = {
-};
-
-static const char *ldap_attr_name(const char *attrname)
-{
- static char newname[1024];
- int i;
-
- if (strcmp(attrname, "name") == 0)
- return attrname;
-
- snprintf(newname, sizeof(newname) - 1, "rhcs");
- for (i=0; i<strlen(attrname)+1; i++) {
- if (i == 0)
- newname[4+i] = attrname[i] & 0x5F;
- else
- if (attrname[i] == '_')
- newname[4+i] = '-';
- else
- newname[4+i] = attrname[i];
- }
- return newname;
-}
-
-
-/* Recursively dump the object tree */
-static void print_config_tree(confdb_handle_t handle, hdb_handle_t parent_object_handle, const char *dn, char *fulldn)
-{
- hdb_handle_t object_handle;
- char object_name[1024];
- size_t object_name_len;
- char key_name[1024];
- char *key_value=NULL;
- confdb_value_types_t type;
- size_t key_value_len;
- char cumulative_dn[4096];
- int res;
- int keycount=0;
-
- printf("\ndn: %s\n", fulldn);
-
- /* Show the keys */
- res = confdb_key_iter_start(handle, parent_object_handle);
- if (res != CS_OK) {
- printf( "error resetting key iterator for object "HDB_X_FORMAT": %d\n", parent_object_handle, res);
- return;
- }
-
- while ( (res = confdb_key_iter_typed2(handle, parent_object_handle, key_name,
- (void**)&key_value, &key_value_len, &type)) == CS_OK) {
- key_value[key_value_len] = '\0';
-
- printf("%s: %s\n", ldap_attr_name(key_name), key_value);
- keycount++;
- free(key_value);
- key_value=NULL;
- }
- if (strncmp(fulldn, "cn=", 3) == 0) {
- printf("cn: %s\n", dn);
- }
-
-
- /* Determine objectclass... */
- if (keycount == 0) {
- printf("objectclass: nsContainer\n");
- }
- else {
- printf("objectclass: %s\n", ldap_attr_name(dn));
- }
-
- /* Show sub-objects */
- res = confdb_object_iter_start(handle, parent_object_handle);
- if (res != CS_OK) {
- printf( "error resetting object iterator for object "HDB_X_FORMAT": %d\n", parent_object_handle, res);
- return;
- }
-
- while ( (res = confdb_object_iter(handle, parent_object_handle, &object_handle, object_name, &object_name_len)) == CS_OK) {
- hdb_handle_t parent;
-
- res = confdb_object_parent_get(handle, object_handle, &parent);
- if (res != CS_OK) {
- printf( "error getting parent for object "HDB_X_FORMAT": %d\n", object_handle, res);
- return;
- }
-
- object_name[object_name_len] = '\0';
-
- /* Check for "name", and create dummy parent object */
- res = confdb_key_get_typed2(handle, object_handle, "name", (void **)&key_value, &key_value_len, &type);
- if (res == CS_OK) {
- snprintf(cumulative_dn, sizeof(cumulative_dn) - 1, "cn=%s,%s", object_name, fulldn);
- printf("\n");
- printf("dn: %s\n", cumulative_dn);
- printf("cn: %s\n", object_name);
- printf("objectclass: %s\n", "nsContainer");
-
- snprintf(cumulative_dn, sizeof(cumulative_dn) - 1, "name=%s,cn=%s,%s", key_value, object_name, fulldn);
- free(key_value);
- key_value = NULL;
- }
- else {
- snprintf(cumulative_dn, sizeof(cumulative_dn) - 1, "cn=%s,%s", object_name, fulldn);
- }
-
- /* Down we go ... */
- print_config_tree(handle, object_handle, object_name, cumulative_dn);
- }
-}
-
-
-int main(int argc, char *argv[])
-{
- confdb_handle_t handle;
- int result;
- hdb_handle_t cluster_handle;
- const char *clusterroot = "cluster";
- char basedn[1024];
-
- if (argc == 1) {
- fprintf(stderr, "usage: \n");
- fprintf(stderr, " %s <dn> [<objdb root>]\n", argv[0]);
- fprintf(stderr, "\n");
- fprintf(stderr, " eg: \n");
- fprintf(stderr, " %s dc=mycompany,dc=com\n", argv[0]);
- fprintf(stderr, " %s dc=mycompany,dc=com rhcluster\n", argv[0]);
- fprintf(stderr, "\n");
- fprintf(stderr, "objdb root defaults to 'cluster'\n");
- fprintf(stderr, "\n");
- return 0;
- }
-
- if (argc > 2) {
- clusterroot = argv[2];
- }
-
- result = confdb_initialize (&handle, &callbacks);
- if (result != CS_OK) {
- printf ("Could not initialize Cluster Configuration Database API instance error %d\n", result);
- exit (1);
- }
-
- /* Find the starting object ... this should be a param */
-
- result = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE);
- if (result != CS_OK) {
- printf ("Could not start object_find %d\n", result);
- exit (1);
- }
-
- result = confdb_object_find(handle, OBJECT_PARENT_HANDLE, clusterroot, strlen(clusterroot), &cluster_handle);
- if (result != CS_OK) {
- printf ("Could not object_find \"cluster\": %d\n", result);
- exit (1);
- }
-
- snprintf(basedn, sizeof(basedn) - 1, "name=%s,%s", clusterroot, argv[1]);
-
- /* Print a header */
- printf("# This file was generated by confdb2ldif, from an existing cluster configuration\n");
- printf("#\n");
-
- /* Print the configuration */
- print_config_tree(handle, cluster_handle, clusterroot, basedn);
-
-
- result = confdb_finalize (handle);
- return (0);
-}
diff --git a/config/tools/ldap/rng2ldif/Makefile b/config/tools/ldap/rng2ldif/Makefile
deleted file mode 100644
index 54e7556..0000000
--- a/config/tools/ldap/rng2ldif/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-TARGET1= rng2ldif
-TARGET2= genclass
-
-all: ${TARGET1} ${TARGET2}
-
-include ../../../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -D_GNU_SOURCE
-CFLAGS += -I.
-CFLAGS += `xml2-config --cflags`
-CFLAGS += -I${incdir}
-
-LDFLAGS += `xml2-config --libs`
-LDFLAGS += -L${libdir}
-
-OBJS1= rng2ldif.o \
- tree.o
-
-OBJS2= genclass.o
-
-SHAREDOBJS= zalloc.o \
- value-list.o \
- ldaptypes.o \
- name.o
-
-${TARGET1}: ${SHAREDOBJS} ${OBJS1}
- $(CC) -o $@ $^ $(LDFLAGS)
-
-${TARGET2}: ${SHAREDOBJS} ${OBJS2}
- $(CC) -o $@ $^ $(LDFLAGS)
-
-ldif-update: all $(SRCDIR)/config/plugins/ldap/ldap-base.csv
- make -C $(OBJDIR)/config/tools/xml cluster.rng
- ./rng2ldif $(OBJDIR)/config/tools/xml/cluster.rng \
- $(SRCDIR)/config/plugins/ldap/ldap-base.csv \
- $(SRCDIR)/config/plugins/ldap/99cluster.ldif
-
-clean: generalclean
-
--include $(OBJS1:.o=.Tpo)
--include $(OBJS2:.o=.Tpo)
--include $(SHAREDOBJS:.o=.Tpo)
diff --git a/config/tools/ldap/rng2ldif/debug.h b/config/tools/ldap/rng2ldif/debug.h
deleted file mode 100644
index 907e096..0000000
--- a/config/tools/ldap/rng2ldif/debug.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _DEBUG_H
-#define _DEBUG_H
-
-#ifdef DEBUG
-#define dbg_printf printf
-#else
-#define dbg_printf(args...)
-#endif
-
-#endif
diff --git a/config/tools/ldap/rng2ldif/genclass.c b/config/tools/ldap/rng2ldif/genclass.c
deleted file mode 100644
index dd69401..0000000
--- a/config/tools/ldap/rng2ldif/genclass.c
+++ /dev/null
@@ -1,106 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-#include "value-list.h"
-#include "tree.h"
-
-
-static void
-id_gen_object_struct(struct idinfo *oi, FILE *fp)
-{
- struct idval *v;
-
- fprintf(fp, "struct objectclasses\n");
- fprintf(fp, "{\n");
- fprintf(fp, "\tchar *name;\n");
- fprintf(fp, "\tchar *class;\n");
- fprintf(fp, "} objectclasses[] = \n");
- fprintf(fp, "{\n");
-
- for (v = oi->head; v->next; v = v->next) {
- if (v->type != OBJ)
- continue;
- fprintf(fp, "\t{ \"%s\", \"%s\" }, \n",
- v->rawname, v->name);
- }
-
- fprintf(fp, "\t{ \"%s\", \"%s\" }\n};\n",
- v->rawname, v->name);
-}
-
-
-static int
-write_class_struct(char *csv, char *arg, struct idinfo *ids)
-{
- char filename[4096];
- FILE *out = NULL;
- int fd = -1;
- mode_t oldumask;
-
- if (!strcmp(arg, "-")) {
- out = stdout;
- } else {
- oldumask=umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
- snprintf(filename, sizeof(filename), "%s.XXXXXX", arg);
- fd = mkstemp(filename);
- umask(oldumask);
- if (fd < 0) {
- perror("mkstemp");
- return -1;
- }
-
- out = fdopen(fd, "w");
- if (out == NULL) {
- perror("fdopen");
- close(fd);
- return -1;
- }
- }
-
- fprintf(out, "/* Begin autogenerated class struct from %s */\n", csv);
- id_gen_object_struct(ids, out);
- fprintf(out, "/* End autogenerated class struct */\n");
-
- fflush(out);
-
- if (fd >= 0) {
- fsync(fd);
- fclose(out);
- close(fd);
- rename(filename, arg);
- }
-
- return 0;
-}
-
-
-int
-main(int argc, char **argv)
-{
- struct idinfo info;
-
- memset(&info, 0, sizeof(info));
-
- if (argc < 3) {
- printf("Translate csv -> C structure\n"
- "file for future reuse of IDs\n");
- printf("Usage: %s file.csv output.c\n",
- argv[0]);
- return 1;
- }
-
- if (id_readfile(&info, argv[1]) < 0) {
- printf("Can't read %s\n", argv[1]);
- return 1;
- }
-
- write_class_struct(argv[1], argv[2], &info);
-
- return 0;
-}
diff --git a/config/tools/ldap/rng2ldif/ldaptypes.c b/config/tools/ldap/rng2ldif/ldaptypes.c
deleted file mode 100644
index beb0de9..0000000
--- a/config/tools/ldap/rng2ldif/ldaptypes.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "ldaptypes.h"
-#include "debug.h"
-
-struct type_entry {
- const char *rng_name;
- const char *ldap_equality;
- const char *ldap_syntax;
-};
-
-
-struct type_entry type_table[] = {
-{ "boolean", "booleanMatch", "1.3.6.1.4.1.1466.115.121.1.7" },
-{ "integer", "integerMatch", "1.3.6.1.4.1.1466.115.121.1.27" },
-{ "positiveInteger", "integerMatch", "1.3.6.1.4.1.1466.115.121.1.27" },
-{ "nonNegativeInteger", "integerMatch", "1.3.6.1.4.1.1466.115.121.1.27" },
-{ "string", "caseExactIA5Match", "1.3.6.1.4.1.1466.115.121.1.26" },
-{ "ID", "caseExactIA5Match", "1.3.6.1.4.1.1466.115.121.1.26" },
-{ NULL, "caseExactIA5Match", "1.3.6.1.4.1.1466.115.121.1.26" } };
-
-
-void
-find_ldap_type_info(const char *name,
- char **equality,
- char **syntax)
-{
- int x;
-
- for (x = 0; type_table[x].rng_name != NULL; x++)
- if (!strcasecmp(name, type_table[x].rng_name))
- break;
- dbg_printf("%s @ index %d\n", name, x);
-
- *equality = (char *)type_table[x].ldap_equality;
- *syntax = (char *)type_table[x].ldap_syntax;
-}
-
-
-#ifdef STANDALONE
-#include <stdio.h>
-int
-main(int argc, char **argv)
-{
- char *eq, *syn;
-
- find_ldap_type_info(argv[1], &eq, &syn);
-
- printf("EQUALITY %s\nSYNTAX %s\n", eq, syn);
-
- return 0;
-}
-#endif
diff --git a/config/tools/ldap/rng2ldif/ldaptypes.h b/config/tools/ldap/rng2ldif/ldaptypes.h
deleted file mode 100644
index 1546cf3..0000000
--- a/config/tools/ldap/rng2ldif/ldaptypes.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _LDAPTYPES_H
-#define _LDAPTYPES_H
-
-void find_ldap_type_info(const char *name,
- char **equality,
- char **syntax);
-
-#endif
diff --git a/config/tools/ldap/rng2ldif/name.c b/config/tools/ldap/rng2ldif/name.c
deleted file mode 100644
index 8cc5ef7..0000000
--- a/config/tools/ldap/rng2ldif/name.c
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <ctype.h>
-#include "name.h"
-#include "zalloc.h"
-
-char *
-normalize_name(const char *name)
-{
- char *ret_val;
- int size = 4, x;
-
- if (!strcasecmp(name, "name")) {
- ret_val = strdup(name);
- assert(ret_val!=NULL);
- goto out;
- }
-
- size = strlen(name)+5;
- ret_val = zalloc(size); /* 1 byte for null, 4 for rhcs */
- if (!ret_val)
- return NULL;
-
- snprintf(ret_val, size, "rhcs%s", name);
-
-out:
- for (x = 0; x < 4; x++)
- ret_val[x] |= 32;
- if (ret_val[4] == '_')
- ret_val[4] = '-';
- else
- ret_val[4] &= ~32;
- for (x = 5; x < size; x++) {
- if (ret_val[x] == '_') {
- ret_val[x] = '-';
- }
- }
-
- return ret_val;
-}
-
-#ifdef STANDALONE
-int
-main(int argc, char **argv)
-{
- char *val;
- if (argc < 2)
- return -1;
-
- val = normalize_name(argv[1]);
- if (!val)
- fprintf(stderr, "oops\n");
- printf("%s\n", val);
- free(val);
- return 0;
-}
-#endif
diff --git a/config/tools/ldap/rng2ldif/name.h b/config/tools/ldap/rng2ldif/name.h
deleted file mode 100644
index a332b45..0000000
--- a/config/tools/ldap/rng2ldif/name.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _NAME_H
-#define _NAME_H
-
-char *normalize_name(const char *name);
-
-#endif
diff --git a/config/tools/ldap/rng2ldif/rng2ldif.c b/config/tools/ldap/rng2ldif/rng2ldif.c
deleted file mode 100644
index 635d4c8..0000000
--- a/config/tools/ldap/rng2ldif/rng2ldif.c
+++ /dev/null
@@ -1,242 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-#include "value-list.h"
-#include "tree.h"
-
-
-struct faux_list {
- struct faux_list *next;
-};
-
-
-static void __attribute__((noinline))
-reverse(struct faux_list **list)
-{
- struct faux_list *node = NULL;
- struct faux_list *newlist = NULL;
-
- if (!list || (*list == NULL))
- return;
-
- while ((*list) != NULL) {
- node = *list;
- *list = node->next;
- node->next = newlist;
- newlist = node;
- }
- *list = node;
-}
-
-
-static int
-print_attr_node(FILE *fp, struct ldap_attr_node *node)
-{
- if (!node)
- return -1;
- if (!fp)
- fp = stdout;
-
- if (!strcasecmp(node->name, "name")) {
- /* Don't print 'name' out as an attr. */
- return 0;
- }
-
- fprintf(fp, "attributeTypes: (\n");
- fprintf(fp, " 1.3.6.1.4.1.2312.8.1.1.%d NAME '%s'\n",
- node->idval->value, node->name);
- fprintf(fp, " EQUALITY %s\n", node->ldap_equality);
- fprintf(fp, " SYNTAX %s\n", node->ldap_syntax);
- fprintf(fp, " SINGLE-VALUE\n )\n");
- return 0;
-}
-
-
-static int
-print_obj_node(FILE *fp, struct ldap_object_node *node)
-{
- struct ldap_attr_meta_node *n;
- const char *cmt = "";
-
- if (!node)
- return -1;
- if (!fp)
- fp = stdout;
-
- if (!node->required_attrs && !node->optional_attrs) {
- cmt = "#";
- fprintf(fp, "### Placeholder for %s\n", node->name);
- fprintf(fp,
- "### This object class currently has no attributes\n");
- }
-
- fprintf(fp, "%sobjectClasses: (\n", cmt);
- fprintf(fp, "%s 1.3.6.1.4.1.2312.8.1.2.%d NAME '%s' SUP top STRUCTURAL\n", cmt, node->idval->value, node->name);
-
- if (node->required_attrs) {
- fprintf(fp, "%s MUST ( ", cmt);
-
- if (node->need_cn) {
- fprintf(fp, "cn $ ");
- }
-
- for (n = node->required_attrs; n->next != NULL; n = n->next)
- fprintf(fp, "%s $ ", n->node->name);
- fprintf(fp, "%s )\n", n->node->name);
- } else {
- if (node->need_cn) {
- fprintf(fp, "%s MUST ( cn )\n", cmt);
- }
- }
-
- if (node->optional_attrs) {
- fprintf(fp, "%s MAY ( ", cmt);
- for (n = node->optional_attrs; n->next != NULL; n = n->next)
- fprintf(fp, "%s $ ", n->node->name);
- fprintf(fp, "%s )\n", n->node->name);
- }
- fprintf(fp, "%s )\n", cmt);
- return 0;
-}
-
-
-static xmlDocPtr
-open_relaxng(const char *filename)
-{
- xmlDocPtr p;
- xmlNodePtr n;
-
- p = xmlParseFile(filename);
- if (!p) {
- printf("Failed to parse %s\n", filename);
- }
-
- n = xmlDocGetRootElement(p);
- if (!n) {
- printf("Unable to determine xml root element\n");
- xmlFreeDoc(p);
- return NULL;
- }
-
- if (xmlStrcmp(n->name, (xmlChar *)"grammar")) {
- printf("%s is not a relaxng grammar\n", filename);
- xmlFreeDoc(p);
- return NULL;
- }
-
- return p;
-}
-
-
-static int
-write_ldap_schema(const char *rng, const char *arg,
- struct ldap_attr_node *attrs,
- struct ldap_object_node *objs)
-{
- struct ldap_attr_node *attr = NULL;
- struct ldap_object_node *obj = NULL;
- char filename[4096];
- FILE *out_ldap = NULL;
- char now_asc[128];
- time_t now;
- struct tm now_tm;
- int fd = -1;
- mode_t oldumask;
-
- if (!strcmp(arg, "-")) {
- out_ldap = stdout;
- } else {
- oldumask=umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
- snprintf(filename, sizeof(filename), "%s.XXXXXX", arg);
- fd = mkstemp(filename);
- umask(oldumask);
- if (fd < 0) {
- perror("mkstemp");
- return -1;
- }
-
- out_ldap = fdopen(fd, "w");
- if (out_ldap == NULL) {
- perror("fdopen");
- close(fd);
- return -1;
- }
- }
-
- now = time(NULL);
- memset(&now_tm, 0, sizeof(now_tm));
- if (localtime_r(&now, &now_tm) == NULL) {
- snprintf(now_asc, sizeof(now_asc), "???");
- } else {
- strftime(now_asc, sizeof(now_asc), "%F %T", &now_tm);
- }
-
- fprintf(out_ldap, "# Auto-generated @ %s\n", now_asc);
- fprintf(out_ldap, "dn: cn=schema\n");
-
- for (attr = attrs; attr; attr = attr->next)
- print_attr_node(out_ldap, attr);
- for (obj = objs; obj; obj= obj->next)
- print_obj_node(out_ldap, obj);
-
- fflush(out_ldap);
-
- if (fd >= 0) {
- fsync(fd);
- fclose(out_ldap);
- close(fd);
- rename(filename, arg);
- }
-
- return 0;
-}
-
-
-int
-main(int argc, char **argv)
-{
- struct ldap_attr_node *attrs = NULL;
- struct ldap_object_node *objs = NULL;
- struct idinfo info;
- xmlDocPtr doc;
-
- memset(&info, 0, sizeof(info));
-
- if (argc < 4) {
- printf("Translate cluster RelaxNG -> LDIF schema and update\n"
- "global .csv file for future reuse of IDs\n");
- printf("Usage: %s cluster.rng ldap-base.csv cluster.ldif\n",
- argv[0]);
- return 1;
- }
-
- doc = open_relaxng(argv[1]);
- if (doc == NULL) {
- printf("Cannot continue\n");
- return 1;
- }
-
- if (id_readfile(&info, argv[2]) < 0) {
- printf("Can't read %s\n", argv[2]);
- return 1;
- }
-
- find_objects(xmlDocGetRootElement(doc), &objs, &attrs, &info);
-
- reverse((struct faux_list **)&attrs);
- reverse((struct faux_list **)&objs);
-
- if (write_ldap_schema(argv[1], argv[3], attrs, objs) < 0)
- return -1;
-
- id_writefile(&info, argv[2]);
-
- return 0;
-}
diff --git a/config/tools/ldap/rng2ldif/tree.c b/config/tools/ldap/rng2ldif/tree.c
deleted file mode 100644
index 7c63124..0000000
--- a/config/tools/ldap/rng2ldif/tree.c
+++ /dev/null
@@ -1,469 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <assert.h>
-
-#include "zalloc.h"
-#include "value-list.h"
-#include "tree.h"
-#include "name.h"
-#include "ldaptypes.h"
-#include "debug.h"
-
-
-static struct ldap_attr_node *
-find_attr_byname(struct ldap_attr_node *attrs, const char *name)
-{
- struct ldap_attr_node *n;
-
- for (n = attrs; n; n = n->next) {
- if (!strcmp(n->name, name))
- return n;
- }
- return NULL;
-}
-
-
-static struct ldap_attr_meta_node *
-find_meta_attr(struct ldap_attr_meta_node *metas, struct ldap_attr_node *attr)
-{
- struct ldap_attr_meta_node *n;
-
- for (n = metas; n; n = n->next) {
- if (n->node == attr)
- return n;
- }
- return NULL;
-}
-
-
-static struct ldap_attr_meta_node *
-find_meta_attr_byname(struct ldap_attr_meta_node *metas, const char *name)
-{
- struct ldap_attr_meta_node *n;
-
- for (n = metas; n; n = n->next) {
- if (!strcmp(n->node->name, name))
- return n;
- }
- return NULL;
-}
-
-
-static int
-find_data_match_fn(xmlNodePtr curr_node, char **match_fn, char **ldap_syntax)
-{
- xmlNodePtr n = NULL;
- char *type = NULL;
- int need_free = 1;
-
- for (n = curr_node; n; n = n->next) {
- if (!n->name ||
- strcasecmp((char *)n->name, "data"))
- continue;
- break;
- }
-
- if (n)
- type = (char *)xmlGetProp(n, (xmlChar *)"type");
-
- dbg_printf("type %s\n", type);
-
- if (!type) {
- type = (char *)"string";
- need_free = 0;
- }
-
- find_ldap_type_info(type, match_fn, ldap_syntax);
-
- if (need_free)
- xmlFree(type);
-
- return 1;
-}
-
-
-static struct ldap_attr_node *
-get_attr(xmlNodePtr curr_node, struct ldap_attr_node **attrs,
- struct idinfo *ids)
-{
- struct ldap_attr_node *n;
- struct idval *v;
- char *name, *normalized;
-
- name = (char *)xmlGetProp(curr_node, (xmlChar *)"name");
- if (!name) {
- return NULL;
- }
-
- normalized = normalize_name((const char *)name);
-
- n = find_attr_byname(*attrs, normalized);
- if (n) {
- free(normalized);
- return n;
- }
-
- n = zalloc(sizeof(*n));
-
- v = id_find(ids, normalized, ATTR, 0);
- if (!v) {
- v = zalloc(sizeof(*v));
- v->name = normalized;
- v->type = ATTR;
- v->rawname = (char *)name;
- id_insert(ids, v);
- } else {
- free(normalized);
- }
-
- n->idval = v;
- n->name = n->idval->name;
-
- dbg_printf("Lookin for data type for %s\n", n->name);
- find_data_match_fn(curr_node->xmlChildrenNode, &n->ldap_equality,
- &n->ldap_syntax);
-
- n->next = *attrs;
- *attrs = n;
-
- return n;
-}
-
-
-static struct ldap_object_node *
-find_obj(struct ldap_object_node *objs, const char *name)
-{
- struct ldap_object_node *n;
-
- for (n = objs; n; n = n->next) {
- if (!strcmp(n->name, name))
- return n;
- }
- return NULL;
-}
-
-
-static xmlNodePtr
-find_ref(xmlNodePtr curr_node)
-{
- xmlNodePtr n;
- char *name;
- char *tmp_name;
-
- dbg_printf("Trying to parse ref tag\n");
- name = (char *)xmlGetProp(curr_node, (xmlChar *)"name");
- if (!name) {
- fprintf(stderr, "Unable to determine xml name prop\n");
- exit(1);
- }
-
- n = xmlDocGetRootElement(curr_node->doc);
- if (!n) {
- fprintf(stderr, "Unable to determine xml root element\n");
- exit(1);
- }
- n = n->xmlChildrenNode;
- for (; n; n = n->next) {
- if (n->type != XML_ELEMENT_NODE)
- continue;
- if (strcasecmp((char *)n->name, "define"))
- continue;
-
- tmp_name = (char *)xmlGetProp(n, (xmlChar *)"name");
- if (!tmp_name)
- continue;
- if (strcmp(tmp_name, name))
- continue;
-
- break;
- }
-
- if (!n) {
- fprintf(stderr, "Error in RelaxNG schema!\n");
- fprintf(stderr, "Unterminated reference: %s\n",
- name);
- exit(1);
- }
-
- return n->xmlChildrenNode;
-}
-
-
-static int
-find_optional_attributes(xmlNodePtr curr_node, int in_block,
- struct ldap_object_node *curr_obj,
- struct ldap_attr_node **attrs,
- struct idinfo *ids)
-{
- xmlNodePtr node;
- struct ldap_attr_node *attr;
- struct ldap_attr_meta_node *n = NULL;
-
- if (!curr_node || (curr_node->type == XML_ELEMENT_NODE &&
- (curr_node->name && !strcasecmp((char *)curr_node->name, "element")))) {
- return 0;
- }
-
- dbg_printf("lookin for optionals\n");
-
- for (node = curr_node; node; node = node->next) {
- if (node->type != XML_ELEMENT_NODE)
- continue;
-
- if (!node->name)
- continue;
-
- if (strcmp((char *)node->name, "attribute"))
- continue;
-
- if (!strcasecmp((char *)node->name, "ref")) {
- find_optional_attributes(
- find_ref(node), 1, curr_obj, attrs, ids);
- }
- if (!strcasecmp((char *)node->name, "choice")) {
- find_optional_attributes(node->xmlChildrenNode, 1,
- curr_obj,
- attrs, ids);
- continue;
- }
- if (!strcasecmp((char *)node->name, "group")) {
- find_optional_attributes(node->xmlChildrenNode, 1,
- curr_obj,
- attrs, ids);
- continue;
- }
- if (!strcasecmp((char *)node->name, "optional")) {
- find_optional_attributes(node->xmlChildrenNode, 1,
- curr_obj,
- attrs, ids);
- continue;
- }
-
- if (!in_block)
- continue;
-
- attr = get_attr(node, attrs, ids);
- if (!n) {
- n = zalloc(sizeof(*n));
- assert(n);
- }
-
- dbg_printf("opt attr '%s'\n", attr->idval->name);
-
- if (find_meta_attr(curr_obj->required_attrs,
- attr)) {
- dbg_printf("skipping dup attr\n");
- continue;
- }
- if (find_meta_attr(curr_obj->optional_attrs,
- attr)) {
- dbg_printf("skipping dup attr on optional list\n");
- continue;
- }
-
- n->node = attr;
- n->next = curr_obj->optional_attrs;
- curr_obj->optional_attrs = n;
- n=NULL;
- }
-
- if (n) {
- free(n);
- n=NULL;
- }
- return 0;
-}
-
-
-static int
-find_required_attributes(xmlNodePtr curr_node,
- struct ldap_object_node *curr_obj,
- struct ldap_attr_node **attrs,
- struct idinfo *ids)
-{
- xmlNodePtr node;
- struct ldap_attr_node *attr;
- struct ldap_attr_meta_node *n = NULL;
-
- dbg_printf("lookin for required\n");
-
- for (node = curr_node; node; node = node->next) {
- if (node->type != XML_ELEMENT_NODE)
- continue;
- if (xmlStrcmp(node->name, (xmlChar *)"attribute"))
- continue;
-
- attr = get_attr(node, attrs, ids);
- if (!n) {
- n = zalloc(sizeof(*n));
- assert(n);
- }
-
- dbg_printf("req attr '%s'\n", attr->idval->name);
-
- if (find_meta_attr(curr_obj->required_attrs,
- attr)) {
- dbg_printf("skipping dup attr\n");
- continue;
- }
- if (find_meta_attr(curr_obj->optional_attrs,
- attr)) {
- dbg_printf("skipping dup attr on optional list\n");
- continue;
- }
-
- n->node = attr;
- n->next = curr_obj->required_attrs;
- curr_obj->required_attrs = n;
- n=NULL;
- }
-
- if (n) {
- free(n);
- n=NULL;
- }
- return 0;
-}
-
-
-static struct ldap_object_node *
-parse_element_tag(xmlNodePtr curr_node,
- struct ldap_object_node **objs,
- struct ldap_attr_node **attrs,
- struct idinfo *ids)
-{
- struct ldap_object_node *obj;
- char *n, *normalized;
- struct idval *v;
- int need_cn = 1;
-
- dbg_printf("Trying to parse element tag\n");
- n = (char *)xmlGetProp(curr_node, (xmlChar *)"name");
- if (!n) {
- printf("Unable to parse element tag\n");
- exit(1);
- }
- normalized = normalize_name(n);
- v = id_find(ids, normalized, OBJ, 0);
-
- if (!v) {
- v = zalloc(sizeof(*v));
- v->name = normalized;
- v->rawname = n;
- v->type = OBJ;
- id_insert(ids, v);
- }
-
- obj = find_obj(*objs, v->name);
-
- if (!obj) {
- obj = zalloc(sizeof(*obj));
- obj->name = v->name;
- obj->idval = v;
- obj->next = *objs;
- *objs = obj;
- dbg_printf("New object class %s \n",obj->name);
- }
-
- find_optional_attributes(curr_node->xmlChildrenNode, 0,
- obj, attrs, ids);
- find_required_attributes(curr_node->xmlChildrenNode,
- obj, attrs, ids);
-
- if (find_meta_attr_byname(obj->required_attrs, "name") ||
- find_meta_attr_byname(obj->required_attrs, "cn")) {
- need_cn = 0;
- }
-
- if (need_cn &&
- (find_meta_attr_byname(obj->optional_attrs, "name") ||
- find_meta_attr_byname(obj->optional_attrs, "cn"))) {
- need_cn = 0;
- }
-
- if (need_cn) {
- dbg_printf("Object class might %s need 'MUST ( cn )' for proper LDIF\n", obj->name);
- obj->need_cn = 1;
- }
-
- return obj;
-}
-
-
-#if 0
-static struct ldap_object_node *
-parse_ref_tag(xmlNodePtr curr_node,
- struct ldap_object_node **objs,
- struct ldap_attr_node **attrs,
- struct idinfo *ids)
-{
- xmlXPathObjectPtr xobj;
- xmlXPathContextPtr xctx;
- char query[1024];
- char *n;
-
- dbg_printf("Trying to parse ref tag\n");
- n = (char *)xmlGetProp(curr_node, (xmlChar *)"name");
-
- snprintf(query, sizeof(query), "//define[@name=\"%s\"]", n);
- xctx = xmlXPathNewContext(curr_node->doc);
- assert(xctx);
- xobj = xmlXPathEvalExpression((xmlChar *)query, xctx);
-
- printf("%d nodes match %s\n", xobj->nodesetval->nodeNr, query);
-
- assert(0);
- return NULL;
-}
-#endif
-
-int
-find_objects(xmlNodePtr curr_node,
- struct ldap_object_node **objs,
- struct ldap_attr_node **attrs,
- struct idinfo *ids)
-{
- struct ldap_object_node *obj = NULL;
- int ret = 0;
-
- if (!curr_node)
- /* no objects found */
- return 0;
-
- for (; curr_node; curr_node = curr_node->next) {
- if (curr_node->type != XML_ELEMENT_NODE)
- continue;
- if (!strcasecmp((char *)curr_node->name, "element")) {
- obj = parse_element_tag(curr_node, objs, attrs, ids);
- ret = 1;
- } else {
- dbg_printf("Descend on %s\n", curr_node->name);
- }
-
- if (find_objects(curr_node->xmlChildrenNode,
- objs, attrs, ids)) {
- ret = 1;
- } else if (obj) {
- /*
- * We have an object, but when we
- * looked for children, it did not
- * have any. So, we can omit the
- * requirement for 'cn' in the
- * output LDIF here
- */
- if (obj->need_cn) {
- dbg_printf("Object class %s does not have"
- " any children; not outputting "
- "'MUST ( cn )'\n", obj->name);
- }
- obj->need_cn = 0;
- }
- }
-
- /* Child objects were found */
- return ret;
-}
diff --git a/config/tools/ldap/rng2ldif/tree.h b/config/tools/ldap/rng2ldif/tree.h
deleted file mode 100644
index f55c556..0000000
--- a/config/tools/ldap/rng2ldif/tree.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef _TREE_H
-#define _TREE_H
-
-struct ldap_attr_list {
- struct ldap_attr_node *head, *tail;
-};
-
-struct ldap_attr_node {
- struct ldap_attr_node *next;
- char *name; /* self->idval->name; do not free() */
- char *desc;
- char *ldap_equality;
- char *ldap_syntax;
- struct idval *idval;
-};
-
-struct ldap_attr_meta_node {
- struct ldap_attr_meta_node *next;
- struct ldap_attr_node *node;
-};
-
-struct ldap_object_node {
- struct ldap_object_node *next;
- char *name; /* self->idval->name; do not free() */
- char *desc;
- struct idval *idval;
- struct ldap_attr_meta_node *optional_attrs;
- struct ldap_attr_meta_node *required_attrs;
- int need_cn; /* If we don't have a 'name' or a 'cn' attribute,
- add one when we output the LDIF */
-};
-
-int
-find_objects(xmlNodePtr curr_node,
- struct ldap_object_node **objs,
- struct ldap_attr_node **attrs,
- struct idinfo *ids);
-
-
-#endif
diff --git a/config/tools/ldap/rng2ldif/value-list.c b/config/tools/ldap/rng2ldif/value-list.c
deleted file mode 100644
index 010503a..0000000
--- a/config/tools/ldap/rng2ldif/value-list.c
+++ /dev/null
@@ -1,206 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "value-list.h"
-#include "zalloc.h"
-
-void
-id_insert(struct idinfo *i, struct idval *v)
-{
- if (v->type == ATTR) {
- if (v->value > i->max_attr)
- i->max_attr = v->value;
- if (!v->value)
- v->value = ++i->max_attr;
- } else /* if type == OBJ */ {
- if (v->value > i->max_obj)
- i->max_obj = v->value;
- if (!v->value)
- v->value = ++i->max_obj;
- }
-
- if (!i->head)
- i->head = v;
- if (i->tail)
- i->tail->next = v;
- i->tail = v;
-}
-
-
-struct idval *
-id_find(struct idinfo *oi, const char *val, int type, int id)
-{
- struct idval *v;
-
- if (!val && !id)
- return NULL;
-
- /* linear search */
- for (v = oi->head; v; v = v->next) {
- if (v->type != type)
- continue;
- if (val && !strcmp(val, v->name))
- return v;
- if (id && id == v->value)
- return v;
- }
-
- return NULL;
-}
-
-
-void
-id_dump(struct idinfo *oi, FILE *fp)
-{
- struct idval *v;
-
- fprintf(fp, "# Max attribute value: %d\n", oi->max_attr);
- fprintf(fp, "# Max object class value: %d\n", oi->max_obj);
-
- for (v = oi->head; v; v = v->next) {
- fprintf(fp, "%s,%s,%s,%d\n", v->type==OBJ?"obj":"attr",
- v->name, v->rawname, v->value);
- }
-}
-
-
-
-int
-id_writefile(struct idinfo *oi, char *filename)
-{
- char tmpfn[4096];
- FILE *fp = NULL;
- int fd;
- mode_t oldumask;
-
- oldumask=umask(S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
-
- snprintf(tmpfn, sizeof(tmpfn), "%s.XXXXXX", filename);
- fd = mkstemp(tmpfn);
- umask(oldumask);
- if (fd < 0)
- return -1;
-
- fp = fdopen(fd, "w");
- if (!fp) {
- close(fd);
- unlink(tmpfn);
- return -1;
- }
-
- id_dump(oi, fp);
- fflush(fp);
- fsync(fd);
- fclose(fp);
- close(fd);
-
- /* done */
- rename(tmpfn, filename);
-
- return 0;
-}
-
-
-int
-id_readfile(struct idinfo *oi, char *filename)
-{
- char *c, *valp;
- struct idval *v;
- struct idval *tmp;
- FILE *fp;
- char buf[4096];
- int len, lineno = 0, entries = 0;
-
- if (!filename) {
- perror("no file?");
- return 1;
- }
-
- fp = fopen(filename, "r");
- if (!fp) {
- perror("fopen");
- return 1;
- }
-
- while (fgets(buf, sizeof(buf), fp)) {
- ++lineno;
- if (!strlen(buf))
- continue;
- if (buf[0] == '#')
- continue;
- len = strlen(buf);
- while (buf[len-1] < ' ') {
- buf[len-1] = 0;
- --len;
- }
- v = zalloc(sizeof(*v));
- assert(v);
-
- /* Attribute / object */
- c = strchr(buf, ',');
- if (!c || strlen(c) == 1) {
- fprintf(stderr,
- "%s: Malformed input on line %d: '%s'\n",
- filename, lineno, buf);
- exit(-2);
- }
-
- *c = 0;
- c++;
- if (!strncasecmp(buf, "attr",4)) {
- v->type = ATTR;
- } else if (!strncasecmp(buf, "obj", 3)) {
- v->type = OBJ;
- } else {
- fprintf(stderr, "%s: Unknown type on line %d: '%s'\n",
- filename, lineno, buf);
- exit(-2);
- }
-
- valp = strchr(c, ',');
- if (valp) {
- *valp = 0;
- valp++;
- }
- v->name = strdup(c);
- assert(v->name);
-
- c = valp;
- assert(c);
-
- valp = strchr(c, ',');
- v->value = 0;
- if (valp) {
- *valp = 0;
- valp++;
- if (strlen(valp))
- v->value = atoi(valp);
- }
-
- v->rawname = strdup(c);
- assert(v->rawname);
-
- if (!id_find(oi, v->name, v->type, 0)) {
- tmp = id_find(oi, NULL, v->type, v->value);
- if (tmp) {
- fprintf(stderr, "%s: Duplicate id value: "
- "%d & %d, type %d\n", filename,
- tmp->value, v->value, v->type);
- exit(-1);
- }
- id_insert(oi, v);
- }
-
- ++entries;
- free(v);
- v = NULL;
- }
-
- fclose(fp);
-
- return 0;
-}
diff --git a/config/tools/ldap/rng2ldif/value-list.h b/config/tools/ldap/rng2ldif/value-list.h
deleted file mode 100644
index 2e43326..0000000
--- a/config/tools/ldap/rng2ldif/value-list.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _VALUE_LIST_H
-#define _VALUE_LIST_H
-
-struct idval {
- struct idval *next;
- char *name;
- char *rawname;
- int type;
- int value;
-};
-
-struct idinfo {
- struct idval *head;
- struct idval *tail;
- int max_obj;
- int max_attr;
-};
-
-void id_insert(struct idinfo *i, struct idval *v);
-struct idval * id_find(struct idinfo *oi, const char *val, int type, int id);
-void id_dump(struct idinfo *oi, FILE *fp);
-int id_readfile(struct idinfo *oi, char *filename);
-int id_writefile(struct idinfo *oi, char *filename);
-
-#define OBJ 1
-#define ATTR 0
-
-#endif
diff --git a/config/tools/ldap/rng2ldif/zalloc.c b/config/tools/ldap/rng2ldif/zalloc.c
deleted file mode 100644
index f05306d..0000000
--- a/config/tools/ldap/rng2ldif/zalloc.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <malloc.h>
-#include <string.h>
-#include <assert.h>
-#include "zalloc.h"
-
-void *
-zalloc(size_t size)
-{
- void *ret;
- size_t oddball;
-
- oddball = ( size % sizeof(void *) );
- if (oddball) {
- size -= oddball;
- size += sizeof(void *);
- }
-
- ret = malloc(size);
- if (!ret)
- assert(0);
- memset(ret, 0, size);
- return ret;
-}
diff --git a/config/tools/ldap/rng2ldif/zalloc.h b/config/tools/ldap/rng2ldif/zalloc.h
deleted file mode 100644
index 0992ec2..0000000
--- a/config/tools/ldap/rng2ldif/zalloc.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ZALLOC_H
-#define _ZALLOC_H
-
-void *zalloc(size_t size);
-
-#endif
diff --git a/config/tools/man/Makefile b/config/tools/man/Makefile
deleted file mode 100644
index 5faaf6b..0000000
--- a/config/tools/man/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-MANTARGET= \
- ccs_config_dump.8 \
- ccs_config_validate.8 \
- ccs_update_schema.8 \
- ccs_tool.8 \
- confdb2ldif.8
-
-include ../../../make/defines.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-all:
-
-clean:
diff --git a/config/tools/man/ccs_config_dump.8 b/config/tools/man/ccs_config_dump.8
deleted file mode 100644
index e31d3ce..0000000
--- a/config/tools/man/ccs_config_dump.8
+++ /dev/null
@@ -1,35 +0,0 @@
-.TH "ccs_config_dump" "8" "" "" ""
-.SH "NAME"
-ccs_config_dump \- Tool to generate XML output of running configuration.
-
-.SH "SYNOPSIS"
-.B ccs_config_dump
-[\fIOPTION\fR]..
-
-.SH "DESCRIPTION"
-
-\fBccs_config_dump\fP is part of the Cluster Configuration System (CCS).
-It is used to dump the current running configuration in XML format.
-The running configuration is, sometimes, different from the stored
-configuration on file or ldap because some subsystems store or set
-some default information into the configuration. Those values are
-generally not present on the on-disk version of the configuration
-but are required at runtime for the cluster to work properly.
-
-.SH "OPTIONS"
-.TP
-\fB\-h\fP
-Help. Print out the usage.
-.TP
-\fB\-V\fP
-Print the version information.
-.TP
-\fB\-r\fP
-Force config dump from running cluster. This option is only for expert users
-and debugging sessions. Don't use it for random purposes.
-ccs_config_dump can be configured to use different configuration sources via
-environment variables. This option will clear them to use the default and use
-only the runtime configuration.
-
-.SH "SEE ALSO"
-ccs_config_validate(8), cluster.conf(5)
diff --git a/config/tools/man/ccs_config_validate.8 b/config/tools/man/ccs_config_validate.8
deleted file mode 100644
index ac78178..0000000
--- a/config/tools/man/ccs_config_validate.8
+++ /dev/null
@@ -1,56 +0,0 @@
-.TH CCS_CONFIG_VALIDATE "8" "September 2009"
-.SH NAME
-ccs_config_validate
-.SH DESCRIPTION
-Usage:
-.PP
-ccs_config_validate [options]
-.SH OPTIONS
-.TP
-\fB\-h\fR
-Print this help, then exit
-.TP
-\fB\-V\fR
-Print program version information, then exit
-.TP
-\fB\-v\fR
-Produce verbose output
-.SS "Validating XML configuraton files:"
-.TP
-\fB\-f\fR configfile
-Validate an alternate config file without preloading it with default values.
-.TP
-\fB\-l\fR configfile
-Validate an alternate config file with preloading of default values (recommended option).
-.SS "Advanced options:"
-.TP
-\fB\-u\fR
-Do not update relaxng schema (see ccs_update_schema.8)
-.HP
-.TP
-\fB\-r\fR
-Force validation of runtime config
-.HP
-\fB\-C\fR config_loader
-Override config plugin loader
-.TP
-\fB\-t\fR tempfile
-Force temporay file to tempfile
-.TP
-\fB\-n\fR
-Do not remove temporary file
-.TP
-\fB\-o\fR
-Overwrite temporary file (dangerous)
-.SH "DEFAULT"
-Default operation for ccs_config_validate is to load the currently configured environment
-and verify the outcoming configuration.
-.TP
-Example 1: current environment uses a configuration file (/etc/cluster/cluster.conf).
-The user modifies cluser.conf and executes ccs_config_validate without options.
-The tool will validate the modified cluster.conf after including default values.
-.TP
-Example 2: current environment is set to load the configuration from LDAP. Users
-modifies LDAP databse and before pushing the change to the nodes, she/he can issue
-ccs_config_validate to verify the contents o the LDAP database automatically
-(as long as the correct LDAP environment is set in the cman/cluster sysconfig/defaults files).
diff --git a/config/tools/man/ccs_tool.8 b/config/tools/man/ccs_tool.8
deleted file mode 100644
index 0f52f18..0000000
--- a/config/tools/man/ccs_tool.8
+++ /dev/null
@@ -1,151 +0,0 @@
-.TH "ccs_tool" "8" "" "" ""
-.SH "NAME"
-ccs_tool \- The tool used to make online queries to the cluster configuration.
-
-.SH "SYNOPSIS"
-.B ccs_tool
-[\fIOPTION\fR].. <\fBcommand\fP>
-
-.SH "DESCRIPTION"
-
-\fBccs_tool\fP is part of the Cluster Configuration System (CCS). It used
-to peform different kind of queries to the cluster configuration and has support
-for some cluster.conf editing functions.
-
-.SH "OPTIONS"
-.TP
-\fB\-h\fP
-Help. Print out the usage.
-.TP
-\fB\-V\fP
-Print the version information.
-
-sub\-commands have their own options, see below for more detail
-.SH "COMMANDS"
-
-.TP
-\fBquery\fP \fI<xpath query>\fP
-Perform an xpath query on running cluster configuration.
-
-.TP
-\fBaddnode\fP [options] \fI<node> [<fenceoption=value>]...\fP
-Adds a new node to the cluster configuration file. Fencing device options
-are specified as key=value pairs (as many as required) and are entered into the
-configuration file as is. See the documentation for your fencing agent for more
-details (eg a powerswitch fence device may need to know which port the node is
-connected to).
-.br
-\fIOptions:\fP
-.br
-\-v <votes> Number of votes for this node (mandatory)
-.br
-\-n <nodeid> Node id for this node (optional)
-.br
-\-i <interface> Network interface to use for this node. Mandatory if the cluster
-is using multicast as transport. Forbidden if not.
-.br
-\-m <multicast> Multicast address for cluster. Only allowed on the first node to
-be added to the file. Subsequent nodes will use either multicast or broadcast
-depending on the properties of the first node.
-.br
-\-f <fencedevice> Name of fence device to use for this node. The fence device
-section must already have been added to the file, probably using the addfence command.
-.br
-\-c <file> Config file to use. Defaults to /etc/cluster/cluster.conf
-.br
-\-o <file> Output file. Defaults to the same as -c
-
-
-
-.TP
-\fBdelnode\fP [options] \fI<node>\fP
-Delete a node from the cluster configuration file. Note: there is no
-"edit" command so to change the properties of a node you must delete it
-and add it back in with the new properties.
-.br
-\fIOptions:\fP
-.br
-\-c <file> Config file to use. Defaults to /etc/cluster/cluster.conf
-.br
-\-o <file> Output file. Defaults to the same as -c
-
-
-
-.TP
-\fBaddfence\fP [options] \fI<name> <agent> [<option>=<value>]...\fP
-Adds a new fence device section to the cluster configuration file. <agent> is the
-name of the fence agent that controls the device. the options following are entered
-as key-value pairs. See the fence agent documentation for details about these. eg:
-you may need to enter the IP address and username/password for a powerswitch fencing
-device.
-.br
-\fIOptions:\fP
-.br
-\-c <file> Config file to use. Defaults to /etc/cluster/cluster.conf
-.br
-\-o <file> Output file. Defaults to the same as -c
-
-.TP
-\fBdelfence\fP [options] \fI<node>\fP
-Deletes a fencing device from the cluster configuration file.
-delfence will allow you to remove a fence device that is in use by nodes.
-This is to allow changes to be made, but be aware that it may produce an
-invalid configuration file if you don't add it back in again.
-.br
-\fIOptions:\fP
-.br
-\-c <file> Config file to use. Defaults to /etc/cluster/cluster.conf
-.br
-\-o <file> Output file. Defaults to the same as -