| 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. 2004,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 | # @(#)17 1.14 src/avs/fs/mmfs/ts/admin/mmdsm.sh, mmfs, avs_rgpfs24, rgpfs240610b 7/21/05 01:45:41 |
|---|
| 17 | ############################################################################# |
|---|
| 18 | # |
|---|
| 19 | # Common interface module for DSM support. |
|---|
| 20 | # |
|---|
| 21 | # Usage: mmdsm <action> <arg1> <arg2> ... |
|---|
| 22 | # |
|---|
| 23 | # where action is one of the following: |
|---|
| 24 | # |
|---|
| 25 | # dsmGetClusterType - retrieve the GPFS cluster type |
|---|
| 26 | # dsmGetNodeNumber - retrieve the local node's GPFS node number |
|---|
| 27 | # dsmGetNodesetId - retrieve the nodeset to which this node belongs |
|---|
| 28 | # dsmGetNodeCount - retrieve the number of nodes in the nodeset |
|---|
| 29 | # dsmPutHsmdata - store the HSM data for a given nodeset |
|---|
| 30 | # dsmGetHsmdata - retrieve the HSM data for a given nodeset |
|---|
| 31 | # dsmPutHsmversion - store the version information for the HSM data |
|---|
| 32 | # dsmGetHsmversion - retrieve the version information for the HSM data |
|---|
| 33 | # dsmGetConfigServerState - verify both config servers are up |
|---|
| 34 | # dsmGetFileSystems - create a list of all file systems |
|---|
| 35 | # dsmIsFileSystemLocal - check if a file system is local or remote |
|---|
| 36 | # |
|---|
| 37 | # For additional information and description of arguments and |
|---|
| 38 | # return codes, see the prolog of the corresponding function. |
|---|
| 39 | # |
|---|
| 40 | ############################################################################# |
|---|
| 41 | |
|---|
| 42 | # Include global declarations and service routines. |
|---|
| 43 | . /usr/lpp/mmfs/bin/mmglobfuncs |
|---|
| 44 | . /usr/lpp/mmfs/bin/mmsdrfsdef |
|---|
| 45 | |
|---|
| 46 | sourceFile="mmdsm.sh" |
|---|
| 47 | [[ -n $DEBUG || -n $DEBUGmmdsm ]] && set -x |
|---|
| 48 | $mmTRACE_ENTER "$*" |
|---|
| 49 | |
|---|
| 50 | # To get mmdsm error messages, specify a file name in the dsmLog variable. |
|---|
| 51 | # If this variable is not defined, all error messages will be discarded. |
|---|
| 52 | [[ -z $dsmLog ]] && dsmLog="/dev/null" |
|---|
| 53 | |
|---|
| 54 | # Local work files. Names should be of the form: |
|---|
| 55 | # fn=${tmpDir}fn.${mmcmd}.$$ |
|---|
| 56 | |
|---|
| 57 | LOCAL_FILES=" " |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | # Local variables |
|---|
| 61 | rc=0 |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | # Local functions |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | ########################################################################### |
|---|
| 68 | # |
|---|
| 69 | # Function: Called if there is an interrupt before changes are committed. |
|---|
| 70 | # Removes temporary files and unlocks the sdr if necessary. |
|---|
| 71 | # |
|---|
| 72 | # Input: None |
|---|
| 73 | # |
|---|
| 74 | # Output: None |
|---|
| 75 | # |
|---|
| 76 | # Returns: Exits with code 2 |
|---|
| 77 | # |
|---|
| 78 | ########################################################################### |
|---|
| 79 | function localPretrap |
|---|
| 80 | { |
|---|
| 81 | typeset sourceFile="mmdsm.sh" |
|---|
| 82 | [[ -n $DEBUG || -n $DEBUGlocalPretrap ]] && set -x |
|---|
| 83 | $mmTRACE_ENTER "$*" |
|---|
| 84 | typeset ec=0 |
|---|
| 85 | |
|---|
| 86 | trap "" HUP INT QUIT KILL # Disable traps so we won't get interrupted. |
|---|
| 87 | |
|---|
| 88 | [[ -z $MMMODE ]] && determineMode 2>> $dsmLog |
|---|
| 89 | |
|---|
| 90 | # We come here if an interrupt was received and |
|---|
| 91 | # no changes have been made to the sdrfs file. |
|---|
| 92 | # Display any buffered error messages that might be there. |
|---|
| 93 | [[ -s $errMsg ]] && $cat $errMsg 1>&2 2>> $dsmLog |
|---|
| 94 | printErrorMsg 306 $mmcmd 2>> $dsmLog |
|---|
| 95 | $rm -f $GLOBAL_FILES $LOCAL_FILES |
|---|
| 96 | |
|---|
| 97 | if [[ $gpfsLocked = yes ]] |
|---|
| 98 | then |
|---|
| 99 | setRunningCommand null $primaryServer |
|---|
| 100 | ec=$? |
|---|
| 101 | if [[ $ec -ne 0 ]] |
|---|
| 102 | then |
|---|
| 103 | printErrorMsg 171 $mmcmd "function setRunningCommand" $ec 2>> $dsmLog |
|---|
| 104 | fi |
|---|
| 105 | fi |
|---|
| 106 | |
|---|
| 107 | [[ $envLocked = yes ]] && \ |
|---|
| 108 | freeEnvLock >/dev/null 2>> $dsmLog |
|---|
| 109 | envLocked=no |
|---|
| 110 | |
|---|
| 111 | [[ $sdrLocked = yes ]] && \ |
|---|
| 112 | freeLockOnServer $primaryServer $ourNodeNumber >/dev/null 2>> $dsmLog |
|---|
| 113 | sdrLocked=no |
|---|
| 114 | |
|---|
| 115 | trap - HUP INT QUIT KILL # Restore interrupts. |
|---|
| 116 | exit 2 |
|---|
| 117 | |
|---|
| 118 | } #--------- end of function localPretrap --------------------------- |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | ########################################################################### |
|---|
| 122 | # |
|---|
| 123 | # Function: Called if there is an interrupt after changes were committed. |
|---|
| 124 | # Removes temporary files and unlocks the sdr if necessary. |
|---|
| 125 | # |
|---|
| 126 | # Input: None |
|---|
| 127 | # |
|---|
| 128 | # Output: None |
|---|
| 129 | # |
|---|
| 130 | # Returns: Exits with code 2 |
|---|
| 131 | # |
|---|
| 132 | ########################################################################### |
|---|
| 133 | function localPosttrap |
|---|
| 134 | { |
|---|
| 135 | typeset sourceFile="mmdsm.sh" |
|---|
| 136 | [[ -n $DEBUG || -n $DEBUGlocalPosttrap ]] && set -x |
|---|
| 137 | $mmTRACE_ENTER "$*" |
|---|
| 138 | typeset ec=0 |
|---|
| 139 | |
|---|
| 140 | trap "" HUP INT QUIT KILL # Disable traps so we won't get interrupted. |
|---|
| 141 | |
|---|
| 142 | [[ -z $MMMODE ]] && determineMode 2>> $dsmLog |
|---|
| 143 | |
|---|
| 144 | # Interrupt received: changes not propagated. |
|---|
| 145 | # Display any buffered error messages that might be there. |
|---|
| 146 | [[ -s $errMsg ]] && $cat $errMsg 1>&2 2>> $dsmLog |
|---|
| 147 | printErrorMsg 32 $mmcmd 2>> $dsmLog |
|---|
| 148 | $rm -f $GLOBAL_FILES $LOCAL_FILES |
|---|
| 149 | |
|---|
| 150 | if [[ $gpfsLocked = yes ]] |
|---|
| 151 | then |
|---|
| 152 | setRunningCommand null $primaryServer |
|---|
| 153 | ec=$? |
|---|
| 154 | if [[ $ec -ne 0 ]] |
|---|
| 155 | then |
|---|
| 156 | printErrorMsg 171 $mmcmd "function setRunningCommand" $ec 2>> $dsmLog |
|---|
| 157 | fi |
|---|
| 158 | fi |
|---|
| 159 | |
|---|
| 160 | [[ $envLocked = yes ]] && \ |
|---|
| 161 | freeEnvLock >/dev/null 2>> $dsmLog |
|---|
| 162 | envLocked=no |
|---|
| 163 | |
|---|
| 164 | [[ $sdrLocked = yes ]] && \ |
|---|
| 165 | freeLockOnServer $primaryServer $ourNodeNumber >/dev/null 2>> $dsmLog |
|---|
| 166 | sdrLocked=no |
|---|
| 167 | |
|---|
| 168 | trap - HUP INT QUIT KILL # Restore interrupts. |
|---|
| 169 | exit 2 |
|---|
| 170 | |
|---|
| 171 | } #--------- end of function localPosttrap --------------------------- |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | ########################################################################## |
|---|
| 175 | # |
|---|
| 176 | # Function: Retrieve the name of the nodeset to which this node belongs. |
|---|
| 177 | # |
|---|
| 178 | # Input: None. |
|---|
| 179 | # |
|---|
| 180 | # Output: Nodeset identifier or zero. |
|---|
| 181 | # |
|---|
| 182 | # Returns: 0 - no errors encountered |
|---|
| 183 | # non-zero - unexpected error |
|---|
| 184 | # |
|---|
| 185 | ########################################################################## |
|---|
| 186 | function dsmGetNodesetId # |
|---|
| 187 | { |
|---|
| 188 | typeset sourceFile="mmdsm.sh" |
|---|
| 189 | [[ -n $DEBUG || -n $DEBUGdsmGetNodesetId ]] && set -x |
|---|
| 190 | |
|---|
| 191 | # Ensure that the local copy of the mmsdrfs is up-to-date. |
|---|
| 192 | gpfsInitOutput=$(gpfsInit nolock) |
|---|
| 193 | setGlobalVar $? $gpfsInitOutput |
|---|
| 194 | |
|---|
| 195 | # Display the nodeset name. |
|---|
| 196 | print -- "$nsId" |
|---|
| 197 | |
|---|
| 198 | return 0 |
|---|
| 199 | |
|---|
| 200 | } #------------ end function dsmGetNodesetId ----------------- |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | ########################################################################## |
|---|
| 204 | # |
|---|
| 205 | # Function: Retrieve the number of nodes in the current nodeset. |
|---|
| 206 | # |
|---|
| 207 | # Input: None. |
|---|
| 208 | # |
|---|
| 209 | # Output: Number of nodes. |
|---|
| 210 | # |
|---|
| 211 | # Returns: 0 - no errors encountered |
|---|
| 212 | # non-zero - unexpected error |
|---|
| 213 | # |
|---|
| 214 | ########################################################################## |
|---|
| 215 | function dsmGetNodeCount # |
|---|
| 216 | { |
|---|
| 217 | typeset sourceFile="mmdsm.sh" |
|---|
| 218 | [[ -n $DEBUG || -n $DEBUGdsmGetNodeCount ]] && set -x |
|---|
| 219 | |
|---|
| 220 | # Ensure that the local copy of the mmsdrfs is up-to-date. |
|---|
| 221 | gpfsInitOutput=$(gpfsInit nolock) |
|---|
| 222 | setGlobalVar $? $gpfsInitOutput |
|---|
| 223 | |
|---|
| 224 | # Find out the number of nodes in the local nodeset. |
|---|
| 225 | # The result is displayed on stdout. |
|---|
| 226 | getNodesetInfo $NODE_COUNT_Field $nsId $mmsdrfsFile |
|---|
| 227 | |
|---|
| 228 | return 0 |
|---|
| 229 | |
|---|
| 230 | } #------------ end function dsmGetNodeCount ----------------- |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | ########################################################################## |
|---|
| 234 | # |
|---|
| 235 | # Function: Append the specified file with HSM data to the mmsdrfs file. |
|---|
| 236 | # |
|---|
| 237 | # Input: $1 - nodeset to which the data pertains |
|---|
| 238 | # $2 - path name of file to store in the sdr or DELETE |
|---|
| 239 | # $3 - path name of file with version information (optional) |
|---|
| 240 | # $4 - mmsdrfs file version (generation) number (optional) |
|---|
| 241 | # |
|---|
| 242 | # Returns: 0 - no errors encountered |
|---|
| 243 | # non-zero - unexpected error |
|---|
| 244 | # |
|---|
| 245 | ########################################################################## |
|---|
| 246 | function dsmPutHsmdata # <nodesetId> <inputFile> [<versionFile> [<genNumber>]] |
|---|
| 247 | { |
|---|
| 248 | typeset sourceFile="mmdsm.sh" |
|---|
| 249 | [[ -n $DEBUG || -n $DEBUGdsmPutHsmdata ]] && set -x |
|---|
| 250 | typeset hsmNodesetId=$1 |
|---|
| 251 | typeset inputFile=$2 |
|---|
| 252 | typeset versionFile=$3 |
|---|
| 253 | typeset genNumber=$4 |
|---|
| 254 | |
|---|
| 255 | typeset gpfsInitOutput sdrfsLine printLine inLine rc |
|---|
| 256 | typeset replaceVersionInfo='' |
|---|
| 257 | typeset removeHSMdata='' |
|---|
| 258 | typeset -i lineNumber=0 |
|---|
| 259 | |
|---|
| 260 | [[ -z $genNumber ]] && genNumber=0 |
|---|
| 261 | |
|---|
| 262 | if [[ $hsmNodesetId = DELETE ]] |
|---|
| 263 | then |
|---|
| 264 | removeHSMdata=yes |
|---|
| 265 | else |
|---|
| 266 | [[ ! -f $inputFile ]] && cleanupAndExit |
|---|
| 267 | [[ -f $versionFile ]] && replaceVersionInfo=yes |
|---|
| 268 | fi |
|---|
| 269 | |
|---|
| 270 | ####################################################################### |
|---|
| 271 | # Ensure that the local copy of the mmsdrfs is up-to-date. |
|---|
| 272 | ####################################################################### |
|---|
| 273 | gpfsInitOutput=$(gpfsInit $lockId) |
|---|
| 274 | setGlobalVar $? $gpfsInitOutput |
|---|
| 275 | |
|---|
| 276 | ######################################################################## |
|---|
| 277 | # Go through the current mmsdrfs file. Increment the generation |
|---|
| 278 | # number and build the node name list that will be needed later. |
|---|
| 279 | # Remove all HSMDATA lines that are currently in the file so that |
|---|
| 280 | # they can be replaced with their new version. |
|---|
| 281 | ######################################################################## |
|---|
| 282 | $rm -f $newsdrfs $nodefile |
|---|
| 283 | IFS=":" |
|---|
| 284 | exec 3<&- |
|---|
| 285 | exec 3< $mmsdrfsFile |
|---|
| 286 | while read -u3 sdrfsLine |
|---|
| 287 | do |
|---|
| 288 | # Parse the line. |
|---|
| 289 | set -f ; set -A v -- - $sdrfsLine ; set +f |
|---|
| 290 | |
|---|
| 291 | IFS="$IFS_sv" # Restore the default IFS settings. |
|---|
| 292 | printLine=true # Assume the line will be printed. |
|---|
| 293 | |
|---|
| 294 | case ${v[$LINE_TYPE_Field]} in |
|---|
| 295 | |
|---|
| 296 | $VERSION_LINE ) |
|---|
| 297 | # If requested, ensure that the current version of the mmsdrfs |
|---|
| 298 | # file matches the caller's version of the data. |
|---|
| 299 | [[ $genNumber -gt 0 && $genNumber -ne ${v[$SDRFS_GENNUM_Field]} ]] && \ |
|---|
| 300 | return 52 # ESTALE |
|---|
| 301 | |
|---|
| 302 | # Increment the generation number |
|---|
| 303 | newGenNumber=${v[$SDRFS_GENNUM_Field]}+1 |
|---|
| 304 | v[$SDRFS_GENNUM_Field]=$newGenNumber |
|---|
| 305 | ;; |
|---|
| 306 | |
|---|
| 307 | $MEMBER_NODE ) |
|---|
| 308 | # Collect the reliable names of all nodes in the cluster. |
|---|
| 309 | print -- "${v[$REL_HOSTNAME_Field]}" >> $nodefile |
|---|
| 310 | checkForErrors "writing to file $nodefile" $? |
|---|
| 311 | ;; |
|---|
| 312 | |
|---|
| 313 | $HSMDATA ) |
|---|
| 314 | # This is a line with HSM data. |
|---|
| 315 | # Remove the line if it is for the right nodeset. |
|---|
| 316 | [[ ${v[$HSM_NODESET_Field]} = $hsmNodesetId || -n $removeHSMdata ]] && \ |
|---|
| 317 | printLine=false |
|---|
| 318 | ;; |
|---|
| 319 | |
|---|
| 320 | $HSMVERSION ) |
|---|
| 321 | # This is a HSMVERSION line. |
|---|
| 322 | # Remove the line from the mmsdrfs file if the |
|---|
| 323 | # version information will be updated as well. |
|---|
| 324 | [[ -n $replaceVersionInfo || -n $removeHSMdata ]] && \ |
|---|
| 325 | printLine=false |
|---|
| 326 | ;; |
|---|
| 327 | |
|---|
| 328 | * ) # Not interested in any other lines. |
|---|
| 329 | ;; |
|---|
| 330 | |
|---|
| 331 | esac # end of case ${v[$LINE_TYPE_Field]} in |
|---|
| 332 | |
|---|
| 333 | # Build and write the line to the new mmsdrfs file. |
|---|
| 334 | if [[ $printLine = true ]] |
|---|
| 335 | then |
|---|
| 336 | print_newLine >> $newsdrfs |
|---|
| 337 | checkForErrors "writing to file $newsdrfs" $? |
|---|
| 338 | fi |
|---|
| 339 | |
|---|
| 340 | IFS=":" # Change the separator back to ":" for the next iteration. |
|---|
| 341 | |
|---|
| 342 | done # end while read -u3 |
|---|
| 343 | |
|---|
| 344 | IFS="$IFS_sv" # Restore the default IFS settings. |
|---|
| 345 | |
|---|
| 346 | ######################################################### |
|---|
| 347 | # Append the user-provided input file to the sdrfs file. |
|---|
| 348 | ######################################################### |
|---|
| 349 | if [[ -z $removeHSMdata ]] |
|---|
| 350 | then |
|---|
| 351 | exec 3<&- |
|---|
| 352 | exec 3< $inputFile |
|---|
| 353 | IFS="" # Reset IFS to preserve blanks and tabs. |
|---|
| 354 | while read -u3 inLine |
|---|
| 355 | do |
|---|
| 356 | lineNumber=$lineNumber+1 |
|---|
| 357 | print -- "$DSM_DATA:$HSMDATA:$hsmNodesetId:$lineNumber:$inLine" >> $newsdrfs |
|---|
| 358 | done |
|---|
| 359 | checkForErrors "writing to file $newsdrfs" $? |
|---|
| 360 | IFS="$IFS_sv" |
|---|
| 361 | fi # end of if [[ -z $removeHSMdata ]] |
|---|
| 362 | |
|---|
| 363 | ######################################################### |
|---|
| 364 | # If the version information needs to be updated as well, |
|---|
| 365 | # append the user-provided input file to the sdrfs file. |
|---|
| 366 | ######################################################### |
|---|
| 367 | if [[ -n $replaceVersionInfo && -z $removeHSMdata ]] |
|---|
| 368 | then |
|---|
| 369 | exec 3<&- |
|---|
| 370 | exec 3< $versionFile |
|---|
| 371 | IFS="" # Reset IFS to preserve blanks and tabs. |
|---|
| 372 | lineNumber=0 |
|---|
| 373 | while read -u3 inLine |
|---|
| 374 | do |
|---|
| 375 | lineNumber=$lineNumber+1 |
|---|
| 376 | print -- "$DSM_DATA:$HSMVERSION::$lineNumber:$inLine" >> $newsdrfs |
|---|
| 377 | done |
|---|
| 378 | checkForErrors "writing to file $newsdrfs" $? |
|---|
| 379 | IFS="$IFS_sv" |
|---|
| 380 | fi # end of if [[ -n $replaceVersionInfo && -z $removeHSMdata ]] |
|---|
| 381 | |
|---|
| 382 | # Sort the new version of the mmsdrfs file. |
|---|
| 383 | LC_ALL=C $SORT_MMSDRFS $newsdrfs -o $newsdrfs |
|---|
| 384 | checkForErrors "sorting $newsdrfs" $? |
|---|
| 385 | |
|---|
| 386 | #################################################################### |
|---|
| 387 | # Put the new mmsdrfs file into the sdr. This commits the changes. |
|---|
| 388 | #################################################################### |
|---|
| 389 | trap "" HUP INT QUIT KILL |
|---|
| 390 | gpfsObjectInfo=$(commitChanges \ |
|---|
| 391 | $nsId $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer) |
|---|
| 392 | rc=$? |
|---|
| 393 | if [[ $rc -ne 0 ]] |
|---|
| 394 | then |
|---|
| 395 | # The commit step failed. |
|---|
| 396 | printErrorMsg 381 $mmcmd |
|---|
| 397 | cleanupAndExit |
|---|
| 398 | fi |
|---|
| 399 | |
|---|
| 400 | ################## |
|---|
| 401 | # Unlock the sdr. |
|---|
| 402 | ################## |
|---|
| 403 | [[ $sdrLocked = yes ]] && \ |
|---|
| 404 | freeLockOnServer $primaryServer $ourNodeNumber > /dev/null |
|---|
| 405 | sdrLocked=no |
|---|
| 406 | trap localPosttrap HUP INT QUIT KILL |
|---|
| 407 | |
|---|
| 408 | ############################################### |
|---|
| 409 | # Propagate the changes to all affected nodes. |
|---|
| 410 | ############################################### |
|---|
| 411 | propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber |
|---|
| 412 | |
|---|
| 413 | return 0 |
|---|
| 414 | |
|---|
| 415 | } #------------ end function dsmPutHsmdata ----------------- |
|---|
| 416 | |
|---|
| 417 | |
|---|
| 418 | ########################################################################## |
|---|
| 419 | # |
|---|
| 420 | # Function: Retrieve the HSM data from the mmsdrfs file. |
|---|
| 421 | # |
|---|
| 422 | # Input: $1 - nodeset to which the data pertains |
|---|
| 423 | # $2 - name of a file where to store the HSM data |
|---|
| 424 | # $3 - (optional) assume cached data is current |
|---|
| 425 | # |
|---|
| 426 | # Returns: 0 - no errors encountered |
|---|
| 427 | # 1 - unexpected error |
|---|
| 428 | # 3 - HSM data not found in the repository |
|---|
| 429 | # |
|---|
| 430 | ########################################################################## |
|---|
| 431 | function dsmGetHsmdata # <nodesetId> <outputFile> [norefresh] |
|---|
| 432 | { |
|---|
| 433 | typeset sourceFile="mmdsm.sh" |
|---|
| 434 | [[ -n $DEBUG || -n $DEBUGdsmGetHsmdata ]] && set -x |
|---|
| 435 | typeset hsmNodesetId=$1 |
|---|
| 436 | typeset outputFile=$2 |
|---|
| 437 | typeset -l refreshArg=$3 |
|---|
| 438 | |
|---|
| 439 | typeset gpfsInitOutput sdrfsLine nodesetIdField hsmNodesetField |
|---|
| 440 | typeset lineTypeField outLine |
|---|
| 441 | |
|---|
| 442 | ####################################################################### |
|---|
| 443 | # Ensure that the local copy of the mmsdrfs is up-to-date. |
|---|
| 444 | ####################################################################### |
|---|
| 445 | if [[ $refreshArg != "norefresh" ]] |
|---|
| 446 | then |
|---|
| 447 | gpfsInitOutput=$(gpfsInit nolock) |
|---|
| 448 | setGlobalVar $? $gpfsInitOutput |
|---|
| 449 | fi |
|---|
| 450 | |
|---|
| 451 | ############################################################################## |
|---|
| 452 | # Go through the current mmsdrfs file and retrieve the requested information. |
|---|
| 453 | ############################################################################## |
|---|
| 454 | $rm -f $outputFile |
|---|
| 455 | IFS=":" |
|---|
| 456 | exec 3<&- |
|---|
| 457 | exec 3< $mmsdrfsFile |
|---|
| 458 | while read -u3 sdrfsLine |
|---|
| 459 | do |
|---|
| 460 | # Parse the line. |
|---|
| 461 | set -f ; set -- $sdrfsLine ; set +f |
|---|
| 462 | nodesetIdField=$1 |
|---|
| 463 | lineTypeField=$2 |
|---|
| 464 | hsmNodesetField=$3 |
|---|
| 465 | |
|---|
| 466 | # We are interested only in the HSMDATA lines for |
|---|
| 467 | # the specified HSM nodeset id. |
|---|
| 468 | if [[ $nodesetIdField = $DSM_DATA && |
|---|
| 469 | $lineTypeField = $HSMDATA && |
|---|
| 470 | $hsmNodesetField = $hsmNodesetId ]] |
|---|
| 471 | then |
|---|
| 472 | # The HSM information is everything past the first 4 fields. |
|---|
| 473 | shift 4 |
|---|
| 474 | outLine=$* |
|---|
| 475 | |
|---|
| 476 | # To preserve tabs, temporarily set IFS to new line only. |
|---|
| 477 | IFS=" |
|---|
| 478 | " |
|---|
| 479 | # Strip trailing colons and add the line to the output file. |
|---|
| 480 | print -- "${outLine%%+(:)}" >> $outputFile |
|---|
| 481 | checkForErrors "writing to file $outputFile" $? |
|---|
| 482 | IFS=":" # Change the separator back to ":" for the next iteration |
|---|
| 483 | fi |
|---|
| 484 | |
|---|
| 485 | done # end while read -u3 sdrfsLine |
|---|
| 486 | |
|---|
| 487 | IFS="$IFS_sv" # Restore the default IFS settings. |
|---|
| 488 | |
|---|
| 489 | if [[ -s $outputFile ]] |
|---|
| 490 | then |
|---|
| 491 | return 0 # HSM data successfully retrieved. |
|---|
| 492 | else |
|---|
| 493 | return 3 # HSM data does not exist. |
|---|
| 494 | fi |
|---|
| 495 | |
|---|
| 496 | } #------------ end function dsmGetHsmdata ----------------- |
|---|
| 497 | |
|---|
| 498 | |
|---|
| 499 | ########################################################################## |
|---|
| 500 | # |
|---|
| 501 | # Function: Append the version information for the HSM data. |
|---|
| 502 | # |
|---|
| 503 | # Input: $1 - path name of file to store in the sdr |
|---|
| 504 | # $2 - mmsdrfs file version (generation) number (optional) |
|---|
| 505 | # |
|---|
| 506 | # Returns: 0 - no errors encountered |
|---|
| 507 | # non-zero - unexpected error |
|---|
| 508 | # |
|---|
| 509 | ########################################################################## |
|---|
| 510 | function dsmPutHsmversion # <inputFile> [<genNumber>] |
|---|
| 511 | { |
|---|
| 512 | typeset sourceFile="mmdsm.sh" |
|---|
| 513 | [[ -n $DEBUG || -n $DEBUGdsmPutHsmversion ]] && set -x |
|---|
| 514 | typeset inputFile=$1 |
|---|
| 515 | typeset genNumber=$2 |
|---|
| 516 | |
|---|
| 517 | typeset gpfsInitOutput sdrfsLine printLine inLine rc |
|---|
| 518 | typeset -i lineNumber=0 |
|---|
| 519 | |
|---|
| 520 | [[ ! -f $inputFile ]] && cleanupAndExit |
|---|
| 521 | [[ -z $genNumber ]] && genNumber=0 |
|---|
| 522 | |
|---|
| 523 | ################################################################# |
|---|
| 524 | # Ensure that the local copy of the mmsdrfs is up-to-date. |
|---|
| 525 | ################################################################# |
|---|
| 526 | gpfsInitOutput=$(gpfsInit $lockId) |
|---|
| 527 | setGlobalVar $? $gpfsInitOutput |
|---|
| 528 | |
|---|
| 529 | ################################################################# |
|---|
| 530 | # Go through the current mmsdrfs file. Increment the generation |
|---|
| 531 | # number and build the node name list that will be needed later. |
|---|
| 532 | # Remove all HSMVERSION lines that are currently in the file |
|---|
| 533 | # so that they can be replaced with their new version. |
|---|
| 534 | ################################################################# |
|---|
| 535 | $rm -f $newsdrfs $nodefile |
|---|
| 536 | IFS=":" |
|---|
| 537 | exec 3<&- |
|---|
| 538 | exec 3< $mmsdrfsFile |
|---|
| 539 | while read -u3 sdrfsLine |
|---|
| 540 | do |
|---|
| 541 | # Parse the line. |
|---|
| 542 | set -f ; set -A v -- - $sdrfsLine ; set +f |
|---|
| 543 | |
|---|
| 544 | IFS="$IFS_sv" # Restore the default IFS settings. |
|---|
| 545 | printLine=true # Assume the line will be printed. |
|---|
| 546 | |
|---|
| 547 | case ${v[$LINE_TYPE_Field]} in |
|---|
| 548 | |
|---|
| 549 | $VERSION_LINE ) |
|---|
| 550 | # If requested, ensure that the current version of the mmsdrfs |
|---|
| 551 | # file matches the caller's version of the data. |
|---|
| 552 | [[ $genNumber -gt 0 && $genNumber -ne ${v[$SDRFS_GENNUM_Field]} ]] && \ |
|---|
| 553 | return 52 # ESTALE |
|---|
| 554 | |
|---|
| 555 | # Increment the generation number |
|---|
| 556 | newGenNumber=${v[$SDRFS_GENNUM_Field]}+1 |
|---|
| 557 | v[$SDRFS_GENNUM_Field]=$newGenNumber |
|---|
| 558 | ;; |
|---|
| 559 | |
|---|
| 560 | $MEMBER_NODE ) |
|---|
| 561 | # Collect the reliable names of all nodes in the cluster. |
|---|
| 562 | print -- "${v[$REL_HOSTNAME_Field]}" >> $nodefile |
|---|
| 563 | checkForErrors "writing to file $nodefile" $? |
|---|
| 564 | ;; |
|---|
| 565 | |
|---|
| 566 | $HSMVERSION ) |
|---|
| 567 | # This is a HSMVERSION line. |
|---|
| 568 | # Remove the line from the mmsdrfs file. |
|---|
| 569 | printLine=false |
|---|
| 570 | ;; |
|---|
| 571 | |
|---|
| 572 | * ) # Not interested in any other lines. |
|---|
| 573 | ;; |
|---|
| 574 | |
|---|
| 575 | esac # end of case ${v[$LINE_TYPE_Field]} in |
|---|
| 576 | |
|---|
| 577 | # Build and write the line to the new mmsdrfs file. |
|---|
| 578 | if [[ $printLine = true ]] |
|---|
| 579 | then |
|---|
| 580 | print_newLine >> $newsdrfs |
|---|
| 581 | checkForErrors "writing to file $newsdrfs" $? |
|---|
| 582 | fi |
|---|
| 583 | |
|---|
| 584 | IFS=":" # Change the separator back to ":" for the next iteration. |
|---|
| 585 | |
|---|
| 586 | done # end while read -u3 |
|---|
| 587 | |
|---|
| 588 | IFS="$IFS_sv" # Restore the default IFS settings. |
|---|
| 589 | |
|---|
| 590 | ######################################################### |
|---|
| 591 | # Append the user-provided input file to the sdrfs file. |
|---|
| 592 | ######################################################### |
|---|
| 593 | exec 3<&- |
|---|
| 594 | exec 3< $inputFile |
|---|
| 595 | IFS="" # Reset IFS to preserve blanks and tabs. |
|---|
| 596 | while read -u3 inLine |
|---|
| 597 | do |
|---|
| 598 | lineNumber=$lineNumber+1 |
|---|
| 599 | print -- "$DSM_DATA:$HSMVERSION::$lineNumber:$inLine" >> $newsdrfs |
|---|
| 600 | done |
|---|
| 601 | checkForErrors "writing to file $newsdrfs" $? |
|---|
| 602 | IFS="$IFS_sv" |
|---|
| 603 | |
|---|
| 604 | # Sort the new version of the mmsdrfs file. |
|---|
| 605 | LC_ALL=C $SORT_MMSDRFS $newsdrfs -o $newsdrfs |
|---|
| 606 | checkForErrors "sorting $newsdrfs" $? |
|---|
| 607 | |
|---|
| 608 | #################################################################### |
|---|
| 609 | # Put the new mmsdrfs file into the sdr. This commits the changes. |
|---|
| 610 | #################################################################### |
|---|
| 611 | trap "" HUP INT QUIT KILL |
|---|
| 612 | gpfsObjectInfo=$(commitChanges \ |
|---|
| 613 | $nsId $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer) |
|---|
| 614 | rc=$? |
|---|
| 615 | if [[ $rc -ne 0 ]] |
|---|
| 616 | then |
|---|
| 617 | # The commit step failed. |
|---|
| 618 | printErrorMsg 381 $mmcmd |
|---|
| 619 | cleanupAndExit |
|---|
| 620 | fi |
|---|
| 621 | |
|---|
| 622 | ################## |
|---|
| 623 | # Unlock the sdr. |
|---|
| 624 | ################## |
|---|
| 625 | [[ $sdrLocked = yes ]] && \ |
|---|
| 626 | freeLockOnServer $primaryServer $ourNodeNumber > /dev/null |
|---|
| 627 | sdrLocked=no |
|---|
| 628 | trap localPosttrap HUP INT QUIT KILL |
|---|
| 629 | |
|---|
| 630 | ############################################### |
|---|
| 631 | # Propagate the changes to all affected nodes. |
|---|
| 632 | ############################################### |
|---|
| 633 | propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber |
|---|
| 634 | |
|---|
| 635 | return 0 |
|---|
| 636 | |
|---|
| 637 | } #------------ end function dsmPutHsmversion ----------------- |
|---|
| 638 | |
|---|
| 639 | |
|---|
| 640 | ########################################################################## |
|---|
| 641 | # |
|---|
| 642 | # Function: Retrieve the version information for the HSM data. |
|---|
| 643 | # |
|---|
| 644 | # Input: $1 - name of a file where to store the data |
|---|
| 645 | # $2 - (optional) assume cached data is current |
|---|
| 646 | # |
|---|
| 647 | # Output: current version (generation) number of the mmsdrfs file. |
|---|
| 648 | # |
|---|
| 649 | # Returns: 0 - no errors encountered |
|---|
| 650 | # 1 - unexpected error |
|---|
| 651 | # 3 - data not found in the repository |
|---|
| 652 | # |
|---|
| 653 | ########################################################################## |
|---|
| 654 | function dsmGetHsmversion # <outputFile> [norefresh] |
|---|
| 655 | { |
|---|
| 656 | typeset sourceFile="mmdsm.sh" |
|---|
| 657 | [[ -n $DEBUG || -n $DEBUGdsmGetHsmversion ]] && set -x |
|---|
| 658 | typeset outputFile=$1 |
|---|
| 659 | typeset -l refreshArg=$2 |
|---|
| 660 | |
|---|
| 661 | typeset gpfsInitOutput sdrfsLine nodesetIdField lineTypeField outLine |
|---|
| 662 | typeset genNumber |
|---|
| 663 | |
|---|
| 664 | ########################################################### |
|---|
| 665 | # Ensure that the local copy of the mmsdrfs is up-to-date. |
|---|
| 666 | ########################################################### |
|---|
| 667 | if [[ $refreshArg != "norefresh" ]] |
|---|
| 668 | then |
|---|
| 669 | gpfsInitOutput=$(gpfsInit nolock) |
|---|
| 670 | setGlobalVar $? $gpfsInitOutput |
|---|
| 671 | fi |
|---|
| 672 | |
|---|
| 673 | ############################################################################## |
|---|
| 674 | # Go through the current mmsdrfs file and retrieve the requested information. |
|---|
| 675 | ############################################################################## |
|---|
| 676 | $rm -f $outputFile |
|---|
| 677 | IFS=":" |
|---|
| 678 | exec 3<&- |
|---|
| 679 | exec 3< $mmsdrfsFile |
|---|
| 680 | while read -u3 sdrfsLine |
|---|
| 681 | do |
|---|
| 682 | # Parse the line. |
|---|
| 683 | set -f ; set -- $sdrfsLine ; set +f |
|---|
| 684 | nodesetIdField=$1 |
|---|
| 685 | lineTypeField=$2 |
|---|
| 686 | |
|---|
| 687 | # Get the current mmsdrfs gen number. |
|---|
| 688 | [[ $lineTypeField = $VERSION_LINE ]] && genNumber=$6 |
|---|
| 689 | |
|---|
| 690 | # We are interested only in the HSMVERSION lines. |
|---|
| 691 | if [[ $nodesetIdField = $DSM_DATA && $lineTypeField = $HSMVERSION ]] |
|---|
| 692 | then |
|---|
| 693 | # The HSM version information is everything past the first 4 fields. |
|---|
| 694 | shift 4 |
|---|
| 695 | outLine=$* |
|---|
| 696 | |
|---|
| 697 | # To preserve tabs, temporarily set IFS to new line only. |
|---|
| 698 | IFS=" |
|---|
| 699 | " |
|---|
| 700 | # Strip trailing colons and add the line to the output file. |
|---|
| 701 | print -- "${outLine%%+(:)}" >> $outputFile |
|---|
| 702 | checkForErrors "writing to file $outputFile" $? |
|---|
| 703 | IFS=":" # Change the separator back to ":" for the next iteration. |
|---|
| 704 | fi |
|---|
| 705 | |
|---|
| 706 | done # end while read -u3 sdrfsLine |
|---|
| 707 | |
|---|
| 708 | IFS="$IFS_sv" # Restore the default IFS settings. |
|---|
| 709 | |
|---|
| 710 | print -- "$genNumber" |
|---|
| 711 | if [[ -s $outputFile ]] |
|---|
| 712 | then |
|---|
| 713 | return 0 # HSM version information successfully retrieved. |
|---|
| 714 | else |
|---|
| 715 | return 3 # HSM version information does not exist. |
|---|
| 716 | fi |
|---|
| 717 | |
|---|
| 718 | } #------------ end function dsmGetHsmversion ----------------- |
|---|
| 719 | |
|---|
| 720 | |
|---|
| 721 | ################################################################### |
|---|
| 722 | # |
|---|
| 723 | # Function: Check whether both the primary and backup config |
|---|
| 724 | # servers are available. |
|---|
| 725 | # |
|---|
| 726 | # Input: $1 - (optional) assume cached data is current |
|---|
| 727 | # |
|---|
| 728 | # Output: getConfigServerState:<up | down> |
|---|
| 729 | # |
|---|
| 730 | # Returns: 0 - both config servers are available. |
|---|
| 731 | # 1 - at least one of the servers does not respond, |
|---|
| 732 | # or some other unexpected error. |
|---|
| 733 | # |
|---|
| 734 | ################################################################### |
|---|
| 735 | function getConfigServerState |
|---|
| 736 | { |
|---|
| 737 | typeset sourceFile="mmdsm.sh" |
|---|
| 738 | [[ -n $DEBUG || -n $DEBUGgetConfigServerState ]] && set -x |
|---|
| 739 | $mmTRACE_ENTER "$*" |
|---|
| 740 | typeset -l refreshArg=$1 |
|---|
| 741 | |
|---|
| 742 | typeset versionLine="" |
|---|
| 743 | typeset serverState="up" |
|---|
| 744 | typeset rc=0 |
|---|
| 745 | typeset primaryServer backupServer |
|---|
| 746 | |
|---|
| 747 | # Ensure that the local copy of the mmsdrfs is up-to-date. |
|---|
| 748 | if [[ $refreshArg != "norefresh" ]] |
|---|
| 749 | then |
|---|
| 750 | gpfsInitOutput=$(gpfsInit nolock) |
|---|
| 751 | setGlobalVar $? $gpfsInitOutput |
|---|
| 752 | fi |
|---|
| 753 | |
|---|
| 754 | # Parse the version line of the mmsdrfs file. |
|---|
| 755 | versionLine=$($head -1 $mmsdrfsFile) |
|---|
| 756 | IFS=':' |
|---|
| 757 | set -f ; set -A v -- - $versionLine ; set +f |
|---|
| 758 | IFS="$IFS_sv" |
|---|
| 759 | |
|---|
| 760 | # Perform a quick sanity check. |
|---|
| 761 | [[ ${v[$LINE_TYPE_Field]} != $VERSION_LINE ]] && \ |
|---|
| 762 | corruptedSdrFileExit 143 "$versionLine" |
|---|
| 763 | |
|---|
| 764 | # Get the config server names. |
|---|
| 765 | primaryServer=${v[$PRIMARY_SERVER_Field]} |
|---|
| 766 | backupServer=${v[$BACKUP_SERVER_Field]} |
|---|
| 767 | [[ $backupServer = "_NOSECONDARY_" ]] && backupServer="" |
|---|
| 768 | |
|---|
| 769 | # Verify the primary server is reachable. |
|---|
| 770 | isNodeReachable $primaryServer |
|---|
| 771 | rc=$? |
|---|
| 772 | [[ $rc -ne 0 ]] && serverState=down |
|---|
| 773 | |
|---|
| 774 | # Verify the backup server is reachable. |
|---|
| 775 | if [[ $rc -eq 0 && -n $backupServer ]] |
|---|
| 776 | then |
|---|
| 777 | isNodeReachable $backupServer |
|---|
| 778 | rc=$? |
|---|
| 779 | [[ $rc -ne 0 ]] && serverState=down |
|---|
| 780 | fi |
|---|
| 781 | |
|---|
| 782 | # Generate and display the result. |
|---|
| 783 | print -- "getConfigServerState:$serverState" |
|---|
| 784 | |
|---|
| 785 | return $rc |
|---|
| 786 | |
|---|
| 787 | } #------ end of function getConfigServerState ------------------- |
|---|
| 788 | |
|---|
| 789 | |
|---|
| 790 | ################################################################### |
|---|
| 791 | # |
|---|
| 792 | # Function: Create a list of all local and remote file systems. |
|---|
| 793 | # |
|---|
| 794 | # Input: $1 - name of a file where to store the result |
|---|
| 795 | # $2 - (optional) assume cached data is current |
|---|
| 796 | # |
|---|
| 797 | # Output: A file with all file system device names, one per line. |
|---|
| 798 | # The names of all local file systems found in the cluster |
|---|
| 799 | # are preceded by "0:", while the names of the remote file |
|---|
| 800 | # systems are preceded by "93:" (MM_Remotefs). |
|---|
| 801 | # |
|---|
| 802 | # Returns: 0 - success |
|---|
| 803 | # 19 - no file systems found |
|---|
| 804 | # nn - some other unexpected error |
|---|
| 805 | # |
|---|
| 806 | ################################################################### |
|---|
| 807 | function dsmGetFileSystems # <outputFile> [<norefresh>] |
|---|
| 808 | { |
|---|
| 809 | typeset sourceFile="mmdsm.sh" |
|---|
| 810 | [[ -n $DEBUG || -n $DEBUGdsmGetFileSystems ]] && set -x |
|---|
| 811 | $mmTRACE_ENTER "$*" |
|---|
| 812 | typeset outputFile=$1 |
|---|
| 813 | typeset -l refreshArg=$2 |
|---|
| 814 | |
|---|
| 815 | typeset rc=0 |
|---|
| 816 | |
|---|
| 817 | |
|---|
| 818 | # Ensure that the local copy of the mmsdrfs is up-to-date. |
|---|
| 819 | if [[ $refreshArg != "norefresh" ]] |
|---|
| 820 | then |
|---|
| 821 | gpfsInitOutput=$(gpfsInit nolock) |
|---|
| 822 | setGlobalVar $? $gpfsInitOutput |
|---|
| 823 | fi |
|---|
| 824 | |
|---|
| 825 | # Generate the requested information. |
|---|
| 826 | $rm -f $outputFile |
|---|
| 827 | $awk -F: ' \ |
|---|
| 828 | BEGIN { rc = '$MM_DeviceNotFound' } \ |
|---|
| 829 | $'$LINE_TYPE_Field' == "'$SG_HEADR'" { \ |
|---|
| 830 | if ($'$FS_TYPE_Field' == "'$remotefs'") { \ |
|---|
| 831 | { print "93:/dev/"$'$DEV_NAME_Field' >> "'$outputFile'" } \ |
|---|
| 832 | } \ |
|---|
| 833 | else { \ |
|---|
| 834 | { print "0:/dev/"$'$DEV_NAME_Field' >> "'$outputFile'" } \ |
|---|
| 835 | } \ |
|---|
| 836 | { rc = 0 } \ |
|---|
| 837 | } \ |
|---|
| 838 | END { exit rc } \ |
|---|
| 839 | ' $mmsdrfsFile |
|---|
| 840 | rc=$? |
|---|
| 841 | |
|---|
| 842 | return $rc |
|---|
| 843 | |
|---|
| 844 | } #------ end of function dsmGetFileSystems ------------------- |
|---|
| 845 | |
|---|
| 846 | |
|---|
| 847 | ################################################################### |
|---|
| 848 | # |
|---|
| 849 | # Function: Check whether a given file system is local or remote. |
|---|
| 850 | # |
|---|
| 851 | # Input: $1 - file system device name |
|---|
| 852 | # $2 - (optional) assume cached data is current |
|---|
| 853 | # |
|---|
| 854 | # Output: 0 - file system is local |
|---|
| 855 | # 93 - file system is remote |
|---|
| 856 | # |
|---|
| 857 | # Returns: 0 - file system is local |
|---|
| 858 | # 93 - file system is remote |
|---|
| 859 | # 19 - file system not found |
|---|
| 860 | # nn - some other unexpected error |
|---|
| 861 | # |
|---|
| 862 | ################################################################### |
|---|
| 863 | function dsmIsFileSystemLocal # <deviceName> [<norefresh>] |
|---|
| 864 | { |
|---|
| 865 | typeset sourceFile="mmdsm.sh" |
|---|
| 866 | [[ -n $DEBUG || -n $DEBUGdsmIsFileSystemLocal ]] && set -x |
|---|
| 867 | $mmTRACE_ENTER "$*" |
|---|
| 868 | typeset device=$1 |
|---|
| 869 | typeset -l refreshArg=$2 |
|---|
| 870 | |
|---|
| 871 | typeset rc=0 |
|---|
| 872 | typeset gpfsInitOutput findFSoutput fqDeviceName deviceName fsHomeCluster |
|---|
| 873 | |
|---|
| 874 | # Ensure that the local copy of the mmsdrfs is up-to-date. |
|---|
| 875 | if [[ $refreshArg != "norefresh" ]] |
|---|
| 876 | then |
|---|
| 877 | gpfsInitOutput=$(gpfsInit nolock) |
|---|
| 878 | setGlobalVar $? $gpfsInitOutput |
|---|
| 879 | fi |
|---|
| 880 | |
|---|
| 881 | # Make sure the specified file system exists and is local. |
|---|
| 882 | findFSoutput=$(findFS "$device" $mmsdrfsFile) |
|---|
| 883 | rc=$? |
|---|
| 884 | [[ $rc -ne 0 || -z $findFSoutput ]] && return $rc |
|---|
| 885 | |
|---|
| 886 | # Parse the output from the findFS function. |
|---|
| 887 | set -f ; set -- $findFSoutput ; set +f |
|---|
| 888 | fqDeviceName=$1 |
|---|
| 889 | deviceName=$2 |
|---|
| 890 | fsHomeCluster=$3 |
|---|
| 891 | |
|---|
| 892 | # Figure out the proper return information. |
|---|
| 893 | if [[ $fsHomeCluster = $HOME_CLUSTER ]] |
|---|
| 894 | then |
|---|
| 895 | print -- "0" |
|---|
| 896 | rc=0 |
|---|
| 897 | else |
|---|
| 898 | print -- "$MM_Remotefs" |
|---|
| 899 | rc=$MM_Remotefs |
|---|
| 900 | fi |
|---|
| 901 | |
|---|
| 902 | return $rc |
|---|
| 903 | |
|---|
| 904 | } #------ end of function dsmIsFileSystemLocal ------------------- |
|---|
| 905 | |
|---|
| 906 | |
|---|
| 907 | ######################## |
|---|
| 908 | # Mainline processing |
|---|
| 909 | ######################## |
|---|
| 910 | |
|---|
| 911 | # Set local trap routine. |
|---|
| 912 | trap localPretrap HUP INT QUIT KILL |
|---|
| 913 | |
|---|
| 914 | [[ $dsmLog != "/dev/null" ]] && \ |
|---|
| 915 | print -- "$(date) ENTER: mmdsm $*" >> $dsmLog |
|---|
| 916 | |
|---|
| 917 | kword=$arg1 |
|---|
| 918 | if [[ -z $kword ]] |
|---|
| 919 | then |
|---|
| 920 | # Missing keyword |
|---|
| 921 | printErrorMsg 133 $mmcmd NULL |
|---|
| 922 | cleanupAndExit |
|---|
| 923 | fi |
|---|
| 924 | |
|---|
| 925 | # Determine the execution environment. |
|---|
| 926 | [[ -z $MMMODE ]] && determineMode 2>> $dsmLog |
|---|
| 927 | |
|---|
| 928 | # Make sure we have the proper credentials. |
|---|
| 929 | [[ $getCredCalled = no ]] && getCred 2>> $dsmLog |
|---|
| 930 | |
|---|
| 931 | |
|---|
| 932 | # Perform the requested action. |
|---|
| 933 | case $kword in |
|---|
| 934 | |
|---|
| 935 | #------------------------- |
|---|
| 936 | dsmGetClusterType) # mmdsm dsmGetClusterType |
|---|
| 937 | #------------------------- |
|---|
| 938 | # Retrieve the GPFS cluster type. |
|---|
| 939 | print -- "$MMMODE" |
|---|
| 940 | rc=$? |
|---|
| 941 | ;; |
|---|
| 942 | |
|---|
| 943 | #------------------------ |
|---|
| 944 | dsmGetNodeNumber) # mmdsm dsmGetNodeNumber |
|---|
| 945 | #------------------------ |
|---|
| 946 | # Retrieve the local node data. |
|---|
| 947 | getLocalNodeData 2>> $dsmLog |
|---|
| 948 | [[ -n $ourNodeNumber ]] && print -- "$ourNodeNumber" |
|---|
| 949 | rc=$? |
|---|
| 950 | ;; |
|---|
| 951 | |
|---|
| 952 | #------------------------ |
|---|
| 953 | dsmGetNodesetId) # mmdsm dsmGetNodesetId |
|---|
| 954 | #------------------------ |
|---|
| 955 | # Retrieve the nodeset name. |
|---|
| 956 | dsmGetNodesetId 2>> $dsmLog |
|---|
| 957 | rc=$? |
|---|
| 958 | ;; |
|---|
| 959 | |
|---|
| 960 | #------------------------ |
|---|
| 961 | dsmGetNodeCount) # mmdsm dsmGetNodeCount |
|---|
| 962 | #------------------------ |
|---|
| 963 | # Retrieve the number of nodes in the nodeset. |
|---|
| 964 | dsmGetNodeCount 2>> $dsmLog |
|---|
| 965 | rc=$? |
|---|
| 966 | ;; |
|---|
| 967 | |
|---|
| 968 | #---------------------------------------------------------- |
|---|
| 969 | dsmGetHsmdata) # mmdsm dsmGetHsmdata <nodesetId> <outputFile> [norefresh] |
|---|
| 970 | #---------------------------------------------------------- |
|---|
| 971 | if [[ $argc -lt 3 ]] |
|---|
| 972 | then |
|---|
| 973 | operands=" <nodesetId> <outputFile> [norefresh] " |
|---|
| 974 | printErrorMsg 260 $mmcmd $kword "$operands" |
|---|
| 975 | cleanupAndExit |
|---|
| 976 | fi |
|---|
| 977 | |
|---|
| 978 | # Retrieve the HSM data. |
|---|
| 979 | dsmGetHsmdata "$arg2" "$arg3" "$arg4" 2>> $dsmLog |
|---|
| 980 | rc=$? |
|---|
| 981 | ;; |
|---|
| 982 | |
|---|
| 983 | #------------------------------------------------------------- |
|---|
| 984 | dsmPutHsmdata) # mmdsm dsmPutHsmdata <nodesetId> <inputFile> |
|---|
| 985 | # [<versionFile> [<mmsdrfsVersion>]] |
|---|
| 986 | #------------------------------------------------------------- |
|---|
| 987 | if [[ $argc -lt 2 ]] |
|---|
| 988 | then |
|---|
| 989 | operands=" {<nodesetId> | DELETE} <inputFile> [<versionFile> [<mmsdrfsVersion>]] " |
|---|
| 990 | printErrorMsg 260 $mmcmd $kword "$operands" |
|---|
| 991 | cleanupAndExit |
|---|
| 992 | fi |
|---|
| 993 | |
|---|
| 994 | # Store the HSM data in the mmsdrfs file. |
|---|
| 995 | dsmPutHsmdata "$arg2" "$arg3" "$arg4" "$arg5" 2>> $dsmLog |
|---|
| 996 | rc=$? |
|---|
| 997 | ;; |
|---|
| 998 | |
|---|
| 999 | #------------------------------------------------- |
|---|
| 1000 | dsmGetHsmversion) # mmdsm dsmGetHsmversion <outputFile> [norefresh] |
|---|
| 1001 | #------------------------------------------------- |
|---|
| 1002 | if [[ $argc -lt 2 ]] |
|---|
| 1003 | then |
|---|
| 1004 | operands=" <outputFile> [norefresh] " |
|---|
| 1005 | printErrorMsg 260 $mmcmd $kword "$operands" |
|---|
| 1006 | cleanupAndExit |
|---|
| 1007 | fi |
|---|
| 1008 | |
|---|
| 1009 | # Retrieve the version information for the HSM data. |
|---|
| 1010 | dsmGetHsmversion "$arg2" "$arg3" 2>> $dsmLog |
|---|
| 1011 | rc=$? |
|---|
| 1012 | ;; |
|---|
| 1013 | |
|---|
| 1014 | #------------------------------------------------------- |
|---|
| 1015 | dsmPutHsmversion) # mmdsm dsmPutHsmversion <inputFile> [<mmsdrfsVersion>] |
|---|
| 1016 | #------------------------------------------------------- |
|---|
| 1017 | if [[ $argc -lt 2 ]] |
|---|
| 1018 | then |
|---|
| 1019 | operands=" <inputFile> [<mmsdrfsVersion>] " |
|---|
| 1020 | printErrorMsg 260 $mmcmd $kword "$operands" |
|---|
| 1021 | cleanupAndExit |
|---|
| 1022 | fi |
|---|
| 1023 | |
|---|
| 1024 | # Store the version information for the HSM data. |
|---|
| 1025 | dsmPutHsmversion "$arg2" "$arg3" 2>> $dsmLog |
|---|
| 1026 | rc=$? |
|---|
| 1027 | ;; |
|---|
| 1028 | |
|---|
| 1029 | #------------------------------------------- |
|---|
| 1030 | dsmGetConfigServerState) # mmdsm dsmGetConfigServerState [norefresh] |
|---|
| 1031 | #------------------------------------------- |
|---|
| 1032 | # Confirm that both config servers are available. |
|---|
| 1033 | getConfigServerState "$arg2" 2>> $dsmLog |
|---|
| 1034 | rc=$? |
|---|
| 1035 | ;; |
|---|
| 1036 | |
|---|
| 1037 | #-------------------------------------------------- |
|---|
| 1038 | dsmGetFileSystems) # mmdsm dsmGetFileSystems <outputFile> [norefresh] |
|---|
| 1039 | #-------------------------------------------------- |
|---|
| 1040 | if [[ $argc -lt 2 ]] |
|---|
| 1041 | then |
|---|
| 1042 | operands=" <outputFile> [norefresh] " |
|---|
| 1043 | printErrorMsg 260 $mmcmd $kword "$operands" |
|---|
| 1044 | cleanupAndExit |
|---|
| 1045 | fi |
|---|
| 1046 | |
|---|
| 1047 | # Retrieve the file system information. |
|---|
| 1048 | dsmGetFileSystems "$arg2" "$arg3" 2>> $dsmLog |
|---|
| 1049 | rc=$? |
|---|
| 1050 | ;; |
|---|
| 1051 | |
|---|
| 1052 | #----------------------------------------------------- |
|---|
| 1053 | dsmIsFileSystemLocal) # mmdsm dsmIsFileSystemLocal <deviceName> [norefresh] |
|---|
| 1054 | #----------------------------------------------------- |
|---|
| 1055 | if [[ $argc -lt 2 ]] |
|---|
| 1056 | then |
|---|
| 1057 | operands=" <deviceName> [<norefresh>] " |
|---|
| 1058 | printErrorMsg 260 $mmcmd $kword "$operands" |
|---|
| 1059 | cleanupAndExit |
|---|
| 1060 | fi |
|---|
| 1061 | |
|---|
| 1062 | # Find out if a file system is local or remote. |
|---|
| 1063 | dsmIsFileSystemLocal "$arg2" "$arg3" 2>> $dsmLog |
|---|
| 1064 | rc=$? |
|---|
| 1065 | ;; |
|---|
| 1066 | |
|---|
| 1067 | #-------------------------- |
|---|
| 1068 | * ) # Unknown action requested |
|---|
| 1069 | #-------------------------- |
|---|
| 1070 | # Invalid keyword |
|---|
| 1071 | printErrorMsg 133 $mmcmd $kword |
|---|
| 1072 | cleanupAndExit |
|---|
| 1073 | ;; |
|---|
| 1074 | |
|---|
| 1075 | esac # end Perform the requested action |
|---|
| 1076 | |
|---|
| 1077 | [[ $dsmLog != "/dev/null" ]] && \ |
|---|
| 1078 | print -- "$(date) EXIT (rc=$rc)" >> $dsmLog |
|---|
| 1079 | |
|---|
| 1080 | cleanupAndExit $rc 2>> $dsmLog |
|---|
| 1081 | |
|---|