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 shell 变量的值设置为 1 (TRUE)。x 标记将捕获所更新特性的名称和值。如果 Confdir 是所更新的特性之一,则其值将放置在 CONFDIR shell 变量中,且变量 CONFDIR_FOUND 将设置为 1 (TRUE)。