Print this page
6865006 ldom validate shouldn't check for password file if migration type is set to normal
6864993 HA-xVM validate messages need to be wrapped by gettext


  57 }
  58 
  59 scds_syslog()
  60 {
  61         if [ -f "${SCLOGGER}" ]
  62         then
  63            ${SCLOGGER} "$@" &
  64         else
  65            while getopts 'p:t:m' opt
  66            do
  67               case "${opt}" in
  68                  t) TAG=${OPTARG};;
  69                  p) PRI=${OPTARG};;
  70               esac
  71            done
  72       
  73            shift $((${OPTIND} - 1))
  74            LOG_STRING=$(/usr/bin/printf "$@")
  75            ${LOGGER} -p ${PRI} -t ${TAG} ${LOG_STRING}
  76         fi

  77 
  78         if [[ "${METHOD}" == "validate" ]]
  79         then
  80            shift 5
  81            /usr/bin/printf "$@"
  82         fi




  83 }
  84 
  85 debug_message()
  86 {
  87         typeset DEBUG_TEXT=
  88    
  89         case ${DEBUG_LEVEL} in
  90            0)   # No debug msgs
  91               SET_DEBUG=
  92               ;;
  93            1)  # Begin and End msgs
  94               SET_DEBUG=
  95               DEBUG_TEXT=$(echo ${1} | ${GREP} -E 'Begin|End')
  96               ;;
  97            2)  # All debug msgs
  98               SET_DEBUG="set -x"
  99               DEBUG_TEXT=${1}
 100               ;;
 101         esac
 102    


 197               # @user_action
 198               # Check the syslog for further messages.
 199               scds_syslog -p daemon.error -t $(syslog_tag) -m \
 200                    "Cannot get the property %s of resource %s." \
 201                    "${prop}" "${RESOURCE}"
 202               break
 203            fi
 204         done
 205    
 206         debug_message "Function: get_properties - End"
 207    
 208         return ${rc}
 209 }
 210 
 211 validate_xvm()
 212 {
 213         debug_message "Function: validate_xvm - Begin"
 214         ${SET_DEBUG}
 215 
 216         typeset rc=0

 217    
 218         if [ "$(/usr/bin/uname -i)" != "i86xpv" ]
 219         then
 220            # SCMSGS
 221            # @explanation
 222            # Solaris is not booted with xVM.
 223            # @user_action
 224            # Ensure that the default boot grub menu is set to boot
 225            # Solaris xVM.
 226            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 227                 "Node is not booted with xVM."
 228 



 229            rc=1
 230         fi
 231 
 232         debug_message "Function: validate_xvm - End"
 233 
 234         return ${rc}
 235 }
 236 
 237 validate_ldom()
 238 {
 239         debug_message "Function: validate_ldom - Begin"
 240         ${SET_DEBUG}
 241 
 242         typeset ncount=0

 243 
 244         # Make sure that the password file is readable.
 245         if [ ! -r "${PASSWORD_FILE}" ]
 246         then


 247            # SCMSGS
 248            # @explanation

















 249            # Incorrect Password file specified.
 250            # @user_action
 251            # Ensure that a valid password file is specified.
 252            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 253               "Invalid password file specified %s." \
 254               "${PASSWORD_FILE}"
 255 



 256            debug_message "Function: validate_ldom - End"
 257            return 1
 258         fi

 259         
 260         # Ensure that the control domain is a cluster node.
 261         if ! ${LDM} ls > /dev/null 2>&1
 262         then
 263            # SCMSGS
 264            # @explanation
 265            # Self explanatory.
 266            # @user_action
 267            # Ensure that the resource is configured in
 268            # control domain.
 269            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 270                "The LDom Manager is running in configuration mode."
 271 



 272               debug_message "Function: validate_ldom - End"
 273            return 1
 274         fi
 275 
 276         # Ensure that the failure-policy setting is set to "reset".
 277         # If the control domain fails,this would allow the guest domains
 278         # to panic. 
 279         policy=$(${LDM} list -o domain primary \
 280             | ${AWK} -F"=" '$1~/failure-policy/ {print $2}')
 281 
 282         if [ "${policy}" != "reset" ]
 283         then
 284            # SCMSGS
 285            # @explanation
 286            # Incorrect failure-policy setting for the domain.
 287            # @user_action
 288            # Ensure that the failure-policy for the domain is
 289            # set to "reset" on the control domain.
 290            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 291               "Invalid failure policy \"%s\" for %s domain." \
 292               "${policy}" "primary"
 293 



 294            debug_message "Function: validate_ldom - End"
 295            return 1
 296         fi
 297 
 298         # The CL_EXEC_CLIENT program executes a command on any of the 
 299         # cluster nodes or a zone or in a zone cluster. It then generates
 300         # as output the exit status of command and the stdout and stderr
 301         # messages. The valid options are:
 302         #     [ -z zoneclustername] The command is run on the zone cluster
 303         # represented by the zonename.
 304         #     -C { TS | RT | FSS | FX } The scheduling class in which the
 305         #  command is to be run.
 306         #     -p pri Specifies the priority of the command in the given
 307         # scheduling class.
 308         #     -n id[,id..] A comma seperated list of node ID's of a
 309         # zone cluster or a node to run the command.
 310         #     -c cmd [Args] The command to be run along with its arguments.
 311 
 312         for nodename in $(${SCHA_RESOURCEGROUP_GET} -O NODELIST -G ${RESOURCEGROUP})
 313         do
 314            if [[ "$(${SCHA_CLUSTER_GET} -O NodeState_Node ${nodename})" == "DOWN" ]]
 315            then
 316               continue
 317            fi
 318 
 319            nodeid=$(${SCHA_CLUSTER_GET} -O NODEID_NODENAME ${nodename})
 320            output=$(${CL_EXEC_CLIENT} -n ${nodeid} -c "${LDM} list-domain ${DOMAIN}")
 321            result=${?}
 322 
 323            status=$(echo ${output} | ${AWK} '{print $6}')
 324 
 325            if (( ${result} == 0 )) && (( ${status} == 0 ))
 326            then
 327               domstate=$(echo $output | ${AWK} -F" " '{print $18}')     
 328 
 329               if (( ${update} == 0)) && echo $domstate | ${GREP} -q -E "^active$|suspending|resuming|suspended|starting" > /dev/null 2>&1
 330               then
 331                  # SCMSGS
 332                  # @explanation
 333                  # The domain is in an invalid state.
 334                  # @user_action
 335                  # Ensure that the domain is in inactive or bound state.
 336                  scds_syslog -p daemon.error -t $(syslog_tag) -m \
 337                     "Domain %s is in %s state on %s." \
 338                     "${DOMAIN}" "${domstate}" "${nodename}"
 339 



 340                  debug_message "Function: validate_ldom - End"
 341                  return 1
 342               fi
 343 
 344               ncount=$((ncount+1))
 345               nlist=$(echo ${nodename} ${nlist})
 346 
 347               # dump domain confguration to ccr
 348               if [[ "$(/usr/bin/hostname)" == "${nodename}" ]]
 349               then
 350                  if ! dump_domain_config
 351                  then
 352                     debug_message "Function: validate_ldom - End"
 353                     return 1
 354                  fi
 355               fi
 356             fi
 357         done
 358 
 359         if (( ${ncount} == 0 ))
 360         then
 361            if ! ${CCRADM} showkey --key xml_${RESOURCE} ${CCR_TABLE} > /dev/null 2>&1
 362            then
 363               scds_syslog -p daemon.error -t $(syslog_tag) -m \
 364                  "Domain %s does not exist." \
 365                  "${DOMAIN}"




 366               return 1
 367            fi
 368         fi
 369 
 370         if [[ ${ncount} -gt 1 ]]
 371         then
 372            # SCMSGS
 373            # @explanation
 374            # The domain is configured on multiple 
 375            # cluster nodes.
 376            # @user_action
 377            # Ensure that the domain is configured on one node
 378            # of the cluster.
 379            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 380               "Multiple domain %s configuration exists on %s." \
 381               "${DOMAIN}" "${nlist}"




 382            return 1
 383         fi
 384 
 385         debug_message "Function: validate_ldom - End"
 386         return 0
 387 }
 388 
 389 validate()
 390 {
 391         debug_message "Function: validate - Begin"
 392         ${SET_DEBUG}
 393 
 394         typeset rc
 395 
 396         # Make sure that the plugin probe specified is readable.
 397         if [[ -n "${PLUGIN_PROBE}" ]]
 398         then
 399            if [ -f "${PLUGIN_PROBE}" ] && [ ! -r "${PLUGIN_PROBE}" ]
 400            then
 401                # SCMSGS
 402                # @explanation
 403                # Incorrect user probe file specified.
 404                # @user_action
 405                # Ensure that a valid user probe file is specified.
 406                scds_syslog -p daemon.error -t $(syslog_tag) -m \
 407                    "Invalid user probe file %s." \
 408                    "${PLUGIN_PROBE}"
 409 



 410                return 1
 411            fi
 412         fi
 413    
 414         validate_${VM}
 415         rc=${?}   
 416 
 417         debug_message "Function: validate - End"
 418         return ${rc}
 419 }
 420 
 421 #
 422 # get the domain status 
 423 #
 424 get_xvm_status()
 425 {
 426         debug_message "Function: get_xvm_status - Begin"
 427         ${SET_DEBUG}
 428 
 429         typeset rc




  57 }
  58 
  59 scds_syslog()
  60 {
  61         if [ -f "${SCLOGGER}" ]
  62         then
  63            ${SCLOGGER} "$@" &
  64         else
  65            while getopts 'p:t:m' opt
  66            do
  67               case "${opt}" in
  68                  t) TAG=${OPTARG};;
  69                  p) PRI=${OPTARG};;
  70               esac
  71            done
  72       
  73            shift $((${OPTIND} - 1))
  74            LOG_STRING=$(/usr/bin/printf "$@")
  75            ${LOGGER} -p ${PRI} -t ${TAG} ${LOG_STRING}
  76         fi
  77 }
  78 
  79 i18n_message()
  80 {
  81         debug_message "Function: i18n_message - Begin"
  82         ${DEBUG}
  83 
  84         print -u2 $(/bin/printf "$@")
  85 
  86         debug_message "Function: i18n_message - End"
  87         return 0
  88 }
  89 
  90 debug_message()
  91 {
  92         typeset DEBUG_TEXT=
  93    
  94         case ${DEBUG_LEVEL} in
  95            0)   # No debug msgs
  96               SET_DEBUG=
  97               ;;
  98            1)  # Begin and End msgs
  99               SET_DEBUG=
 100               DEBUG_TEXT=$(echo ${1} | ${GREP} -E 'Begin|End')
 101               ;;
 102            2)  # All debug msgs
 103               SET_DEBUG="set -x"
 104               DEBUG_TEXT=${1}
 105               ;;
 106         esac
 107    


 202               # @user_action
 203               # Check the syslog for further messages.
 204               scds_syslog -p daemon.error -t $(syslog_tag) -m \
 205                    "Cannot get the property %s of resource %s." \
 206                    "${prop}" "${RESOURCE}"
 207               break
 208            fi
 209         done
 210    
 211         debug_message "Function: get_properties - End"
 212    
 213         return ${rc}
 214 }
 215 
 216 validate_xvm()
 217 {
 218         debug_message "Function: validate_xvm - Begin"
 219         ${SET_DEBUG}
 220 
 221         typeset rc=0
 222         typeset msgtext
 223    
 224         if [ "$(/usr/bin/uname -i)" != "i86xpv" ]
 225         then
 226            # SCMSGS
 227            # @explanation
 228            # Solaris is not booted with xVM.
 229            # @user_action
 230            # Ensure that the default boot grub menu is set to boot
 231            # Solaris xVM.
 232            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 233                 "Node is not booted with xVM."
 234 
 235            msgtext=$(gettext "Node is not booted with xVM.")
 236            i18n_message "${msgtext}" 
 237 
 238            rc=1
 239         fi
 240 
 241         debug_message "Function: validate_xvm - End"
 242 
 243         return ${rc}
 244 }
 245 
 246 validate_ldom()
 247 {
 248         debug_message "Function: validate_ldom - Begin"
 249         ${SET_DEBUG}
 250 
 251         typeset ncount=0
 252         typeset msgtext
 253 
 254         # Make sure that the password file is readable.
 255         if [[ ${MIGRATION_TYPE} != "NORMAL" ]]
 256         then
 257            if [ -z "${PASSWORD_FILE}" ]
 258            then
 259               # SCMSGS
 260               # @explanation
 261               # Password file cannot be null.
 262               # @user_action
 263               # Ensure that a password file name is specified.
 264               scds_syslog -p daemon.error -t $(syslog_tag) -m \
 265                  "Password file cannot be (null)."
 266 
 267               msgtext=$(gettext "Password file cannot be (null).")
 268               i18n_message "${msgtext}"
 269 
 270               debug_message "Function: validate_ldom - End"
 271               return 1
 272            fi
 273 
 274            if [[ ! -f "${PASSWORD_FILE}" ]] || [[ ! -r "${PASSWORD_FILE}" ]]
 275            then
 276               # SCMSGS
 277               # @explanation
 278               # Incorrect Password file specified.
 279               # @user_action
 280               # Ensure that a valid password file is specified.
 281               scds_syslog -p daemon.error -t $(syslog_tag) -m \
 282                  "Invalid password file specified %s." \
 283                  "${PASSWORD_FILE}"
 284 
 285               msgtext=$(gettext "Invalid password file specified %s.")
 286               i18n_message "${msgtext}" "${PASSWORD_FILE}"
 287 
 288               debug_message "Function: validate_ldom - End"
 289               return 1
 290            fi
 291         fi
 292         
 293         # Ensure that the control domain is a cluster node.
 294         if ! ${LDM} ls > /dev/null 2>&1
 295         then
 296            # SCMSGS
 297            # @explanation
 298            # Self explanatory.
 299            # @user_action
 300            # Ensure that the resource is configured in
 301            # control domain.
 302            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 303                "The LDom Manager is running in configuration mode."
 304 
 305            msgtext=$(gettext "The LDom Manager is running in configuration mode.")
 306            i18n_message "${msgtext}"
 307 
 308            debug_message "Function: validate_ldom - End"
 309            return 1
 310         fi
 311 
 312         # Ensure that the failure-policy setting is set to "reset".
 313         # If the control domain fails,this would allow the guest domains
 314         # to panic. 
 315         policy=$(${LDM} list -o domain primary \
 316             | ${AWK} -F"=" '$1~/failure-policy/ {print $2}')
 317 
 318         if [ "${policy}" != "reset" ]
 319         then
 320            # SCMSGS
 321            # @explanation
 322            # Incorrect failure-policy setting for the domain.
 323            # @user_action
 324            # Ensure that the failure-policy for the domain is
 325            # set to "reset" on the control domain.
 326            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 327               "Invalid failure policy \"%s\" for %s domain." \
 328               "${policy}" "primary"
 329 
 330            msgtext=$(gettext "Invalid failure policy \"%s\" for %s domain.")
 331            i18n_message "${msgtext}" "${policy}" "primary"
 332 
 333            debug_message "Function: validate_ldom - End"
 334            return 1
 335         fi
 336 
 337         # The CL_EXEC_CLIENT program executes a command on any of the 
 338         # cluster nodes or a zone or in a zone cluster. It then generates
 339         # as output the exit status of command and the stdout and stderr
 340         # messages. The valid options are:
 341         #     [ -z zoneclustername] The command is run on the zone cluster
 342         # represented by the zonename.
 343         #     -C { TS | RT | FSS | FX } The scheduling class in which the
 344         #  command is to be run.
 345         #     -p pri Specifies the priority of the command in the given
 346         # scheduling class.
 347         #     -n id[,id..] A comma seperated list of node ID's of a
 348         # zone cluster or a node to run the command.
 349         #     -c cmd [Args] The command to be run along with its arguments.
 350 
 351         for nodename in $(${SCHA_RESOURCEGROUP_GET} -O NODELIST -G ${RESOURCEGROUP})
 352         do
 353            if [[ "$(${SCHA_CLUSTER_GET} -O NodeState_Node ${nodename})" == "DOWN" ]]
 354            then
 355               continue
 356            fi
 357 
 358            nodeid=$(${SCHA_CLUSTER_GET} -O NODEID_NODENAME ${nodename})
 359            output=$(${CL_EXEC_CLIENT} -n ${nodeid} -c "${LDM} list-domain ${DOMAIN}")
 360            result=${?}

 361            status=$(echo ${output} | ${AWK} '{print $6}')
 362 
 363            if (( ${result} == 0 )) && (( ${status} == 0 ))
 364            then
 365               domstate=$(echo $output | ${AWK} -F" " '{print $18}')     
 366 
 367               if (( ${update} == 0)) && echo $domstate | ${GREP} -q -E "^active$|suspending|resuming|suspended|starting" > /dev/null 2>&1
 368               then
 369                  # SCMSGS
 370                  # @explanation
 371                  # The domain is in an invalid state.
 372                  # @user_action
 373                  # Ensure that the domain is in inactive or bound state.
 374                  scds_syslog -p daemon.error -t $(syslog_tag) -m \
 375                     "Domain %s is in %s state on %s." \
 376                     "${DOMAIN}" "${domstate}" "${nodename}"
 377 
 378                    msgtext=$(gettext "Domain %s is in %s state on %s.")
 379                    i18n_message "${msgtext}" "${DOMAIN}" "${domstate}" "${nodename}"
 380 
 381                  debug_message "Function: validate_ldom - End"
 382                  return 1
 383               fi
 384 
 385               ncount=$((ncount+1))
 386               nlist=$(echo ${nodename} ${nlist})
 387 
 388               # dump domain confguration to ccr
 389               if [[ "$(/usr/bin/hostname)" == "${nodename}" ]]
 390               then
 391                  if ! dump_domain_config
 392                  then
 393                     debug_message "Function: validate_ldom - End"
 394                     return 1
 395                  fi
 396               fi
 397             fi
 398         done
 399 
 400         if (( ${ncount} == 0 ))
 401         then
 402            if ! ${CCRADM} showkey --key xml_${RESOURCE} ${CCR_TABLE} > /dev/null 2>&1
 403            then
 404               scds_syslog -p daemon.error -t $(syslog_tag) -m \
 405                  "Domain %s does not exist." \
 406                  "${DOMAIN}"
 407 
 408               msgtext=$(gettext "Domain %s does not exist.")
 409               i18n_message "${msgtext}" "${DOMAIN}"
 410 
 411               return 1
 412            fi
 413         fi
 414 
 415         if [[ ${ncount} -gt 1 ]]
 416         then
 417            # SCMSGS
 418            # @explanation
 419            # The domain is configured on multiple 
 420            # cluster nodes.
 421            # @user_action
 422            # Ensure that the domain is configured on one node
 423            # of the cluster.
 424            scds_syslog -p daemon.error -t $(syslog_tag) -m \
 425               "Multiple domain %s configuration exists on %s." \
 426               "${DOMAIN}" "${nlist}"
 427 
 428               msgtext=$(gettext "Multiple domain %s configuration exists on %s.")
 429               i18n_message "${msgtext}" "${DOMAIN}" "${nlist}"
 430 
 431            return 1
 432         fi
 433 
 434         debug_message "Function: validate_ldom - End"
 435         return 0
 436 }
 437 
 438 validate()
 439 {
 440         debug_message "Function: validate - Begin"
 441         ${SET_DEBUG}
 442 
 443         typeset rc
 444 
 445         # Make sure that the plugin probe specified is readable.
 446         if [[ -n "${PLUGIN_PROBE}" ]]
 447         then
 448            if [ -f "${PLUGIN_PROBE}" ] && [ ! -r "${PLUGIN_PROBE}" ]
 449            then
 450                # SCMSGS
 451                # @explanation
 452                # Incorrect user probe file specified.
 453                # @user_action
 454                # Ensure that a valid user probe file is specified.
 455                scds_syslog -p daemon.error -t $(syslog_tag) -m \
 456                    "Invalid user probe file %s." \
 457                    "${PLUGIN_PROBE}"
 458 
 459                msgtext=$(gettext "Invalid user probe file %s.")
 460                i18n_message "${msgtext}" "${PLUGIN_PROBE}"
 461 
 462                return 1
 463            fi
 464         fi
 465    
 466         validate_${VM}
 467         rc=${?}   
 468 
 469         debug_message "Function: validate - End"
 470         return ${rc}
 471 }
 472 
 473 #
 474 # get the domain status 
 475 #
 476 get_xvm_status()
 477 {
 478         debug_message "Function: get_xvm_status - Begin"
 479         ${SET_DEBUG}
 480 
 481         typeset rc