#!/usr/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2018,2019,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r720 src/43haes/usr/sbin/cluster/sa/printServer/sbin/cl_print_server_import.sh 1.2 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2010 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#) 7d4c34b 43haes/usr/sbin/cluster/sa/printServer/sbin/cl_print_server_import.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM #################################################################################################### # # Name: cl_print_server_import # # Print Server Smart Assist import function for adding and removing resources. # # Syntax: # cl_print_server_import [-D | -v] [-M] {-a | -r} -C # -A # -o # -n # -l # -P # # Arguments: # -C Component ID ( System V or PowerPC ) # # -D Turn on debug mode. # # -A Application Name - Smart assistant application identifier # # -v Turn on verbose mode. # # -a Add/change all necessary resources for the print subsystem. # If the resources already exist, they will be removed and then added. # This is the change/modify mode. # # -r Remove all resources for the specified print subsystem. # # -o Print subsystem owning node. This is the node that has the # highest priority. # # -n Print subsystem takeover node(s). These nodes will be appended to the # owning node and then passed to "claddgrp -n". Takeover # nodelist is colon-separated. # # -l The TCP/IP service IP label. # # -M Delete pre-existing configuration (modify mode) # # -P Netmask (IPv4) / Prefix Length (IPv6) # # Returns: # 0 on Success (import completed without error) # 1 on Warning (import completed with warning(s)) # 2 on Failure (import failed due to pre-verification failure) # 3 on Failure (import failed due to failure in adding resource) # #################################################################################################### . /usr/es/lib/ksh93/func_include # : Load the common variables # . /usr/es/sbin/cluster/sa/printServer/sbin/cl_print_server_common_variables #################################################################################################### # Global Definitions: #################################################################################################### RECOVERY_ODM=/tmp/cl_print_server_RemRes_recovery_odm RECOVERY_CMDS=/tmp/cl_print_server_RemRes_recovery_cmds PROGNAME=$(basename ${0}) PATH=$(/usr/es/sbin/cluster/utilities/cl_get_path all) PATH=$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/sbin:/usr/es/sbin/cluster/sa/sbin FPATH_BASE=/usr/es/lib/ksh93 FPATH=$FPATH_BASE/hacmp:$FPATH_BASE/sa:$FPATH_BASE/aix:$FPATH_BASE/aix/odm:$FPATH_BASE/util export PATH FPATH export ODMDIR=/etc/objrepos PRINT_SERVER_SA="/usr/es/sbin/cluster/sa/printServer" PRINT_SERVER_SA_BIN_DIR="$PRINT_SERVER_SA/sbin" MANUAL_CONFIG_SCHEMA="$PRINT_SERVER_SA/config/cl_print_server_manual_config.xsd" export DEBUG=${DEBUG:-"0"} export VERBOSE=${VERBOSE:-"0"} ADD_RESOURCES=0 REMOVE_RESOURCES=0 OWNING_NODE="" TAKEOVER_NODES="" SERVICE_LABEL="" IS_NETWORK_PROVIDED="" NETWORK_NAME="" NETMASK_PREFIX_LEN="" service_ip_label="" sa_type="SA_PrintServer" NODE2STOP="" POWERPC_FILE_COLLECTION_NAME="sa_powerpc_print_file_coll" POWERPC_FILE_COLLECTION_LIST="/etc/qconfig \ /var/spool/lpd \ /var/spool/lpd/qdir \ /var/spool/lpd/stat \ /var/spool/qdaemon" POWERPC_FILESET_LIST="bos.rte.printers \ printers.rte" SYSTEMV_FILE_COLLECTION_NAME="sa_systemv_print_file_coll" SYSTEMV_FILE_COLLECTION_LIST="/etc/lp /etc/lp/fd" SYSTEMV_FILESET_LIST="bos.svprint.rte \ bos.svprint.fonts \ bos.svprint.hpnp \ bos.svprint.ps \ bos.terminfo.svprint.data" VERIFICATION_LIBRARY_NAME="sa_print_subsystem_verification" # : Add or Remove # ACTION="" NUM_ARGS=$# MODIFY_MODE=false #################################################################################################### # # Name: usage # # Description: Prints usage message and exits the program. # # Arguments: N/A # # Returns: N/A # #################################################################################################### function usage { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x KLIB_SA_logmsg INFO 9 2 print_server_sa.cat "Usage: cl_print_server_import -A \n\ \t[-D | -v] {-a | -r}\n\ \t-o -n \n\ \t-l -P -f \n\ \n\ -A Application Name.\n\ -D Turn on debug mode.\n\ -v Turn on verbose mode.\n\ -a Add/change all necessary PowerHA SystemMirror resources for the specified Print subsystem.\n\ If the resources already exist, they will be removed and then added.\n\ This is the change/modify mode.\n\ -r Remove all PowerHA SystemMirror resources for the specified Print subsystem.\n\ -o Print subsystem owning node. This is the node that has the highest priority.\n\ -n Print subsystem takeover node(s). These nodes will be appended to the instance\n\ owning node and then passed to \"claddgrp -n\". Takeover nodelist is colon-separated.\n\ -l The TCP/IP service IP label used by Print subsystem to communicate with other application\n\ tiers and/or clients.\n\ -P Netmask(IPv4)/Prefix Length(IPv6)\n\ -M Delete the pre-existing configuration (modify mode)\n\ -f Input XML file populated with required information\n" exit 1 } #################################################################################################### # Name: RemoveResources # # Description: # Removes (-r) PowerHA SystemMirror resources for Print Server Smart Assist. This function # removes all the PowerHA SystemMirror resources its counterpart function, AddResources # added for Print subsystem. # Entries added by AddResources in the HACMPsa_metadata ODM will also # be cleaned up. # # This function, for the most part, will print out a warning and # continue removing other resources should it fails removing a # particular resource. # # Arguments: N/A # # Returns: # 0 on SUCCESS # 1 on FAILURE #################################################################################################### function RemoveResources { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x REMOVE_ERROR=0 # set to 1 if any of the remove fails key="$APPLICATION_NAME" # : Determine if the Print subsystem resource group exists first prior to removing # typeset group=$(clodmget -q "sa_key=$key and sa_type=$sa_type" -f group \ -d "=" HACMPgroup) group=${group//\"/} [[ -z $group ]] && { KLIB_SA_logmsg INFO 2 2 print_server_sa.cat "%1\$s Print subsystem \ Resource Group doesn't exist.\n" $COMPONENT_ID } [[ -n $group ]] && { # : Remove Resource Group from the PowerHA SystemMirror configuration : All of the metadata will be removed at the time the RG : metadata is removed # clvt delete resource_group $group if (( $? != 0 )); then KLIB_SA_logmsg ERROR 2 8 print_server_sa.cat "Failed removing Print \ subsystem Resource Group from PowerHA SystemMirror\n" REMOVE_ERROR=1 fi } # : Now, we remove all entries from HACMP. : Remove Application Server from the HACMP Configuration # clvt query application "${COMPONENT_ID}_ApplicationServer" > /dev/null 2>&1 if (( $? == 0 )) then clvt delete application "${COMPONENT_ID}_ApplicationServer" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 4 print_server_sa.cat "Failed removing Application Server %1\$s from PowerHA SystemMirror\n" "${COMPONENT_ID}_ApplicationServer" REMOVE_ERROR=1 } else KLIB_SA_logmsg INFO 2 5 print_server_sa.cat "Print subsystem %1\$s is not running on any node\n" "$COMPONENT_ID" fi # : Remove Service IP Label # clvt query service_ip $SERVICE_LABEL > /dev/null 2>&1 if (( $? == 0 )); then clvt delete service_ip $SERVICE_LABEL if (( $? != 0 )); then KLIB_SA_logmsg ERROR 2 6 print_server_sa.cat "Failed removing Print \ subsystem Service IP Label from PowerHA SystemMirror\n" REMOVE_ERROR=1 fi else KLIB_SA_logmsg INFO 2 7 print_server_sa.cat "Print subsystem \ Service IP label doesn't exist.\n" fi # : Remove the file collection # [[ "$COMPONENT_ID" == "PowerPC" ]] && { clvt query file_collection $POWERPC_FILE_COLLECTION_NAME 1>/dev/null 2>&1 (( $? == 0 )) && { clvt delete file_collection $POWERPC_FILE_COLLECTION_NAME (( $? != 0 )) && { KLIB_SA_logmsg ERROR 9999 9999 print_server_sa.cat "Failed removing \ file collection %1\$s" $POWERPC_FILE_COLLECTION_NAME REMOVE_ERROR=1 } } } [[ "$COMPONENT_ID" == "SystemV" ]] && { clvt query file_collection $SYSTEMV_FILE_COLLECTION_NAME 1>/dev/null 2>&1 (( $? == 0 )) && { clvt delete file_collection $SYSTEMV_FILE_COLLECTION_NAME (( $? != 0 )) && { KLIB_SA_logmsg ERROR 9999 9999 print_server_sa.cat "Failed removing \ file collection %1\$s" $SYSTEMV_FILE_COLLECTION_NAME REMOVE_ERROR=1 } } } # : Remove the custom verification library # clvt query method $VERIFICATION_LIBRARY_NAME 1>/dev/null 2>&1 (( $? == 0 )) && { clvt delete method $VERIFICATION_LIBRARY_NAME (( $? != 0 )) && { KLIB_SA_logmsg ERROR 9999 9999 print_server_sa.cat "Failed removing \ custom verfication library %1\$s" $VERIFICATION_LIBRARY_NAME REMOVE_ERROR=1 } } # : Remove the entries from HACMPsa_metadata. # clquerysaapp -a $APPLICATION_NAME >/dev/null 2>&1 (( $? == 0 )) && clrmsaapp -a $APPLICATION_NAME return $REMOVE_ERROR } #################################################################################################### # # Name: StopPowerPCsubsystem # # Description: Checks the $NODE_LIST to make sure PowerPC Print subsystem is not running # anywhere. If found running, an attempt will be made to stop it. # # Arguments: N/A # # Returns: # 0 on SUCCESS # 1 on FAILURE #################################################################################################### function StopPowerPCsubsystem { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x # : The product of these will dictate how long we wait for the : subsystem to stop. We wait up to $TOTAL_SLEEP_TIME seconds for the : subsystem to stop. # typeset -i SLEEP_TIME=5 # in seconds typeset -i SLEEP_CYCLE=120 typeset -i TOTAL_SLEEP_TIME (( TOTAL_SLEEP_TIME = $SLEEP_TIME * $SLEEP_CYCLE )) # : Verify and stop the PowerPC subsystem if running. # for node in $NODE_LIST do cl_rsh $node "/usr/bin/lssrc -s qdaemon | grep -iw active" > /dev/null 2>&1 RC=$? cl_rsh $node "/usr/bin/lssrc -s lpd | grep -iw active" > /dev/null 2>&1 (( $? == 0 || $RC == 0 )) && { NODE2STOP="$node" KLIB_SA_logmsg INFO 2 9 print_server_sa.cat "Stopping %1\$s Print Subsystem on node %2\$s\n" "PowerPC" $NODE2STOP cl_rsh $NODE2STOP "$PRINT_SERVER_SA_BIN_DIR/cl_print_server_powerpc_stop" > /dev/null 2>&1 } done [[ -z $NODE2STOP ]] && { KLIB_SA_logmsg INFO 2 10 print_server_sa.cat "%1\$s Print subsystem is not active on any node\n" "PowerPC" return 0 } # : Check to see if the PowerPC print subsystem is stopped, : if not, cycle through a sleep to give it more time. # while (( $SLEEP_CYCLE > 0 )) do cl_rsh $NODE2STOP "/usr/bin/lssrc -s qdaemon | grep -iw active" > /dev/null 2>&1 RC=$? cl_rsh $NODE2STOP "/usr/bin/lssrc -s lpd | grep -iw active" > /dev/null 2>&1 if (( $? == 0 || $RC == 0 )); then KLIB_SA_logmsg INFO 2 11 print_server_sa.cat "%1\$s Print subsystem on node %2\$s is still running\n" "PowerPC" "$NODE2STOP" KLIB_SA_logmsg INFO 2 12 print_server_sa.cat "Sleeping for %1\$s seconds \(up to a total of %2\$s seconds\)...\n" $TOTAL_SLEEP_TIME $TOTAL_SLEEP_TIME sleep $SLEEP_TIME (( SLEEP_CYCLE = $SLEEP_CYCLE - 1 )) else KLIB_SA_logmsg INFO 2 13 print_server_sa.cat "%1\$s Print subsystem on node \"%2\$s\" is stopped\n" "PowerPC" $NODE2STOP return 0 fi done KLIB_SA_logmsg ERROR 2 14 print_server_sa.cat "Failed stopping %1\$s print subsystem on node \"%2\$s\".\n" "PowerPC" $NODE2STOP return 1 } #################################################################################################### # # Name: StopSystemVsubsystem # # Description: Checks the $NODE_LIST to make sure SystemV Print subsystem is not running # anywhere. If found running, an attempt will be made to stop it. # # Arguments: N/A # # Returns: # 0 on SUCCESS # 1 on FAILURE #################################################################################################### function StopSystemVsubsystem { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x export NODE2STOP="" # : The product of these will dictate how long we wait for the : subsystem to stop. We wait up to $TOTAL_SLEEP_TIME seconds for the : subsystem to stop. # typeset -i SLEEP_TIME=5 # in seconds typeset -i SLEEP_CYCLE=120 typeset -i TOTAL_SLEEP_TIME (( TOTAL_SLEEP_TIME = $SLEEP_TIME * $SLEEP_CYCLE )) # : Verify and stop the System V subsystem if running. # for node in $NODE_LIST do cl_rsh $node "/usr/bin/lpstat -r | grep -i \"is running\"" > /dev/null 2>&1 (( $? == 0 )) && { NODE2STOP="$node" KLIB_SA_logmsg INFO 2 9 print_server_sa.cat "Stopping %1\$s Print Subsystem on node %2\$s\n" "System V" $NODE2STOP cl_rsh $NODE2STOP "$PRINT_SERVER_SA_BIN_DIR/cl_print_server_systemv_stop" > /dev/null 2>&1 } done [[ -z $NODE2STOP ]] && { KLIB_SA_logmsg INFO 2 10 print_server_sa.cat "%1\$s Print subsystem is not active on any node\n" "System V" return 0 } # : Check to see if the System V print subsystem is stopped, : if not, cycle through a sleep to give it more time. # while (( $SLEEP_CYCLE > 0 )) do cl_rsh $NODE2STOP "/usr/bin/lpstat -r | grep -i \"is running\"" > /dev/null 2>&1 if (( $? == 0 )); then KLIB_SA_logmsg INFO 2 11 print_server_sa.cat "%1\$s Print subsystem on node %2\$s is still running\n" "System V" $NODE2STOP KLIB_SA_logmsg INFO 2 12 print_server_sa.cat "Sleeping for %1\$s seconds \(up to a total of %2\$s seconds\)...\n" $TOTAL_SLEEP_TIME $TOTAL_SLEEP_TIME sleep $SLEEP_TIME (( SLEEP_CYCLE = $SLEEP_CYCLE - 1 )) else KLIB_SA_logmsg INFO 2 13 print_server_sa.cat "%1\$s Print subsystem on node %2\$s is stopped\n" "System V" $NODE2STOP return 0 fi done KLIB_SA_logmsg ERROR 2 14 print_server_sa.cat "Failed stopping %1\$s print subsystem on node %2\$s.\n" "System V" $NODE2STOP return 1 } #################################################################################################### # # Name: CheckInputs # # Description: Checks a number of basic conditions and inputs to make sure nothing major is # missing before adding any resources. # # Arguments: N/A # # Returns: # 0 on SUCCESS # 1 on FAILURE # #################################################################################################### function CheckInputs { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x [[ "$COMPONENT_ID" == "SystemV" ]] && component="System V" [[ "$COMPONENT_ID" == "PowerPC" ]] && component="PowerPC" KLIB_SA_logmsg INFO 2 15 print_server_sa.cat "Verifying %1\$s Print subsystem input resources.\n" "$component" # : Make sure the owning node is not also part of the takeover nodes # KLIB_SA_logmsg INFO 2 16 print_server_sa.cat "Verifying the owning node %1\$s is part of takeover node(s) %2\$s list\n" $OWNING_NODE "$TAKEOVER_NODES" # : assuming it is OK # NODE_LIST_OK=1 for i in $TAKEOVER_NODES do [[ "$i" == "$OWNING_NODE" ]] && { NODE_LIST_OK=0 } done (( $NODE_LIST_OK == "0" )) && { KLIB_SA_logmsg ERROR 2 17 print_server_sa.cat "The owning node %1\$s cannot be part of takeover node(s) %2\$s list\n" $OWNING_NODE "$TAKEOVER_NODES" exit 1 } # : Make sure all cluster nodes primary and takeover are valid PowerHA SystemMirror nodes. # KLIB_SA_logmsg INFO 2 18 print_server_sa.cat "Verifying all supplied nodes are valid PowerHA SystemMirror nodes.\n" for node in $OWNING_NODE $TAKEOVER_NODES do KLIB_HACMP_is_known_node $node (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 19 print_server_sa.cat "Node %1\$s is not a cluster node\n" $node KLIB_SA_logmsg ERROR 2 20 print_server_sa.cat "Both owning node and takeover node(s) must be cluster nodes\n" exit 1 } done return 0 } #################################################################################################### # # Function: GenerateRecoveryScript # # Description: Run the recovery script and recover to PIT prior to removal # # Arguments: N/A # # Returns: 0 if successful # !0 if a failure occurred # #################################################################################################### function GenerateRecoveryScript { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset key="$APPLICATION_NAME" typeset group=$(clodmget -q "sa_key=$key and sa_type=$sa_type and group=$RG_NAME" -f group -d "=" HACMPgroup) group=${group//\"/} typeset service_label=$(clodmget -q "name=SERVICE_LABEL and group=$group" -f value -d "=" HACMPresource) service_label=${service_label//\"/} typeset application_server=$(KLIB_HACMP_get_appserver $group) echo "/usr/bin/odmdelete -o HACMPgroup -q group=$group" > $RECOVERY_CMDS echo "/usr/bin/odmdelete -o HACMPresource -q group=$group" >> $RECOVERY_CMDS echo "/usr/bin/odmdelete -o HACMPsa_metadata -q 'application_id=$APPLICATION_NAME'" >> $RECOVERY_CMDS echo "/usr/bin/odmdelete -o HACMPserver -q name=$application_server" >> $RECOVERY_CMDS echo "/usr/bin/odmdelete -o HACMPadapter -q ip_label=$service_label" >> $RECOVERY_CMDS MONITORS=$(LC_ALL=C clvt query application $application_server | \ grep ASSOCIATEDMONITORS | \ awk -F= '{print $2}' | sed -e "s/\"//g") for app_mon in $MONITORS do echo "/usr/bin/odmdelete -o HACMPmonitor -q monitor=$app_mon" >> $RECOVERY_CMDS done echo "/usr/bin/odmdelete -o HACMPcustom -q name=$VERIFICATION_LIBRARY_NAME" >> $RECOVERY_CMDS [[ "$COMPONENT_ID" == "SystemV" ]] && { echo "/usr/bin/odmdelete -o HACMPfilecollection -q name=$SYSTEMV_FILE_COLLECTION_NAME" >> $RECOVERY_CMDS echo "/usr/bin/odmdelete -o HACMPfcfile -q fc_name=$SYSTEMV_FILE_COLLECTION_NAME" >> $RECOVERY_CMDS } [[ "$COMPONENT_ID" == "PowerPC" ]] && { echo "/usr/bin/odmdelete -o HACMPfilecollection -q name=$POWERPC_FILE_COLLECTION_NAME" >> $RECOVERY_CMDS echo "/usr/bin/odmdelete -o HACMPfcfile -q fc_name=$POWERPC_FILE_COLLECTION_NAME" >> $RECOVERY_CMDS } /usr/bin/odmget -q group=$group HACMPgroup > $RECOVERY_ODM /usr/bin/odmget -q group=$group HACMPresource >> $RECOVERY_ODM /usr/bin/odmget -q "application_id=$APPLICATION_NAME" HACMPsa_metadata >> $RECOVERY_ODM /usr/bin/odmget -q "name=$application_server" HACMPserver >> $RECOVERY_ODM /usr/bin/odmget -q "ip_label=$service_label" HACMPadapter >> $RECOVERY_ODM for app_mon in $MONITORS do /usr/bin/odmget -q "monitor=$app_mon" HACMPmonitor >> $RECOVERY_ODM done /usr/bin/odmget -q "name=$VERIFICATION_LIBRARY_NAME" HACMPcustom >> $RECOVERY_ODM [[ "$COMPONENT_ID" == "SystemV" ]] && { /usr/bin/odmget -q "name=$SYSTEMV_FILE_COLLECTION_NAME" HACMPfilecollection >> $RECOVERY_ODM /usr/bin/odmget -q "fc_name=$SYSTEMV_FILE_COLLECTION_NAME" HACMPfcfile >> $RECOVERY_ODM } [[ "$COMPONENT_ID" == "PowerPC" ]] && { /usr/bin/odmget -q "name=$POWERPC_FILE_COLLECTION_NAME" HACMPfilecollection >> $RECOVERY_ODM /usr/bin/odmget -q "fc_name=$POWERPC_FILE_COLLECTION_NAME" HACMPfcfile >> $RECOVERY_ODM } /usr/bin/chmod u+x $RECOVERY_CMDS /usr/bin/chmod u+x $RECOVERY_ODM } #################################################################################################### # # Function: RunRecoveryScript # # Description: Run the recovery script and recover to PIT prior to removal # # Arguments: N/A # # Returns: 0 if successful # !0 if a failure occurred # #################################################################################################### function RunRecoveryScript { set +u [[ "$VERBOSE_LOGGING" == "high" ]] && set -x set -u /usr/bin/ksh93 $RECOVERY_CMDS 2>/dev/null /usr/bin/odmadd $RECOVERY_ODM 2>/dev/null } #################################################################################################### # # Function: RemoveRecoveryScript # # Description: Remove the recovery script files from /tmp/ # prior to exiting # # Arguments: N/A # # Returns: 0 if successful # !0 if a failure occurred # #################################################################################################### function RemoveRecoveryScript { set +u [[ "$VERBOSE_LOGGING" == "high" ]] && set -x set -u /usr/bin/rm -f $RECOVERY_ODM $RECOVERY_CMDS } ############################################################################################### # # Function: verParameterizedPrintServerfileset # # Purpose: Prints a script that will validate the print server fileset # # Arguments: N/A # # Returns: N/A # ############################################################################################### function verParameterizedPrintServerfileset { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x typeset TEST_ROOT=/usr/es/sbin/cluster/etc/config/verify typeset VERIFICATION_FILENAME=${APPLICATION_NAME}"_"${COMPONENT_ID}".ver" typeset localnode=$(get_local_nodename) [[ "$COMPONENT_ID" == "PowerPC" ]] && { echo "#\n# PowerHA SystemMirror PowerPC print subsystem" > $TEST_ROOT/$VERIFICATION_FILENAME echo "# Parameterized Verificiation check" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "# Date: $(date)\n#" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.Name.DefaultName = \"PowerPC\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.MsgCat.ID = 3" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.MsgCat.Set = 1" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.MsgCat.Catalog = \"print_server_sa.cat\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.Nodes = \"S=PRINT_SERVER:A=$APPLICATION_NAME\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "\n#\n# Perform validation for PowerPC print subsystem fileset\n#" >> $TEST_ROOT/$VERIFICATION_FILENAME for fileset in $POWERPC_FILESET_LIST do FILESET_VERSION=$(/usr/bin/lslpp -cl $fileset | tail -1 | cut -d ":" -f 3) echo "HAVerify.Fileset.severity = \"ERROR\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "HAVerify.Fileset.exists[0].name = \"$fileset\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "HAVerify.Fileset.exists[0].version = \"$FILESET_VERSION\"" >> $TEST_ROOT/$VERIFICATION_FILENAME done # : Adding parameterized verification configuration file to file collection # clvt modify file_collection $POWERPC_FILE_COLLECTION_NAME ADD="$TEST_ROOT/$VERIFICATION_FILENAME" \ DESCRIPTION="PowerPC print subsystem configuration info" \ ISPROPOGATEDFILEDURINGSYNC="true" ISPROPOGATEAUTOWHENDETECTED="true" } [[ "$COMPONENT_ID" == "SystemV" ]] && { echo "#\n# PowerHA SystemMirror System V print subsystem" > $TEST_ROOT/$VERIFICATION_FILENAME echo "# Parameterized Verificiation check" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "# Date: $(date)\n#" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.Name.DefaultName = \"System V\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.MsgCat.ID = 2" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.MsgCat.Set = 1" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.MsgCat.Catalog = \"print_server_sa.cat\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "Component.Nodes = \"S=PRINT_SERVER:A=$APPLICATION_NAME\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "\n#\n# Perform validation for System V print subsystem fileset\n#" >> $TEST_ROOT/$VERIFICATION_FILENAME for fileset in $SYSTEMV_FILESET_LIST do FILESET_VERSION=$(/usr/bin/lslpp -cl $fileset | tail -1 | cut -d ":" -f 3) echo "HAVerify.Fileset.severity = \"ERROR\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "HAVerify.Fileset.exists[0].name = \"$fileset\"" >> $TEST_ROOT/$VERIFICATION_FILENAME echo "HAVerify.Fileset.exists[0].version = \"$FILESET_VERSION\"" >> $TEST_ROOT/$VERIFICATION_FILENAME done # : Adding parameterized verification configuration file to file collection # clvt modify file_collection $SYSTEMV_FILE_COLLECTION_NAME ADD="$TEST_ROOT/$VERIFICATION_FILENAME" \ DESCRIPTION="System V print subsystem configuration info" \ ISPROPOGATEDFILEDURINGSYNC="true" ISPROPOGATEAUTOWHENDETECTED="true" } for node in $NODE_LIST; do [[ "$node" != "$localnode" ]] && { cl_rcp $TEST_ROOT/$VERIFICATION_FILENAME \ $node:$TEST_ROOT/$VERIFICATION_FILENAME } done } #################################################################################################### # # Name: AddResources # # Description: # Adds (-a) PowerHA SystemMirror resources for Print subsystem. If the resources # already exist, they will be removed and then added. Entries will # also be added to the HACMPsa_metadata ODM. Application Discovery # will remove the resources constructed by this function # # Arguments: N/A # # Returns: # 0 on SUCCESS # 1 on FAILURE # #################################################################################################### function AddResources { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x # : First remove any pre-existing resources for this application id # RemoveResources (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 21 print_server_sa.cat "Removal of one or more resources failed.\n" return 1 } # : Add an entry into the HACMPsa_metadata ODM for the application id : and SMARTASSIST_ID and COMPONENT_ID # claddsaapp -a "$APPLICATION_NAME" SMARTASSIST_ID='PRINT_SERVER' \ COMPONENT_ID="$COMPONENT" APPLICATION_NAME="$APPLICATION_NAME" # : Create the Service IP Label # if [[ "$IS_NETWORK_PROVIDED" == "true" ]]; then clmgr add service_ip $SERVICE_LABEL NETWORK=$NETWORK_NAME PREFIX=$NETMASK_PREFIX_LEN (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 22 dhcpsa.cat "Failed creating PowerHA SystemMirror Service IP Label" return 1 } else KLIB_SA_add_ServiceLabel $SERVICE_LABEL $NETMASK_PREFIX_LEN || { KLIB_SA_logmsg ERROR 2 22 dhcpsa.cat "Failed creating PowerHA SystemMirror Service IP Label" return 1 } fi # : Remove the application server first, in case it already exists # clvt delete application "${COMPONENT_ID}_ApplicationServer" >/dev/null 2>&1 # : Create the PowerPC Print subsystem Application Server # [[ "$COMPONENT_ID" == "PowerPC" ]] && { claddserv -s $COMPONENT_ID"_ApplicationServer" \ -b "$PRINT_SERVER_SA_BIN_DIR/cl_print_server_powerpc_start" \ -e "$PRINT_SERVER_SA_BIN_DIR/cl_print_server_powerpc_stop" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 23 print_server_sa.cat "Failed creating \ PowerHA SystemMirror Application Server for %1\$s Print subsystem.\n" $COMPONENT_ID return 1 } # : Create the PowerPC Print subsystem SQL Monitor # claddappmon MONITOR_TYPE=user name="${COMPONENT_ID}_SQLMonitor" \ RESOURCE_TO_MONITOR="${COMPONENT_ID}_ApplicationServer" \ INVOCATION='longrunning' \ MONITOR_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_powerpc_monitor" \ MONITOR_INTERVAL='120' \ HUNG_MONITOR_SIGNAL='9' \ STABILIZATION_INTERVAL='240' \ RESTART_COUNT='3' \ RESTART_INTERVAL='1440' \ FAILURE_ACTION='fallover' \ CLEANUP_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_powerpc_stop" \ RESTART_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_powerpc_start" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 24 print_server_sa.cat "Failed creating \ PowerHA SystemMirror SQL Monitor for %1\$s Print subsystem.\n" $COMPONENT_ID return 1 } # : Create the PowerPC Print subsystem Process Monitor # claddappmon MONITOR_TYPE=process name="${COMPONENT_ID}_ProcessMonitor" \ RESOURCE_TO_MONITOR="${COMPONENT_ID}_ApplicationServer" \ INVOCATION='longrunning' \ PROCESSES='writesrv qdaemon lpd' \ PROCESS_OWNER="root" \ INSTANCE_COUNT='1' \ STABILIZATION_INTERVAL='240' \ RESTART_COUNT='3' \ RESTART_INTERVAL='1440' \ FAILURE_ACTION='fallover' \ CLEANUP_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_powerpc_stop" \ RESTART_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_powerpc_start" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 25 print_server_sa.cat "Failed creating \ PowerHA SystemMirror Process Monitor for %1\$s Print subsystem.\n" $COMPONENT_ID return 1 } } # : Create the System V Print subsystem Application Server # [[ "$COMPONENT_ID" == "SystemV" ]] && { claddserv -s $COMPONENT_ID"_ApplicationServer" \ -b "$PRINT_SERVER_SA_BIN_DIR/cl_print_server_systemv_start" \ -e "$PRINT_SERVER_SA_BIN_DIR/cl_print_server_systemv_stop" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 23 print_server_sa.cat "Failed creating \ PowerHA SystemMirror Application Server for %1\$s Print subsystem.\n" $COMPONENT_ID return 1 } # : Create the System V Print subsystem SQL Monitor # claddappmon MONITOR_TYPE=user name="${COMPONENT_ID}_SQLMonitor" \ RESOURCE_TO_MONITOR="${COMPONENT_ID}_ApplicationServer" \ INVOCATION='longrunning' \ MONITOR_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_systemv_monitor" \ MONITOR_INTERVAL='120' \ HUNG_MONITOR_SIGNAL='9' \ STABILIZATION_INTERVAL='240' \ RESTART_COUNT='3' \ RESTART_INTERVAL='1440' \ FAILURE_ACTION='fallover' \ CLEANUP_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_systemv_stop" \ RESTART_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_systemv_start" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 24 print_server_sa.cat "Failed creating \ PowerHA SystemMirror SQL Monitor for %1\$s Print subsystem.\n" $COMPONENT_ID return 1 } # : Create the System V Print subsystem Process Monitor # claddappmon MONITOR_TYPE=process name="${COMPONENT_ID}_ProcessMonitor" \ RESOURCE_TO_MONITOR="${COMPONENT_ID}_ApplicationServer" \ INVOCATION='longrunning' \ PROCESSES='lpNet lpsched' \ PROCESS_OWNER="root" \ INSTANCE_COUNT='1' \ STABILIZATION_INTERVAL='240' \ RESTART_COUNT='3' \ RESTART_INTERVAL='1440' \ FAILURE_ACTION='fallover' \ CLEANUP_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_systemv_stop" \ RESTART_METHOD="$PRINT_SERVER_SA_BIN_DIR/cl_print_server_systemv_start" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 25 print_server_sa.cat "Failed creating \ PowerHA SystemMirror Process Monitor for %1\$s Print subsystem.\n" $COMPONENT_ID return 1 } } # : Create the print subsystem Resource Group # claddgrp -g "$RG_NAME" -n "$NODE_LIST" \ -S 'OHN' -O 'FNPN' -B 'NFB' \ -A $sa_type -K ${APPLICATION_NAME} (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 26 print_server_sa.cat "Failed creating PowerHA \ SystemMirror Resource Group for %1\$s Print subsystem.\n" $COMPONENT_ID return 1 } # : Add the required resources to print : subsystem resource group # clvt modify resource_group "$RG_NAME" \ SERVICE_LABEL="$SERVICE_LABEL" \ APPLICATIONS="${COMPONENT_ID}_ApplicationServer" || { KLIB_SA_logmsg ERROR 2 27 print_server_sa.cat "Failed adding resources to Resource Group\n" return 1 } # : Adding file collections to propagate configuration information : of interested print subsystem across cluster # [[ "$COMPONENT_ID" == "SystemV" ]] && { # : File collection for System V print subsystem configuration information # KLIB_SA_logmsg INFO 2 45 print_server_sa.cat "Adding PowerHA SystemMirror file collection for propagating %1\$s print subsystem configuration information across cluster\n" "$COMPONENT_ID" clfilecollection -o coll -a "$SYSTEMV_FILE_COLLECTION_NAME" -"System V print subsystem configuration info" "yes" "yes" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 42 print_server_sa.cat "Adding file collection failed\n" return 1 } KLIB_SA_logmsg INFO 2 47 print_server_sa.cat "Created \"%1\$s\" PowerHA SystemMirror file collection for %2\$s print subsystem\n" "$SYSTEMV_FILE_COLLECTION_NAME" "$COMPONENT_ID" # : Add required configuration files or directories to : above file collection created # for file in $SYSTEMV_FILE_COLLECTION_LIST do KLIB_SA_logmsg INFO 2 46 print_server_sa.cat "Adding %1\$s to PowerHA SystemMirror file collection created for %2\$s print subsystem\n" "$file" "$COMPONENT_ID" clfilecollection -o file -a "$SYSTEMV_FILE_COLLECTION_NAME" "$file" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 43 print_server_sa.cat "Adding file %1\$s to file collection $2\$s failed\n" "$file" "$SYSTEMV_FILE_COLLECTION_NAME" KLIB_SA_logmsg ERROR 2 44 print_server_sa.cat "Removing file collection %1\$s from PowerHA SystemMirror\n" "$SYSTEMV_FILE_COLLECTION_NAME" clfilecollection -o coll -r "$SYSTEMV_FILE_COLLECTION_NAME" return 1 } done } [[ "$COMPONENT_ID" == "PowerPC" ]] && { # : File collection for PowerPC print subsystem configuration information # KLIB_SA_logmsg INFO 2 45 print_server_sa.cat "Adding PowerHA SystemMirror file collection for propagating %1\$s print subsystem configuration information across cluster\n" "$COMPONENT_ID" clfilecollection -o coll -a "$POWERPC_FILE_COLLECTION_NAME" -"PowerPC print subsystem configuration info" "yes" "yes" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 42 print_server_sa.cat "Adding file collection failed\n" return 1 } KLIB_SA_logmsg INFO 2 47 print_server_sa.cat "Created \"%1\$s\" PowerHA SystemMirror file collection for %2\$s print subsystem\n" "$POWERPC_FILE_COLLECTION_NAME" "$COMPONENT_ID" # : Add required configuration files or directories to : above file collection created # for file in $POWERPC_FILE_COLLECTION_LIST do KLIB_SA_logmsg INFO 2 46 print_server_sa.cat "Adding %1\$s to PowerHA SystemMirror file collection created for %2\$s print subsystem\n" "$file" "$COMPONENT_ID" clfilecollection -o file -a "$POWERPC_FILE_COLLECTION_NAME" "$file" (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 43 print_server_sa.cat "Adding file %1\$s to file collection $2\$s failed\n" "$file" "$POWERPC_FILE_COLLECTION_NAME" KLIB_SA_logmsg ERROR 2 44 print_server_sa.cat "Removing file collection %1\$s from PowerHA SystemMirro\n" "$POWERPC_FILE_COLLECTION_NAME" clfilecollection -o coll -r "$POWERPC_FILE_COLLECTION_NAME" return 1 } done } # # Adding parameterized verification check for respective # print subsystem fileset # verParameterizedPrintServerfileset # # Adding custom verification library to PowerHA SystemMirror verification. # claddcustom -t verify -n $VERIFICATION_LIBRARY_NAME -I "Print Subsystem custom verification" \ -v /usr/es/sbin/cluster/sa/printServer/lib/libverprintServersa.so -m 1 (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 41 print_server_sa.cat "Adding custom verification library \"%1\$s\"\n for print subsystem to PowerHA SystemMirror verification has failed\n" "/usr/es/sbin/cluster/sa/printServer/lib/libverprintServersa.so" return 1 } # : Add custom verification library to HACMPsa_metadata ODM # claddsaapp -a "$APPLICATION_NAME" \ CUSTOM_VERIFICATION_LIBRARY=$VERIFICATION_LIBRARY_NAME || { KLIB_SA_logmsg ERROR 9999 9999 print_server_sa.cat "Failed adding PowerHA SystemMirror custom verfication library to the Meta Database" return 1 } # : Add file collection information to the Meta Database ODM : for PowerPC print subsystem # [[ "$COMPONENT_ID" == "PowerPC" ]] && { claddsaapp -a "$APPLICATION_NAME" \ FILE_COLLECTION=$POWERPC_FILE_COLLECTION_NAME || { KLIB_SA_logmsg ERROR 9999 9999 print_server_sa.cat "Failed adding PowerHA SystemMirror file collection for PowerPC print subsystem to the Meta Database" return 1 } } # : Add file collection information to the Meta Database ODM : for System V print subsystem # [[ "$COMPONENT_ID" == "SystemV" ]] && { claddsaapp -a "$APPLICATION_NAME" \ FILE_COLLECTION=$SYSTEMV_FILE_COLLECTION_NAME || { KLIB_SA_logmsg ERROR 9999 9999 print_server_sa.cat "Failed adding PowerHA SystemMirror file collection for System V print subsystem to the Meta Database" return 1 } } # : Adding SQL Monitor to HACMPsa_metadata ODM # claddsaapp -a "$APPLICATION_NAME" \ SQL_MONITOR="${COMPONENT_ID}_SQLMonitor" || { KLIB_SA_logmsg ERROR 2 28 print_server_sa.cat "Failed adding PowerHA SystemMirror SQL Monitor to the Meta Database\n" return 1 } # : Adding Process Monitor to HACMPsa_metadata ODM # claddsaapp -a $APPLICATION_NAME \ PROCESS_MONITOR="${COMPONENT_ID}_ProcessMonitor" || { KLIB_SA_logmsg ERROR 2 29 print_server_sa.cat "Failed adding PowerHA SystemMirror Process Monitor to the Meta Database\n" return 1 } # : Adding Resource Group information to HACMPsa_metadata ODM # claddsaapp -a $APPLICATION_NAME \ RESOURCE_GROUP="$RG_NAME" || { KLIB_SA_logmsg ERROR 2 30 print_server_sa.cat "Failed adding PowerHA SystemMirror Resource Group to the Meta Database\n" return 1 } # : Adding print subsystem information to HACMPsa_metadata ODM # claddsaapp -a $APPLICATION_NAME \ PRINT_SERVER_SUBSYSTEM="$COMPONENT_ID" || { KLIB_SA_logmsg ERROR 2 31 print_server_sa.cat "Failed adding Print subsystem information to the Meta Database\n" return 1 } return 0 } ################################################################################# # # Name: importConfigFromFile # # Description: # This function will read the supplied config file and create powerHA # SystemMirror resources to configure print subsystem for high availability. # # Arguments: # N/A # # Returns: # 0 - on success # 1 - on failure # ################################################################################# function importConfigFromFile { [[ "$VERBOSE_LOGGING" == "high" ]] && set -x MANUAL_CONFIG="" # : configure=yes, interested in manual configuration mode with input XML file # MANUAL_CONFIG=$(clsaxmlutil -s -x $CONFIG_FILE -m $MANUAL_CONFIG_SCHEMA -t $COMPONENT_ID -a configure) (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 33 print_server_sa.cat "Problem with %1\$s information in XML file supplied.\n" "configure" KLIB_SA_logmsg ERROR 2 32 print_server_sa.cat "Problem with XML configuration file. Ensure a valid XML file supplied.\n" exit 1 } [[ "$MANUAL_CONFIG" != "yes" ]] && { return } # : Finding out primary node information from supplied XML file # primary_node=$(clsaxmlutil -s -x $CONFIG_FILE -m $MANUAL_CONFIG_SCHEMA -t $COMPONENT_ID | grep PrimaryNode) (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 33 print_server_sa.cat "Problem with %1\$s information in XML file supplied.\n" "PrimaryNode" KLIB_SA_logmsg ERROR 2 32 print_server_sa.cat "Problem with XML configuration file. Ensure a valid XML file supplied.\n" exit 1 } primary_node=$(echo $primary_node | cut -d"=" -f2) KLIB_HACMP_is_known_node $primary_node (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 19 print_server_sa.cat "Node %1\$s is not a cluster node\n" "$node" exit 1 } PRIMARY_NODE=$primary_node # : Finding out list of Takeover nodes information from supplied XML file # takover_nodes=$(clsaxmlutil -s -x $CONFIG_FILE -m $MANUAL_CONFIG_SCHEMA -t $COMPONENT_ID | grep TakeoverNodes) (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 33 print_server_sa.cat "Problem with %1\$s information in XML file supplied.\n" "TakeoverNodes" KLIB_SA_logmsg ERROR 2 32 print_server_sa.cat "Problem with XML configuration file. Ensure a valid XML file supplied.\n" exit 1 } takover_nodes=$(echo $takover_nodes | cut -d"=" -f2) takeover_nodes=$(echo $takover_nodes | tr ',' ' ') for tnode in $takeover_nodes do KLIB_HACMP_is_known_node $tnode (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 19 print_server_sa.cat "Node %1\$s is not a cluster node\n" "$node" exit 1 } done TAKEOVER_NODES=$(echo $takeover_nodes | sed -e "s/ /\:/g") # : Find out service IP label information from supplied XML file # addrs=$(clsaxmlutil -s -x $CONFIG_FILE -m $MANUAL_CONFIG_SCHEMA -t $COMPONENT_ID | grep IPAddress_or_name) (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 33 print_server_sa.cat "Problem with %1\$s information in XML file supplied.\n" "IPAddress_or_name" KLIB_SA_logmsg ERROR 2 32 print_server_sa.cat "Problem with XML configuration file. Ensure a valid XML file supplied.\n" exit 1 } addrs=$(echo $addrs | cut -d"=" -f2) SERVICE_LABEL=$addrs # : Find out netmask or prefix length information from supplied XML file # netmask=$(clsaxmlutil -s -x $CONFIG_FILE -m $MANUAL_CONFIG_SCHEMA -t $COMPONENT_ID | grep Prefix_or_Netmask) (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 33 print_server_sa.cat "Problem with %1\$s information in XML file supplied.\n" "Prefix_or_Netmask" KLIB_SA_logmsg ERROR 2 32 print_server_sa.cat "Problem with XML configuration file. Ensure a valid XML file supplied.\n" exit 1 } NETMASK_PREFIX_LEN="" NETMASK_PREFIX_LEN=$(echo $netmask | cut -d"=" -f2) APPLICATION_NAME="SA_PrintServer_$COMPONENT_ID" # : Find out Service Network information from supplied XML file # NETWORK_NAME=$(clsaxmlutil -s -x $CONFIG_FILE -m $MANUAL_CONFIG_SCHEMA -t $COMPONENT_ID | grep Service_Network) (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 33 print_server_sa.cat "Problem with %1\$s information in XML file supplied.\n" "Service_Network" KLIB_SA_logmsg ERROR 2 32 print_server_sa.cat "Problem with XML configuration file. Ensure a valid XML file supplied.\n" exit 1 } NETWORK_NAME=$(echo $NETWORK_NAME | cut -d"=" -f2) ARGUMENTS="-a -v -A $APPLICATION_NAME -l $SERVICE_LABEL -o $PRIMARY_NODE -n $TAKEOVER_NODES -C $COMPONENT_ID" [[ -n $NETMASK_PREFIX_LEN ]] && { ARGUMENTS="$ARGUMENTS -P \"$NETMASK_PREFIX_LEN\"" } [[ -n $NETWORK_NAME ]] && { ARGUMENTS="$ARGUMENTS -N $NETWORK_NAME" } /usr/es/sbin/cluster/sa/printServer/sbin/cl_print_server_import $ARGUMENTS } #################################################################################################### # Main: #################################################################################################### umask -S u=rw,g=,o= (( $NUM_ARGS == 0 )) && usage while getopts DA:C:Mvaro:n:P:l:f:N: option do case $option in D) # : Verbose on + Debug on # VERBOSE=1 DEBUG=1 ;; A) # : application name # APPLICATION_NAME=$OPTARG ;; C) # : Component Identifier either PowerPC or Sysytm V # COMPONENT_ID=$OPTARG [[ "$COMPONENT_ID" == "PowerPC" ]] && COMPONENT="PRINT_SERVER_POWERPC" [[ "$COMPONENT_ID" == "SystemV" ]] && COMPONENT="PRINT_SERVER_SYSTEMV" ;; v) # : Verbose on # VERBOSE=1 ;; a) # : Add Resources # if [[ "$REMOVE_RESOURCES" == "1" ]]; then usage fi ACTION="add" ADD_RESOURCES=1 ;; r) # : Remove Resources # if [[ "$ADD_RESOURCES" == "1" ]]; then usage fi ACTION="remove" REMOVE_RESOURCES=1 ;; o) # : Primary cluster node that owns the print : subsystem # OWNING_NODE=$OPTARG ;; n) # : Standby cluster nodes that is/are capable : of hosting the print subsystem. # TAKEOVER_NODES="$OPTARG" TAKEOVER_NODES=$(echo $TAKEOVER_NODES | sed -e "s/\:/ /g") ;; l) # : Service IP label for print subsystem # SERVICE_LABEL=$OPTARG ;; P) # : Netmask / Prefix Length # NETMASK_PREFIX_LEN=$OPTARG ;; M) # : Delete the pre-existing configuration - modify mode # MODIFY_MODE=true ;; f) # : Manual configuration mode, where input XML file : populated with require information. # MANUAL_CONFIG=true CONFIG_FILE=$OPTARG ;; N) # : User provided network # IS_NETWORK_PROVIDED=true NETWORK_NAME=$OPTARG ;; *) usage esac done # : Before handling anything else, check if we have to configure from XML # if [[ $MANUAL_CONFIG == true ]]; then if [[ ! -f $CONFIG_FILE ]]; then dspmsg -s 51 cluster.cat 26 "Unable to read the configuration file. Please ensure the correct path\n" return 1 fi importConfigFromFile exit 0 fi # : Find out the current active print subsystem # ACTIVE_PRINT_SUBSYSTEM=$(/usr/sbin/switch.prt -d | tail -1) # : Find out user is configuring the print subsystem with PowerHA SystemMirror : same as current active print subsystem # [[ "$COMPONENT_ID" == "SystemV" ]] && { [[ "$ACTIVE_PRINT_SUBSYSTEM" != "SystemV" ]] && { KLIB_SA_logmsg ERROR 2 34 print_server_sa.cat "You are trying to configure \"%1\$s\" Print subsystem with\n PowerHA SystemMirror, but current active print subsystem is \"%2\$s\"\nPlease make sure you are configuring the Print Subsystem\nwhich is currently active.\n" "$COMPONENT_ID" "$ACTIVE_PRINT_SUBSYSTEM" exit 1 } } [[ "$COMPONENT_ID" == "PowerPC" ]] && { [[ "$ACTIVE_PRINT_SUBSYSTEM" != "AIX" ]] && { KLIB_SA_logmsg ERROR 2 34 print_server_sa.cat "You are trying to configure \"%1\$s\" Print subsystem with PowerHA SystemMirror, but current active print subsystem is \"%2\$s\"\n" "AIX" "$ACTIVE_PRINT_SUBSYSTEM" exit 1 } } export NODE_LIST="$OWNING_NODE $TAKEOVER_NODES" RG_NAME="PrintServer_${COMPONENT_ID}_ResourceGroup" if (( $ADD_RESOURCES == 0 )) && (( $REMOVE_RESOURCES == 0 )); then KLIB_SA_logmsg ERROR 2 35 print_server_sa.cat "Missing required argument(s) to import\n" usage fi if [[ "$ACTION" == "add" ]]; then clsapre # : Remove the pre-existing configuration - modify mode # [[ "$MODIFY_MODE" == "true" ]] && { GenerateRecoveryScript set -a eval $(clquerysaapp -a $APPLICATION_NAME RESOURCE_GROUP) set +a service_ip_label=$(clodmget -q "name=SERVICE_LABEL and group=$RESOURCE_GROUP" -f value -d "=" HACMPresource) service_ip_label=${service_ip_label//\"/} [[ -n $service_ip_label ]] && clvt delete service_ip $service_ip_label clvt delete resource_group $RESOURCE_GROUP clrmsaapp -a $APPLICATION_NAME } # : Check to ensure another resource group with the same application name has not been : created # clquerysaapp -a $APPLICATION_NAME > /dev/null 2>&1 (( $? == 0 )) && { KLIB_SA_logmsg ERROR 2 36 print_server_sa.cat "Please choose a different application name, as configuration is already exist with the application name \"%1\$s\"\n" "$APPLICATION_NAME" exit 1 } # : Determine if the print subsystem we are attempting to add is already part of an : PowerHA SystemMirror configuration # application=$(clodmget -q "name=PRINT_SERVER_SUBSYSTEM and value=$COMPONENT_ID" \ -f application_id -d "=" HACMPsa_metadata) application=${application//\"/} [[ -n $application ]] && { KLIB_SA_logmsg ERROR 2 37 print_server_sa.cat "The %1\$s Print subsystem is already defined to the PowerHA SystemMirror\n cluster configuration with application \"%2\$s\"\n" $COMPONENT_ID $application exit 1 } # : PowerPC and System V print subsystem both cannot be active at any point of time. : Find here if PowerPC print subsystem already exists while adding System V and : vice versa. # [[ "$COMPONENT_ID" == "SystemV" ]] && { application="" application=$(clodmget -q "name=PRINT_SERVER_SUBSYSTEM and value=PowerPC" \ -f application_id -d "=" HACMPsa_metadata) application=${application//\"/} [[ -n $application ]] && { KLIB_SA_logmsg ERROR 9999 9999 print_server_sa.cat "The %1\$s print subsystem configuration with PowerHA SystemMirror already exists.\nThe print subsystems, PowerPC and System V, both cannot be active at any point of time." "PowerPC" exit 1 } } [[ "$COMPONENT_ID" == "PowerPC" ]] && { application="" application=$(clodmget -q "name=PRINT_SERVER_SUBSYSTEM and value=SystemV" \ -f application_id -d "=" HACMPsa_metadata) application=${application//\"/} [[ -n $application ]] && { KLIB_SA_logmsg ERROR 9999 9999 print_server_sa.cat "The %1\$s print subsystem configuration with PowerHA SystemMirror already exists.\nThe print subsystems, PowerPC and System V, both cannot be active at any point of time." "SystemV" exit 1 } } # : System V Print subsystem # [[ "$COMPONENT_ID" == "SystemV" ]] && { # : Stop the System V Print subsystem, if active. # StopSystemVsubsystem (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 38 print_server_sa.cat "%1\$s Print subsystem on node \"%2\$s\" should be manually stopped before continuing\n" "$COMPONENT_ID" "$NODE2STOP" exit 1 } } # : PowerPC Print subsystem # [[ "$COMPONENT_ID" == "PowerPC" ]] && { # : Stop the PowerPC Print subsystem, if active. # StopPowerPCsubsystem (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 38 print_server_sa.cat "%1\$s Print subsystem on node \"%2\$s\" should be manually stopped before continuing\n" "$COMPONENT_ID" "$NODE2STOP" exit 1 } } # : Verify the input information # CheckInputs (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 39 print_server_sa.cat "Validation of one or more required resources failed\n" exit 1 } # : Create and Add required resources to resource group # AddResources (( $? != 0 )) && { KLIB_SA_logmsg ERROR 2 40 print_server_sa.cat "Resource creation or adding required resources to resource group failed.\n" # : Remove the resources from configuration created so far. # RemoveResources [[ "$MODIFY_MODE" == "true" ]] && { KLIB_SA_logmsg INFO 9999 9999 print_server_sa.cat "Restoring original configuration as modification of the configuration encountered some errors." RunRecoveryScript 1>/dev/null 2>&1 RemoveRecoveryScript } exit 1 } [[ "$MODIFY_MODE" == "true" ]] && RemoveRecoveryScript # : Run the verification after application instance is added # clsapost -v (( $? != 0 )) && exit 1 else KLIB_SA_logmsg ERROR 2 1 print_server_sa.cat "Unexpected Print Server import action encountered\n" exit 1 fi exit 0