# WSPlib.ctl: Defines Common Macros for IBM WebSphere Application Server # $Id: WSPlib.ctl,v 1.2 2013/10/30 07:18:34 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OFM/WSPlib.ctl,v 1.2 2013/10/30 07:18:34 RDA Exp $ # # Change History # 20130121 KRA Initial RDA 8 version. =head1 NAME OFM:WSPlib - Defines Common Macros for IBM WebSphere Application Server =head1 DESCRIPTION This persistent submodule regroups macros that are common to several IBM WebSphere Application Server related-modules. The following macro is available: =cut use Buffer # Make the module persistent and share macros keep $KEEP_BLOCK,@SHARE_MACROS var @SHARE_MACROS = ('wsp_show') =head2 S This macro returns the WSADMIN C and C command output in a tabular format aligned based on its data type. =cut macro wsp_show {var ($buf,$dat) = @arg import $TOP keep $TOP macro fmt_show {var ($val) = @arg return check(ref($val),'ARRAY',fmt_show_array($val),\ 'HASH', fmt_show_hash($val),\ encode($val)) } macro fmt_show_array {var ($val) = @arg var $buf = '%TBL%' var $pre = '(' loop $val (@{$val}) {var $buf = concat($buf,$pre,'%NEXT%',fmt_show($val)) var $pre = '%BR%' } return concat($buf,$pre,')%ENDTBL%') } macro fmt_show_hash {var ($val) = @arg var $buf = '%TBL%' var $pre = '{' loop $key (keys($val)) {var $buf = concat($buf,$pre,'%NEXT%',$key,'%NEXT%',fmt_show($val->{$key})) var $pre = '%BR%' } return concat($buf,$pre,'}%ENDTBL%') } var ($det,$lnk,$ttl,$loc,$rep) = split('\|',$dat,5) report replace($rep,'[\/\\]','r',true) prefix {write '---+!! ',$ttl if $loc write '---## Location: ',encode($loc) write '|*Name*|*Value*|' } var $hsh = parseWspShow($buf) loop $key (keys($hsh)) write '|',$key,' |',fmt_show($hsh->{$key}),' |' if isCreated(true) {write $TOP toc $det,':[[',getFile(),'][rda_report][',$lnk,']]' } } =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. =head1 TRADEMARK NOTICE Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. =cut