#!/bin/ksh93 # ALTRAN_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # Copyright (C) Altran ACT S.A.S. 2017,2021. All rights reserved. # # ALTRAN_PROLOG_END_TAG # # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/lib/ksh93/db2/vg/KLIB_DB2_VG_lspv_as_hash.sh 1.8 # # 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 # @(#) 7d4c34b 43haes/lib/ksh93/db2/vg/KLIB_DB2_VG_lspv_as_hash.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM # #=head1 NAME # # KLIB_DB2_VG_lspv_as_hash - Gather the local lspv information and generate a ksh93 # hash table to represent the local AIX disk configuration # #=head1 SYNOPSIS # # KLIB_DB2_VG_lspv_as_hash > vg_hash_table.sh # . vg_hash_table.sh # vgs=$(KLIB_DB2_VG_get_vgs "nodeA") # #=head1 DESCRIPTION # # Gathers the local lspv information and generates a ksh93 hash table # to represent the local AIX disk configuration # #=head1 ARGUMENTS # # None # #=head1 RETURN # # Output is a hash table that can be sourced via a ksh93 script # no return code # #=head1 COPYRIGHT # #(C) COPYRIGHT International Business Machines Corp. 2005 #All Rights Reserved # #=cut # function KLIB_DB2_VG_lspv_as_hash { . /usr/es/lib/ksh93/func_include typeset -A VOLUME_GROUP_PVIDS typeset -A VOLUME_GROUP_STATES typeset -A VOLUME_GROUP_HDISKS typeset -A VOLUME_GROUP_CONCURRENT typeset concurrent RANDOM=$$ echo "AIX_DISKS_$RANDOM=( \\" lspv | while read hdisk pvid vg state; do concurrent= LC_ALL=C lsvg $vg 2>/dev/null | while IFS=':' read name value; do name=${name//[[:space:]]/} if [[ "$name" == "Concurrent" ]]; then echo $value | read value tmp concurrent=$value fi done 2>/dev/null VOLUME_GROUP_PVIDS[$vg]="${VOLUME_GROUP_PVIDS[$vg]} $pvid" VOLUME_GROUP_CONCURRENT[$vg]="$concurrent" if [[ -n $state ]]; then VOLUME_GROUP_STATES[$vg]="$state" fi VOLUME_GROUP_HDISKS[$vg]="${VOLUME_GROUP_HDISKS[$vg]} $hdisk" done for vg in ${!VOLUME_GROUP_PVIDS[*]}; do if [[ -n ${VOLUME_GROUP_CONCURRENT[$vg]} ]]; then echo "\t[CONCURRENT_""$vg""]=\"${VOLUME_GROUP_CONCURRENT[$vg]}\"" fi echo "\t[PVIDS_\"\$CLUSTER_NODE\"_$vg]=\"${VOLUME_GROUP_PVIDS[$vg]}\"" echo "\t[STATE_\"\$CLUSTER_NODE\"_$vg]=\"${VOLUME_GROUP_STATES[$vg]}\"" echo "\t[HDISKS_\"\$CLUSTER_NODE\"_$vg]=\"${VOLUME_GROUP_HDISKS[$vg]}\"" done echo ")" }