#! /bin/bash

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

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

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

emit_XML_MainMemory ()
{

# FIXME the uml diagram doesn't specify units
# so I should find out or make a decision myself
# at the moment, this provider emits in megabytes, whilst
# the java provider emits in bytes (I think)
cat <<EOF

<ce:MainMemory
  ce:VirtualSize="${_vm_size_mbytes}"
  ce:RAMSize="${_mem_size_mbytes}"
  ce:RAMAvailable="${_mem_free_mbytes}"
  ce:VirtualAvailable="${_vm_free_mbytes}"
  xmlns:ce="http://glue.base.ogsa.globus.org/ce/1.1"
/>

EOF
}


emit_resource_mem_descriptions ()
{
emit_XML_MainMemory
}

drop_echo ()
{
    echo $1
}

drop_M ()
{
    IFS=M
    drop_echo $1
    IFS="$IFS_save"
}

drop_K ()
{
    IFS=K
    drop_echo $1
    IFS="$IFS_save"
}

drop_MK ()
{
    case "$1" in
	*M)
	    drop_M $1
	    ;;
	*K)
	    $EXPR `drop_K $1` / 1024
	    ;;
    esac
}
