#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/lib/ksh93/sa/KLIB_SA_add_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 # @(#)22 1.5 src/43haes/lib/ksh93/sa/KLIB_SA_add_metadata.sh, hacmp, 61haes_r714 11/28/11 15:18:31 # #=head1 NAME # # KLIB_SA_add_metadata - Add metadata to the smart assistant metadata ODM # #=head1 SYNOPSIS # # typeset application_id="SA_DB2Instance" # typeset sa_name="FILESYSTEM" # typeset sa_value="/db2home1/" # KLIB_SA_add_metadata $sa_type $sa_key $sa_name $sa_value || { # echo "Unable to add DB2 filesystem: $sa_value to the HACMP metadata for instance: $application_id" # } # #=head1 DESCRIPTION # # Add metadata to the smart assistant metadata ODM, this function will not # remove old SA metadata from the ODM with the same application_id and name, use # the update function to perform a remove then add in one operation # #=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 # 3: [scalar] value, the value to store as defined by the unique key (sa_type, sa_key, sa_name) # #=head1 RETURN # # 0 - success # 1 - failed # #=head1 COPYRIGHT # #(C) COPYRIGHT International Business Machines Corp. 2005 #All Rights Reserved # #=cut # function KLIB_SA_add_metadata { . /usr/es/lib/ksh93/func_include application_id=$1 shift name=$1 shift pvalue=$* if [[ -z $name || -z $application_id ]]; then return 1 fi # Is this key unique? KLIB_SA_get_metadata $application_id $name if [[ $? == 0 ]]; then return 1 else KLIB_SA_delete_metadata $application_id $name fi { echo "HACMPsa_metadata:" echo "\tapplication_id=\"$application_id\"" echo "\tname=\"$name\"" echo "\tvalue=\"$pvalue\"" } | odmadd 2>/dev/null return 0 }