5 not_implemented_exit_code=1
12 A fake CTDB stub that prints items depending on the variables
13 FAKE_CTDB_PNN (default 0) depending on command-line options.
15 Note that -Y is ignored.
18 exit $not_implemented_exit_code
21 # Don't set $POSIXLY_CORRECT here.
22 _temp=$(getopt -n "$prog" -o "Yvh" -l help -- "$@") || \
32 -v) verbose=true ; shift ;;
34 -h|--help|*) usage ;; # * shouldn't happen, so this is reasonable.
42 # Make sure tickles file exists.
43 tickles_file="$CTDB_VARDIR/fake-ctdb/tickles"
44 mkdir -p $(dirname "$tickles_file")
50 pstore_dir="$CTDB_VARDIR/fake-ctdb/pstore/$1"
51 mkdir -p "$pstore_dir"
54 # For testing backward compatibility...
55 for i in $CTDB_NOT_IMPLEMENTED ; do
56 if [ "$i" = "$1" ] ; then
57 echo "${prog}: command \"$i\" not implemented" >&2
64 # NOTE: all nodes share the same public addresses file.
66 # This is completely stateless and IPs move unnecessarily.
67 _f="${CTDB_PUBLIC_ADDRESSES:-${CTDB_BASE}/public_addresses}"
68 if [ -f "$_f" ] ; then
70 echo ":Public IP:Node:ActiveInterface:AvailableInterfaces:ConfiguredInterfaces:"
73 echo ":Public IP:Node:"
75 # Here IPs are distributed across nodes in a stupid way...
77 while read _ip _ifaces ; do
81 # Find a node that is up... but don't loop forever.
83 while [ -f "${FAKE_CTDB_NODES_DOWN}/${_n}" ] ; do
85 if [ _n -eq $FAKE_CTDB_NUMNODES ] ; then
88 if [ $_n -eq $_orig ] ; then
89 _n=-1 # Never down! :-)
93 # If more than 1 interface, assume all
94 # addresses are on the 1st.
95 _first_iface="${_ifaces%%,*}"
96 # Only show interface if address is on
99 if [ "PNN:$_n" = $(ctdb -Y pnn) ]; then
100 _my_iface="$_first_iface"
102 echo ":${_ip}:${_n}:${_my_iface}:${_first_iface}:${_ifaces}:"
104 echo ":${_ip}:${_n}:"
112 echo "PNN:${FAKE_CTDB_PNN:-0}"
116 echo ":source ip:port:destination ip:port:"
117 while read src dst ; do
118 echo ":${src}:${dst}:"
119 done <"$tickles_file"
123 echo "$2 $3" >>"$tickles_file"
127 _t=$(grep -F -v "$2 $3" "$tickles_file")
128 echo "$_t" >"$tickles_file"
132 cat "$4" >"${pstore_dir}/$3"
136 cat "${pstore_dir}/$3" >"$4" 2>/dev/null
140 echo ":Name:LinkStatus:References:"
141 _f="${CTDB_PUBLIC_ADDRESSES:-${CTDB_BASE}/public_addresses}"
142 if [ -r "$_f" ] ; then
143 while read _ip _iface ; do
148 # For now assume _iface contains only 1.
149 if [ -f "{FAKE_CTDB_IFACES_DOWN}/${_iface}" ] ; then
152 # Nobody looks at references
153 echo ":${_iface}:${_status}:0"
160 # Existence of file means CTDB thinks interface is down.
161 _f="${FAKE_CTDB_IFACES_DOWN}/$2"
166 echo "ctdb setifacelink: unsupported interface status $3"
171 case "$CTDB_DEBUGLEVEL" in
185 :${_t}:${CTDB_DEBUGLEVEL}:
189 for _i in $FAKE_TCP_LISTEN ; do
190 if [ "$2" = "${_i##*:}" ] ; then
198 echo "${prog}: command \"$1\" not implemented in stub"