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_CONFD = True' lib/_autoconf.py; then
36 DAEMONS="$(echo ganeti-{noded,masterd,rapi,confd})"
37 STOPDAEMONS="$(echo ganeti-{confd,rapi,masterd,noded})"
39 DAEMONS="$(echo ganeti-{noded,masterd,rapi})"
40 STOPDAEMONS="$(echo ganeti-{rapi,masterd,noded})"
43 $daemon_util >/dev/null 2>&1 &&
44 err "daemon-util succeeded without command"
46 $daemon_util this-is-an-unimplemented-command >/dev/null 2>&1 &&
47 err "daemon-util accepted unimplemented command"
49 $daemon_util list_start_daemons >/dev/null 2>&1 &&
50 err "daemon-util accepted command with underscores"
52 $daemon_util check-exitcode 0 ||
53 err "check-exitcode 0 failed"
55 for i in 1 2 3 4 20 25 33; do
56 $daemon_util check-exitcode $i >/dev/null 2>&1 && rc=0 || rc=$?
57 test "$rc" == 1 || err "check-exitcode $i didn't return 1"
60 $daemon_util check-exitcode 11 >/dev/null 2>&1 ||
61 err "check-exitcode 11 (not master) didn't return 0"
63 tmp=$(echo $($daemon_util list-start-daemons))
64 test "$tmp" == "$DAEMONS" ||
65 err "list-start-daemons didn't return correct list of daemons"
67 tmp=$(echo $($daemon_util list-stop-daemons))
68 test "$tmp" == "$STOPDAEMONS" ||
69 err "list-stop-daemons didn't return correct list of daemons"
71 $daemon_util is-daemon-name >/dev/null 2>&1 &&
72 err "is-daemon-name didn't require daemon name"
74 for i in '' '.' '..' '-' 'not-a-daemon'; do
75 $daemon_util is-daemon-name "$i" >/dev/null 2>&1 &&
76 err "is-daemon-name thinks '$i' is a daemon name"
80 $daemon_util is-daemon-name $i >/dev/null 2>&1 ||
81 err "is-daemon-name doesn't think '$i' is a daemon name"