#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/lib/ksh93/sa/KLIB_SA_delete_metadata.sh 1.5 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2005,2011 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)25	1.5 src/43haes/lib/ksh93/sa/KLIB_SA_delete_metadata.sh, hacmp, 61haes_r714 11/28/11 15:22:32
#
#=head1 NAME
# 
# KLIB_SA_delete_metadata - Delete an entry from the smart assistant metadata
#
#=head1 SYNOPSIS
#
# typeset application_id="SA_DB2Instance"
# typeset sa_name="FILESYSTEM"
# typeset sa_value="/db2home1/"
# KLIB_SA_delete_metadata $application_id $sa_name || {
#       echo "Unable to remove DB2 filesystem: $sa_value from the HACMP metadata for instance: $sa_key"
# }
#
#=head1 DESCRIPTION
#
# Removes an entry from the SA metadata ODM with the same application_id and name
#
#=head1 ARGUMENTS
#
#   1: [scalar] application_id, the unique key to identify the smart assistant amongst its peer type
#   2: [scalar] sa_name, the smart assistant name, as part of the name / value pair
#
#=head1 RETURN
#
#       0 - success,
#       1 - failed,
#
#=head1 COPYRIGHT
#
#(C) COPYRIGHT International Business Machines Corp. 2005
#All Rights Reserved
#
#=cut
#
function KLIB_SA_delete_metadata
{
	. /usr/es/lib/ksh93/func_include

	application_id=$1
	shift
	name=$1

	if [[ -z $name || -z $application_id ]]; then
		return 1
	fi
	value=$(KLIB_SA_get_metadata $application_id $name)
	if (( $? != 0 )); then
		return 1
	fi
	odmdelete -q "name = $name and application_id = $application_id" -o HACMPsa_metadata >/dev/null 2>&1
	return 0
}
