#! /bin/bash


# default libexecdir used to bootstrap scripts
libexecdir=${GLOBUS_LOCATION}/libexec

# load GRIS common code and initialization
. ${libexecdir}/grid-info-common

######################################################################

emit_resource_platform ()
{
cat <<EOF
${_line_class_dn}dn: $1
${_line_class_oc}objectclass: MdsHost
${_line_class_oc}objectclass: MdsComputer
${_line_class_oc}objectclass: MdsComputerTotal
${_line_class_av}Mds-Host-hn: ${hostname}
${_line_class_av}Mds-Computer-platform: ${_platform_name}
${_line_class_av}Mds-Computer-ISA: ${_platform_isa}
${_line_class_av}Mds-Computer-Total-nodeCount: 1
`emit_mds_object_timestamps`

EOF
}

emit_resource_platform_descriptions ()
{
    probe_mds_object_timestamps

    if [ "X${_dump_host_object}" = "Xtrue" ]
    then
	emit_resource_platform "${_suffix}"
    fi
}

probe_resource_platform ()
{
    # special-casing for AIX to get a human readable machine name
    if [ "`${GLOBUS_SH_UNAME-uname} -s`" == "AIX" ]; then
        _platform_name=`${GLOBUS_SH_UNAME-uname} -M`
    else
        _platform_name=`${GLOBUS_SH_UNAME-uname} -m`
    fi

 
    #
    # HP-UX does not do "uname -p", but we can make do...
    if [ -x /bin/hp-pa ]; then
      if /bin/hp-pa; then
          _platform_isa=PA-RISC
      else
          _platform_isa=IA64
      fi
    else

    # not HP-UX, so we can use uname -p to determine platform

         _platform_isa=`${GLOBUS_SH_UNAME-uname} -p`

        case "${_platform_name}:${_platform_isa}" in
	    i?86:unknown)
	        # handle linux silliness to be more like solaris and irix
	        _platform_isa=IA32
	        ;;
        esac
    fi


    # run this in initialized subshell environment
    emit_resource_platform_descriptions
}

#############
# do the work
probe_resource_platform

