[16] | 1 | #!/bin/ksh |
---|
| 2 | # IBM_PROLOG_BEGIN_TAG |
---|
| 3 | # This is an automatically generated prolog. |
---|
| 4 | # |
---|
| 5 | # |
---|
| 6 | # |
---|
| 7 | # Licensed Materials - Property of IBM |
---|
| 8 | # |
---|
| 9 | # (C) COPYRIGHT International Business Machines Corp. 1998,2005 |
---|
| 10 | # All Rights Reserved |
---|
| 11 | # |
---|
| 12 | # US Government Users Restricted Rights - Use, duplication or |
---|
| 13 | # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. |
---|
| 14 | # |
---|
| 15 | # IBM_PROLOG_END_TAG |
---|
| 16 | # @(#)01 1.38 src/avs/fs/mmfs/ts/admin/mmlsnode.sh, mmfs, avs_rgpfs24, rgpfs240610b 10/3/05 11:59:22 |
---|
| 17 | ########################################################################## |
---|
| 18 | # |
---|
| 19 | # List the names of the nodes that belong to a GPFS nodeset. |
---|
| 20 | # |
---|
| 21 | # Usage: mmlsnode { -C nodesetId | -a | -n nodename } |
---|
| 22 | # |
---|
| 23 | # where |
---|
| 24 | # nodesetId is the name of the nodeset whose nodes are to be listed |
---|
| 25 | # -C display the names of the nodes that belong to nodesetId |
---|
| 26 | # -a display the names of all nodes in all GPFS nodesets |
---|
| 27 | # -n display the names of the nodes that belong to the same nodeset |
---|
| 28 | # as nodename |
---|
| 29 | # |
---|
| 30 | ########################################################################## |
---|
| 31 | |
---|
| 32 | # Include global declarations and service routines. |
---|
| 33 | . /usr/lpp/mmfs/bin/mmglobfuncs |
---|
| 34 | . /usr/lpp/mmfs/bin/mmsdrfsdef |
---|
| 35 | |
---|
| 36 | sourceFile="mmlsnode.sh" |
---|
| 37 | [[ -n $DEBUG || -n $DEBUGmmlsnode ]] && set -x |
---|
| 38 | $mmTRACE_ENTER "$*" |
---|
| 39 | |
---|
| 40 | # Local work files. Names should be of the form: |
---|
| 41 | # fn=${tmpDir}fn.${mmcmd}.$$ |
---|
| 42 | |
---|
| 43 | LOCAL_FILES=" " |
---|
| 44 | |
---|
| 45 | # Local variables |
---|
| 46 | nodesetId=$GLOBAL_ID |
---|
| 47 | allOpt="" |
---|
| 48 | nOpt="" |
---|
| 49 | COpt="" |
---|
| 50 | nodeName="" |
---|
| 51 | usageMsg=184 |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | ################################ |
---|
| 55 | # Check the input arguments. |
---|
| 56 | ################################ |
---|
| 57 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ |
---|
| 58 | syntaxError "help" $usageMsg |
---|
| 59 | |
---|
| 60 | while getopts :an:C: OPT |
---|
| 61 | do |
---|
| 62 | case $OPT in |
---|
| 63 | |
---|
| 64 | a) # display all nodesets in the sdr |
---|
| 65 | [[ -n $allOpt ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
| 66 | allOpt="-a" |
---|
| 67 | [[ -n $nOpt ]] && \ |
---|
| 68 | syntaxError "invalidCombination" $usageMsg "-a" "-n" |
---|
| 69 | [[ -n $COpt ]] && \ |
---|
| 70 | syntaxError "invalidCombination" $usageMsg "-a" "-C" |
---|
| 71 | ;; |
---|
| 72 | |
---|
| 73 | n) # display the nodes in the nodeset of the specified node |
---|
| 74 | [[ -n $nOpt ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
| 75 | nOpt="-n" |
---|
| 76 | nodeName=$OPTARG |
---|
| 77 | [[ -n $allOpt ]] && \ |
---|
| 78 | syntaxError "invalidCombination" $usageMsg "-a" "-n" |
---|
| 79 | [[ -n $COpt ]] && \ |
---|
| 80 | syntaxError "invalidCombination" $usageMsg "-C" "-n" |
---|
| 81 | ;; |
---|
| 82 | |
---|
| 83 | C) # display the nodes for the specified nodeset |
---|
| 84 | [[ -n $COpt ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
| 85 | COpt="-C" |
---|
| 86 | nodesetId=$OPTARG |
---|
| 87 | [[ -n $allOpt ]] && \ |
---|
| 88 | syntaxError "invalidCombination" $usageMsg "-a" "-C" |
---|
| 89 | [[ -n $nOpt ]] && \ |
---|
| 90 | syntaxError "invalidCombination" $usageMsg "-C" "-n" |
---|
| 91 | ;; |
---|
| 92 | |
---|
| 93 | :) syntaxError "missingValue" $usageMsg $OPTARG |
---|
| 94 | ;; |
---|
| 95 | |
---|
| 96 | +[aCn]) syntaxError "invalidOption" $usageMsg "$OPT" |
---|
| 97 | ;; |
---|
| 98 | |
---|
| 99 | *) syntaxError "invalidOption" $usageMsg $OPTARG |
---|
| 100 | ;; |
---|
| 101 | |
---|
| 102 | esac |
---|
| 103 | done |
---|
| 104 | |
---|
| 105 | shift OPTIND-1 |
---|
| 106 | [[ $# -ne 0 ]] && syntaxError "extraArg" $usageMsg $1 |
---|
| 107 | [[ $argc -eq 0 ]] && allOpt="-a" # assume -a if nothing else is specified |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | ####################################################################### |
---|
| 111 | # Set up trap exception handling and call the gpfsInit function. |
---|
| 112 | # It will ensure that the local copy of the mmsdrfs and the rest of |
---|
| 113 | # the GPFS system files are up-to-date. There is no need to lock |
---|
| 114 | # the sdr. |
---|
| 115 | ####################################################################### |
---|
| 116 | trap pretrap2 HUP INT QUIT KILL |
---|
| 117 | gpfsInitOutput=$(gpfsInit nolock) |
---|
| 118 | setGlobalVar $? $gpfsInitOutput |
---|
| 119 | |
---|
| 120 | # If the nodeset id was not explicitly specified, |
---|
| 121 | # use the default nodeset returned from gpfsInit. |
---|
| 122 | [[ $nodesetId = "." ]] && \ |
---|
| 123 | nodesetId=$nsId |
---|
| 124 | |
---|
| 125 | if [[ $nodesetId = 0 ]] |
---|
| 126 | then |
---|
| 127 | print -u2 "$mmcmd: The nodeset can not be determined. Use the -C <nodesetId> option," |
---|
| 128 | print -u2 "or issue the command from a node that belongs to the desired nodeset." |
---|
| 129 | cleanupAndExit |
---|
| 130 | fi |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | ######################################################################## |
---|
| 134 | # If -n was specified, find the name of the nodeset that contains |
---|
| 135 | # the specified node. To do this reliably, we first convert the name |
---|
| 136 | # into a node number. |
---|
| 137 | ######################################################################## |
---|
| 138 | if [[ -n $nOpt ]] |
---|
| 139 | then |
---|
| 140 | |
---|
| 141 | # Find the IP address that corresponds to this node name. |
---|
| 142 | hostResult=$($host $nodeName) |
---|
| 143 | set -f ; set -- $hostResult ; set +f |
---|
| 144 | ipa=${3%%,*} # Exclude everything after the first comma. |
---|
| 145 | if [[ -z $ipa ]] |
---|
| 146 | then |
---|
| 147 | # Invalid node name specified |
---|
| 148 | printErrorMsg 54 $mmcmd $nodeName |
---|
| 149 | cleanupAndExit |
---|
| 150 | fi |
---|
| 151 | |
---|
| 152 | # Find the nodeset to which this node number belongs. |
---|
| 153 | nodesetId=$($awk -F: ' \ |
---|
| 154 | /':$MEMBER_NODE:'/ { \ |
---|
| 155 | if ($'$IPA_Field' == "'$ipa'") { \ |
---|
| 156 | { print $'$NODESETID_Field' } \ |
---|
| 157 | { exit } \ |
---|
| 158 | } \ |
---|
| 159 | } \ |
---|
| 160 | ' $mmsdrfsFile) |
---|
| 161 | rc=$? |
---|
| 162 | if [[ $rc != 0 || -z $nodesetId ]] |
---|
| 163 | then |
---|
| 164 | if [[ $rc != 0 ]] |
---|
| 165 | then |
---|
| 166 | print -u2 "$mmcmd: A node name that is not valid was found in the mmsdrfs file." |
---|
| 167 | else |
---|
| 168 | print -u2 "$mmcmd: Node $nodeName does not belong to the GPFS cluster." |
---|
| 169 | fi |
---|
| 170 | cleanupAndExit |
---|
| 171 | fi |
---|
| 172 | |
---|
| 173 | fi #end of if [[ -n $nOpt ]] |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | ######################################################################## |
---|
| 177 | # Create a list of the nodesets that will be displayed. |
---|
| 178 | # If the user requested a specific nodeset, or if the -n option |
---|
| 179 | # was specified, the list will consist of a single nodeset id. |
---|
| 180 | # If the user specified -a, then the value of $nodesetId is set |
---|
| 181 | # to the global id, and the call to getNodesetInfo will return |
---|
| 182 | # the names of all nodesets. |
---|
| 183 | ######################################################################## |
---|
| 184 | nodesetList=$(getNodesetInfo $NODESETID_Field $nodesetId $mmsdrfsFile) |
---|
| 185 | if [[ -z $nodesetList ]] |
---|
| 186 | then |
---|
| 187 | if [[ $nodesetId = $GLOBAL_ID ]] |
---|
| 188 | then |
---|
| 189 | print -u2 "$mmcmd: There are no known GPFS nodesets." |
---|
| 190 | else |
---|
| 191 | print -u2 "$mmcmd: GPFS nodeset $nodesetId does not exist." |
---|
| 192 | fi |
---|
| 193 | cleanupAndExit |
---|
| 194 | fi |
---|
| 195 | |
---|
| 196 | clusterName=$($head -1 $mmsdrfsFile | $GETVALUE $CLUSTER_NAME_Field) |
---|
| 197 | |
---|
| 198 | ######################################################### |
---|
| 199 | # Print out the node names for each nodeset in the list. |
---|
| 200 | ######################################################### |
---|
| 201 | # Put out the header line. |
---|
| 202 | print -- "GPFS nodeset Node list" |
---|
| 203 | print -- "------------- -------------------------------------------------------" |
---|
| 204 | |
---|
| 205 | for nodesetId in $nodesetList |
---|
| 206 | do |
---|
| 207 | nodeList=$(getNodeList $NODE_NAME_Field $nodesetId $mmsdrfsFile) |
---|
| 208 | [[ $nodesetId = $HOME_CLUSTER ]] && nodesetId="${clusterName%%.*}" |
---|
| 209 | printf "%2s %-8s %4s" "$BLANKchar" "$nodesetId" "$BLANKchar" |
---|
| 210 | for nodeName in $nodeList |
---|
| 211 | do |
---|
| 212 | printf "%s " $nodeName |
---|
| 213 | done |
---|
| 214 | printf "\n" |
---|
| 215 | done |
---|
| 216 | |
---|
| 217 | |
---|
| 218 | ####################### |
---|
| 219 | # Cleanup and return. |
---|
| 220 | ####################### |
---|
| 221 | cleanupAndExit 0 |
---|
| 222 | |
---|