done
}
+node_is_ctdb_node_DEFAULT ()
+{
+ echo 0
+}
+
hack_one_node_with ()
{
local filter="$1" ; shift
# the same disk.
hack_disk_hooks=""
+create_node_DEFAULT ()
+{
+ local type="$1"
+ local ip_offset="$2"
+ local name="$3"
+ local ctdb_node="$4"
+
+ echo "Creating node \"$name\" (of type \"${type}\")"
+
+ create_node_COMMON "$name" "$ip_offset" "$type"
+}
+
# common node creation stuff
create_node_COMMON ()
{
##############################
-hack_nodes_functions=
-
-expand_nodes () {
+expand_nodes ()
+{
# Expand out any abbreviations in NODES.
local ns=""
local n
done
NODES="$ns"
- # Apply nodes hacks. Some of this is about backward compatibility
- # but the hacks also fill in the node names and whether they're
- # part of the CTDB cluster. The order is the order that
- # configuration modules register their hacks.
- run_hooks hack_nodes_functions
-
# Check IP addresses for duplicates.
local ip_offsets=":"
# This function doesn't modify anything...
ip_offsets="${ip_offsets}${ip_offset}:"
}
hack_all_nodes_with get_ip_offset
+
+ # Determine node names and whether they're in the CTDB cluster
+ declare -A node_count
+ _get_name_ctdb_node ()
+ {
+ local count=$((${node_count[$node_type]:-0} + 1))
+ node_count[$node_type]=$count
+ local fmt
+ fmt=$(call_func node_name_format "$node_type") || \
+ die "Node type \"${node_type}\" not defined!!!"
+ # printf behaves weirdly if given too many args for format, so
+ # "head" handles the case where there is no %d or similar for
+ # $count.
+ name=$(printf "${fmt}" "$CLUSTER" $count | head -n 1)
+ ctdb_node=$(call_func node_is_ctdb_node "$node_type")
+ }
+ hack_all_nodes_with _get_name_ctdb_node
}
##############################
local sname=""
local hosts_line
local ip_addr="${NETWORK_PRIVATE_PREFIX}.$(($FIRSTIP + $ip_offset))"
-
+
+ # Primary name for CTDB nodes is <CLUSTER>n<num>
if [ "$ctdb_node" = 1 ] ; then
num_ctdb_nodes=$(($num_ctdb_nodes + 1))
sname="${CLUSTER}n${num_ctdb_nodes}"
##############################
-register_hook hack_nodes_functions hack_nodes_rhel_base
-
-hack_nodes_rhel_base ()
-{
- local node_count_rhel_base=0
- hack_filter ()
- {
- case "$node_type" in
- rhel_base)
- node_count_rhel_base=$(($node_count_rhel_base + 1))
- name="${CLUSTER}base${node_count_rhel_base}"
- # rhel_base nodes are not part of CTDB cluster
- ctdb_node=0
- esac
- }
- hack_all_nodes_with hack_filter
-}
-
-create_node_rhel_base ()
-{
- local ip_offset="$1"
- local name="$2"
- local ctdb_node="$3"
-
- echo "Creating RHEL base node $name"
- create_node_COMMON "$name" "$ip_offset" "$type"
-}
-
-##############################
-
# Authentication method
defconf AUTH_METHOD "files" \
"files|winbind" "authentication method"
# Hey Emacs, this is a -*- shell-script -*- !!!
-hack_nodes_nas ()
+node_name_format_nas ()
{
- local node_count_nas=0
- hack_filter ()
- {
- if [ "$node_type" = "nas" ] ; then
- node_count_nas=$(($node_count_nas + 1))
- name="${CLUSTER}nas${node_count_nas}"
- ctdb_node=1
- fi
- }
- hack_all_nodes_with hack_filter
+ echo '%snas%d'
}
-register_hook hack_nodes_functions hack_nodes_nas
-
-create_node_nas ()
+node_is_ctdb_node_nas ()
{
- local ip_offset="$1"
- local name="$2"
- local ctdb_node="$3"
-
- echo "Creating NAS node $name"
-
- create_node_COMMON "$name" "$ip_offset" "$type"
+ echo 1
}
node_has_shared_disks_nas ()
--- /dev/null
+# Hey Emacs, this is a -*- shell-script -*- !!!
+
+node_name_format_rhel_base ()
+{
+ echo '%sbase%d'
+}
# Hey Emacs, this is a -*- shell-script -*- !!!
-create_node_build ()
+node_name_format_build ()
{
- local ip_offset="$1"
- local name="$2"
- local ctdb_node="$3"
-
- echo "Creating build node $name"
-
- create_node_COMMON "$name" "$ip_offset" "$type"
+ echo '%sbuild%d'
}
cluster_setup_tasks_build ()
NODES_STORAGE_GPFS=
-hack_nodes_storage_gpfs ()
+node_name_format_storage_gpfs ()
{
- local node_count_storage_gpfs=0
- hack_filter ()
- {
- if [ "$node_type" = "storage_gpfs" ] ; then
- node_count_storage_gpfs=$(($node_count_storage_gpfs + 1))
- name="${CLUSTER}storage${node_count_storage_gpfs}"
- ctdb_node=0
- local ld=$(echo $DOMAIN | tr 'A-Z' 'a-z')
- NODES_STORAGE_GPFS="${NODES_STORAGE_GPFS}${NODES_STORAGE_GPFS:+,}${name}.${ld}"
- fi
- }
- hack_all_nodes_with hack_filter
+ echo '%sstorage%d'
}
-register_hook hack_nodes_functions hack_nodes_storage_gpfs
-
create_node_storage_gpfs ()
{
local ip_offset="$1"
local name="$2"
local ctdb_node="$3"
- echo "Creating GPFS storage node $name"
+ local ld=$(echo $DOMAIN | tr 'A-Z' 'a-z')
+ NODES_STORAGE_GPFS="${NODES_STORAGE_GPFS}${NODES_STORAGE_GPFS:+,}${name}.${ld}"
+
+ echo "Creating node \"${name}\" (of type \"storage_gpfs\")"
create_node_COMMON "$name" "$ip_offset" "$type"
}
defconf AD_NETBIOS_NAME "samba4" \
"<string>" "NetBIOS name to use for AD server"
+node_name_format_ad ()
+{
+ echo '%sad%d'
+}
+
cluster_setup_tasks_ad ()
{
case "$1" in
# TSM server node type
-register_hook hack_nodes_functions hack_nodes_tsm_server
-
-hack_nodes_tsm_server ()
+node_name_format_tsm ()
{
- local node_count_tsm_server=0
# If only 1 tsm_server node then don't number it.
- [ "${NODES/tsm_server:/}" = "${NODES//tsm_server:/}" ] && \
- node_count_tsm_server=""
- hack_filter ()
- {
- if [ "$node_type" = "tsm_server" ] ; then
- [ -n "$node_count_tsm_server" ] && \
- node_count_tsm_server=$(($node_count_tsm_server + 1))
- name="${CLUSTER}tsm${node_count_tsm_server}"
- ctdb_node=0
- fi
- }
- hack_all_nodes_with hack_filter
+ if [ "${NODES/tsm_server:/}" = "${NODES//tsm_server:/}" ] ; then
+ echo '%stsm'
+ else
+ echo '%stsm%d'
+ fi
}
create_node_tsm_server ()
# template needs the value of TSMDISK.
TSMDISK="${VIRTBASE}/${CLUSTER}/${name}storage.qcow2"
- echo "Creating TSM server node $name"
+ echo "Creating node \"${name}\" (of type \"tsm_server\""
create_node_COMMON "$name" "$ip_offset" "$type" "$TSM_TEMPLATE"
local di="$TSMDISK"
di=$(readlink "$TSMDISK")
fi
- echo "Creating tsm disk"
+ echo "Creating TSM disk"
qemu-img create -f qcow2 "$di" $TSMDISKSIZE
echo