#!/bin/sh
# set -x
# 
#  Cancel job running in 3GBridge.
#  Input: grami file (same as Globus)

echo "----- starting cancel_DGBridge_job -----" 1>&2

joboption_lrms=DGBridge

# ARC1 passes first the config file.
if [ "$1" = "--config" ]; then shift; ARC_CONFIG=$1; shift; fi

basedir=`dirname $0`
basedir=`cd $basedir > /dev/null && pwd` || exit $?

pkgdatadir="$basedir"

. ${pkgdatadir}/cancel_common.sh $1 || exit $?

dgjobid=`echo "$joboption_jobid" |cut -f 2 -d \|`
echo "executing wsclient delete with endpoint $joboption_wsendpoint and job id $dgjobid" 1>&2
#remember to generalize endpoint to config file

wsclient -e $joboption_wsendpoint -m delete -j $dgjobid
if [ "$?" != "0" ];then
    echo "wsclient delete failed" 1>&2
fi

echo "----- exiting cancel_DGBridge_job -----" 1>&2
exit 0
