source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmlspolicy @ 16

Last change on this file since 16 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 6.2 KB
Line 
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. 2005,2006
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# @(#)85 1.3 src/avs/fs/mmfs/ts/admin/mmlspolicy.sh, mmfs, avs_rgpfs24, rgpfs240610b 1/23/06 01:57:02
17#######################################################################
18#
19# Usage:  mmlspolicy Device [-L]
20#
21#######################################################################
22
23# Include global declarations and service routines.
24. /usr/lpp/mmfs/bin/mmglobfuncs
25if [[ $ourUid -eq 0 ]]
26then
27  . /usr/lpp/mmfs/bin/mmsdrfsdef
28  . /usr/lpp/mmfs/bin/mmfsfuncs
29fi
30
31sourceFile="mmlspolicy.sh"
32[[ -n $DEBUG || -n $DEBUGmmlspolicy ]] && set -x
33$mmTRACE_ENTER "$*"
34
35usageMsg=358
36integer rc=0
37integer nodeCount=0
38
39
40#####################################################################
41# Process the command arguments.
42# The detailed syntax checking is left for the ts command.
43# Here we make sure that we have the minimum needed to continue.
44#####################################################################
45[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
46  syntaxError "help" $usageMsg
47
48[[ $argc -lt 1  ]] &&  \
49  syntaxError "missingArgs" $usageMsg
50
51device=$arg1     # Save stripe group device (always the first parameter).
52shift 1          # Drop the device name from the parameter list.
53argList=$@       # Save the remainder of the argument list.
54
55
56###################################
57# Set up trap exception handling.
58###################################
59trap pretrap2 HUP INT QUIT KILL
60
61
62####################################################################
63# If invoked by a root user, call the gpfsInit function to ensure
64# that the local copy of the mmsdrfs file and the rest of the GPFS
65# system files are up-to-date.  There is no need to lock the sdr.
66# Non-root users are not allowed to invoke commands on other nodes.
67####################################################################
68if [[ $ourUid -eq 0 ]]
69then
70  gpfsInitOutput=$(gpfsInit nolock)
71  setGlobalVar $? $gpfsInitOutput
72fi
73
74
75####################################
76# Make sure the file system exists.
77####################################
78# If the invocation is not for an explicitly-remote device, obtain the
79# needed information about the filesystem from the mmsdrfs file.
80if [[ $device != *:* ]]
81then
82  findFSoutput=$(findFS "$device" $mmsdrfsFile)
83  [[ -z $findFSoutput ]] && cleanupAndExit
84
85  # Parse the output from the findFS function.
86  set -f ; set -- $findFSoutput ; set +f
87  fqDeviceName=$1
88  deviceName=$2
89  fsHomeCluster=$3
90  remoteDevice=$4
91
92  # If this is a remote file system, set fqDeviceName appropriately.
93  [[ $fsHomeCluster != $HOME_CLUSTER ]] &&  \
94    fqDeviceName="$fsHomeCluster:/dev/$remoteDevice"
95else
96  fqDeviceName=$device
97  deviceName=${fqDeviceName##*:}
98  fsHomeCluster=${fqDeviceName%%:*}
99  remoteDevice=$deviceName
100fi
101
102
103########################################################################
104# Invoke the command on the local node.
105# Display any error messages and exit if any of the following are true:
106#   - the command completed successfully
107#   - there is an unacceptable error
108#       (anything other than daemon down or quorum wait)
109#   - the file system is remote
110#   - we are not running as UID 0
111#   - this is a single node cluster
112########################################################################
113${mmcmdDir}/${links}/mmlspolicy $fqDeviceName $argList 2>$errMsg
114rc=$(remapRC $?)
115if [[ ($rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait) ||
116      $fsHomeCluster != $HOME_CLUSTER                    ||
117      $ourUid -ne 0                                      ||
118      $MMMODE = single ]]
119then
120  if [[ $rc -eq $MM_FsNotFound ]]
121  then
122    if [[ $fsHomeCluster != $HOME_CLUSTER ]]
123    then
124      # The remote cluster does not know anything about this file system.
125      printErrorMsg 108 $mmcmd $remoteDevice $fsHomeCluster
126    else
127      # Unexpected error.
128      printErrorMsg 171 $mmcmd "file system $deviceName not found" $rc
129    fi
130  elif [[ $rc -eq $MM_Remotefs && $fsHomeCluster != $HOME_CLUSTER ]]
131  then
132    # The file system is not owned by the remote cluster.
133    [[ $device != *:* ]] &&  \
134      printErrorMsg 111 $mmcmd $device $remoteDevice $fsHomeCluster
135    printErrorMsg 112 $mmcmd $remoteDevice $fsHomeCluster
136  elif [[ ($rc -eq $MM_HostDown    ||
137           $rc -eq $MM_TimedOut    ||
138           $rc -eq $MM_SecurityCfg ||
139           $rc -eq $MM_AuthorizationFailed ||
140           $rc -eq $MM_UnknownCluster)    &&
141          $fsHomeCluster != $HOME_CLUSTER ]]
142  then
143    # Failed to connect to the remote cluster.
144    [[ $rc -eq $MM_SecurityCfg ]] &&  \
145      printErrorMsg 150 $mmcmd
146    [[ $rc -eq $MM_AuthorizationFailed ]] &&  \
147      printErrorMsg 151 $mmcmd
148    printErrorMsg 105 $mmcmd $fsHomeCluster
149  elif [[ $rc -eq $MM_DaemonDown ]]
150  then
151    # GPFS is down on this node.
152    printErrorMsg 109 $mmcmd
153  elif [[ $rc -eq $MM_QuorumWait ]]
154  then
155    # GPFS is not ready for commands.
156    printErrorMsg 110 $mmcmd
157  elif [[ $rc -eq $MM_ConnectionReset ]]
158  then
159    # An internode connection was reset.
160    printErrorMsg 257 $mmcmd
161  else
162    # Either the command worked, or it is an unexpected error.
163    [[ -s $errMsg ]] && $cat $errMsg 1>&2
164#   [[ $rc -ne 0 ]] && printErrorMsg 113 "$mmcmd" "tslspolicy $fqDeviceName" $rc
165  fi  # end of if [[ $rc -eq $MM_FsNotFound ]]
166  cleanupAndExit $rc
167fi  # end of if [[ ($rc -ne $MM_DaemonDown && ... ]]
168$rm -f $errMsg
169
170
171#######################################################################
172# We come here if the file system is local but the local daemon is not
173# available.  Find an active node and send the command there.
174#######################################################################
175
176# Create a file with the reliable names of the nodes in the cluster.
177getNodeList $REL_HOSTNAME_Field $GLOBAL_ID $mmsdrfsFile > $nodefile
178preferredNode=$ourNodeName
179
180# Try the nodes one by one until you find a node that can execute the command.
181$mmcommon linkCommand $preferredNode $nodefile mmlspolicy $fqDeviceName $argList
182rc=$?
183
184cleanupAndExit $rc
185
Note: See TracBrowser for help on using the repository browser.