4 # Copyright (C) 2010, 2011 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 daemon_util=daemons/daemon-util
31 if ! grep -q '^ENABLE_CONFD = ' lib/_autoconf.py; then
32 err "Please update $0, confd enable feature is missing"
35 if ! grep -q '^ENABLE_MOND = ' lib/_autoconf.py; then
36 err "Please update $0, mond enable feature is missing"
39 DAEMONS_LIST="noded masterd rapi"
40 STOPDAEMONS_LIST="rapi masterd noded"
42 if grep -q '^ENABLE_CONFD = True' lib/_autoconf.py; then
43 DAEMONS_LIST="$DAEMONS_LIST confd queryd"
44 STOPDAEMONS_LIST="queryd confd $STOPDAEMONS_LIST"
47 if grep -q '^ENABLE_MOND = True' lib/_autoconf.py; then
48 DAEMONS_LIST="$DAEMONS_LIST mond"
49 STOPDAEMONS_LIST="mond $STOPDAEMONS_LIST"
52 DAEMONS=$(echo $(for d in $DAEMONS_LIST; do echo "ganeti-$d"; done))
53 STOPDAEMONS=$(echo $(for d in $STOPDAEMONS_LIST; do echo "ganeti-$d"; done))
55 $daemon_util >/dev/null 2>&1 &&
56 err "daemon-util succeeded without command"
58 $daemon_util this-is-an-unimplemented-command >/dev/null 2>&1 &&
59 err "daemon-util accepted unimplemented command"
61 $daemon_util list_start_daemons >/dev/null 2>&1 &&
62 err "daemon-util accepted command with underscores"
64 $daemon_util check-exitcode 0 ||
65 err "check-exitcode 0 failed"
67 for i in 1 2 3 4 20 25 33; do
68 $daemon_util check-exitcode $i >/dev/null 2>&1 && rc=0 || rc=$?
69 test "$rc" == 1 || err "check-exitcode $i didn't return 1"
72 $daemon_util check-exitcode 11 >/dev/null 2>&1 ||
73 err "check-exitcode 11 (not master) didn't return 0"
75 tmp=$(echo $($daemon_util list-start-daemons))
76 test "$tmp" == "$DAEMONS" ||
77 err "list-start-daemons didn't return correct list of daemons"
79 tmp=$(echo $($daemon_util list-stop-daemons))
80 test "$tmp" == "$STOPDAEMONS" ||
81 err "list-stop-daemons didn't return correct list of daemons"
83 $daemon_util is-daemon-name >/dev/null 2>&1 &&
84 err "is-daemon-name didn't require daemon name"
86 for i in '' '.' '..' '-' 'not-a-daemon'; do
87 $daemon_util is-daemon-name "$i" >/dev/null 2>&1 &&
88 err "is-daemon-name thinks '$i' is a daemon name"
92 $daemon_util is-daemon-name $i >/dev/null 2>&1 ||
93 err "is-daemon-name doesn't think '$i' is a daemon name"