RGM は、ほかのコールバックメソッドとは異なる引数セットを Validate メソッドに渡すため、Validate メソッドには、ほかのメソッドとは異なる引数を構文解析する別の関数が必要です。Validate メソッドやそのほかのコールバックメソッドに渡される引数の詳細については、rt_callbacks(1HA)のマニュアルページを参照してください。次のコードサンプルに、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)、RGM から渡されるリソースタイプを取得するためのフラグ (T) を提供します。
r フラグ (システム定義プロパティーを示す)、g フラグ (リソースグループプロパティーを示す)、c フラグ (リソースの作成中に妥当性の検査が行われていることを示す) は無視されます。これらのフラグが無視されるのは、このメソッドはリソースが更新されるときに拡張プロパティーの妥当性を検査するために呼び出されるためです。
u フラグは、UPDATE_PROPERTY シェル変数の値を 1 (TRUE) に設定します。x フラグは、更新されているプロパティーの名前と値を取得します。更新されているプロパティーの中に Confdir が存在する場合、その値が CONFDIR シェル変数に格納され、CONFDIR_FOUND 変数が 1 (TRUE) に設定されます。