Sun Cluster 資料服務開發者指南 (適用於 Solaris 作業系統)

Validate 方法剖析函式

RGM 將對 Validate 方法傳送一組與其他回呼方法不同的參數,因此 Validate 需要與其他方法不同的剖析引數之函式。請參閱 rt_callbacks(1HA) 線上說明手冊,以取得有關傳送至 Validate 與其他回呼方法之參數的詳細資訊。以下說明了 Validate parse_args() 函式。


#########################################################################
# Parse Validate arguments.
#
function parse_args # [args...]
{

   typeset opt
   while getopts 'cur:x:g:R:T:G:' opt
   do
         case "$opt" in
         R)
                  # Name of the DNS resource.
                  RESOURCE_NAME=$OPTARG
                  ;;
         G)
                  # Name of the resource group in which the resource is
                  # configured.
                  RESOURCEGROUP_NAME=$OPTARG
                  ;;
         T)
                  # Name of the resource type.
                  RESOURCETYPE_NAME=$OPTARG
                  ;;
         r)
                  # The method is not accessing any system defined
                  # properties so this is a no-op
                  ;;
         g)
                  # The method is not accessing any resource group
                  # properties, so this is a no-op
                  ;;
         c)
                  # Indicates the Validate method is being called while
                  # creating the resource, so this flag is a no-op.
                  ;;
         u)
                  # Indicates the updating of a property when the
                  # resource already exists. If the update is to the
                  # Confdir property then Confdir should appear in the 
                  # command-line arguments. If it does not, the method must 
                  # look for it specifically using scha_resource_get.
                  UPDATE_PROPERTY=1
                  ;;
         x)
                  # Extension property list. Separate the property and 
                  # value pairs using "=" as the separator.
                  PROPERTY=`echo $OPTARG | awk -F= '{print $1}'`
                  VAL=`echo $OPTARG | awk -F= '{print $2}'`
                  # If the Confdir extension property is found on the 
                  # command line, note its value. 
                  if [ $PROPERTY == "Confdir" ]; then
                           CONFDIR=$VAL
                           CONFDIR_FOUND=1
                  fi
                  ;;
         *)
                  logger -p ${SYSLOG_FACILITY}.err \
                  -t [$SYSLOG_TAG] \
                  "ERROR: Option $OPTARG unknown"
                  exit 1
                  ;;
         esac
   done
}

與其他方法的 parse_args() 函式一樣,此函式將提供三個旗號:提供 R 抓取資源名稱,提供 G 抓取資源群組名稱,以及提供 T 抓取 RGM 傳送的資源類型。

將忽略旗號 r (指示系統定義的特性)、旗號 g (指示資源群組特性) 以及旗號 c (指示驗證發生在建立資源期間),因為將在更新資源時呼叫此方法來驗證延伸特性。

u 旗號將 UPDATE_PROPERTY shell 變數的值設定為 1 (TRUE)。x 旗號抓取正在更新的特性之名稱與值。如果 Confdir 是正更新的特性之一,其值將置於 CONFDIR shell 變數中,且變數 CONFDIR_FOUND 設定為 1 (TRUE)。