# WLSlib.def: Defines Common Macros for Oracle WebLogic Server # $Id: WLSlib.def,v 1.10 2012/01/03 13:34:48 mschenke Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_4/src/scripting/lib/modules/WLSlib.def,v 1.10 2012/01/03 13:34:48 mschenke Exp $ # # Change History # 20120103 MSC Change the copyright notice. =head1 NAME WLSlib - Defines Common Macros for Oracle WebLogic Server =head1 DESCRIPTION This persistent submodule regroups macros that are common to several Oracle WebLogic Server related-modules. The following macros are available: =cut use Buffer # Make the module persistent and share macros keep $KEEP_BLOCK,@SHARE_MACROS var @SHARE_MACROS = ('dsp_manifest','get_config','MBean','write_list') =head2 S This macro looks in the specified directory tree for all C<*.ear>, C<*.jar>, and C<*.war> files that contain the C word in the path and extracts the MANIFEST information from them. It requires the availability of F command. =head2 S This macro extracts the MANIFEST information from a fixed set of files passed as an array reference. =cut macro dsp_manifest {var ($lvl,$arg) = @arg import $TOP keep $TOP # Check for unzip availability var $cmd = findCommand('unzip') if !length($cmd) return # Filter the file list if ref($arg) {loop $fil (@{$arg}) var $fil{dirname($fil),basename($fil)} = $fil } else {var $pat = '(apache|com\.bea\.cie\.|com\.bea\.core\.apache\.|\ com\.oracle\.cie\.|help|javax\.|\bjdk|org\.apache\.ant)' loop $sub (findDir($arg,'^(\.+|help|jdk)$','vn')) {loop $fil (grepDir(catDir($arg,$sub),'\.([ejw]ar)$','ir')) {next !match($fil,'\bmodules\b') next match($fil,$pat,true) var $fil{dirname($fil),basename($fil)} = $fil } } } # Generate the reports and related index links loop $grp (keys(%fil)) {# Start a new directory debug ' Inside dsp_manifest, searching ',$grp output F,manifest_info title '---+!! Manifest Information from ',encode($grp),' Directory' title '%TOC3-2%' # Gather the manifest information associated with the files loop $nam (keys($fil{$grp})) {var $fil = $fil{$grp,$nam} prefix {write '---++ ',encode($nam) call statFile('b',$fil) } call writeCommand(concat($cmd,' -p ',$fil,' META-INF/MANIFEST.MF')) if hasOutput(true) write $TOP } # Add relevant report to the table of content if isCreated(true) toc $lvl,':[[',getFile(),'][rda_report][From ',encode(addSymbol($grp)),']]' } } =head2 S This macro returns the configuration files. It skips top entries matching the pattern specified. Unless the flag is set, it captures the C<.property> and C<.xml> files only. =cut macro get_config {var (\@tbl,$dir,$pat,$flg) = @arg # Analyze the directory loop $fil (grepDir($dir,'^\.+$','vn')) {next match($fil,$pat,true) var $pth = catFile($dir,$fil) if testDir('d',$pth) call push(@sub,$pth) elsif $flg call push(@tbl,$pth) elsif match($pth,'\.(properties|xml)$',true) call push(@tbl,$pth) } # Treat the subdirectories loop $sub (@sub) call get_config(\@tbl,$sub,'^servers$',$flg) } =head2 S This macro returns the WLST output in a table format. =cut macro MBean {var ($buf,$dat) = @arg import $TOC,$TOP var ($det,$lnk,$ttl,$loc,$rep,$com) = split('\|',$dat,6) var ($nxt,$sct,$skp) = (false,false,false) report nvl(replace($rep,'[\/\\]','r',true),$lnk) prefix {write '---+!! ',$ttl if $loc write '---## Location: ',encode($loc) write $TOC } debug ' - Inside MBean, treating ',$lnk while ?$str = $buf->get_line {if match($str,'^\-+$') {if $nxt {write ' |' var $nxt = false } if $skp var $skp = false elsif $sct {write $TOP var $sct = false } } elsif match($str,'^d[rwx\-]+\s+') {if !isCreated() write '---++ Overview' if !$sct {write '---+++ Child Beans' write '|*Property*|*Name*|' } write '|',replace(replace($str,'\*','*',true),'\s+',' |',true),' |' var $sct = true } elsif match($str,'^\-[rw\-]{2}x',true) {if !isCreated() write '---++ Overview' if !$sct {write '---+++ Operations' write '|*Property*|*Name*|*Value*|' } var ($mod,$tmp) = split('\s{3,}',$str,2) var ($nam,$val) = split('\s+',$tmp,2) write '|',$mod,' |',$nam,' |',replace(replace($val,'\*','*',true),\ '\|','|',true),' |' var $sct = true } elsif match($str,'^\-') {if !isCreated() write '---++ Overview' if !$sct {write '---+++ Attributes' write '|*Property*|*Name*|*Value*|' } var ($mod,$tmp) = split('\s{3,}',$str,2) var ($nam,$val) = split('\s+',$tmp,2) if match($val,'^(WebLogic Server Temporary Patch|\)') {write '|',$mod,' |',$nam,' |',replace(replace($val,'\*','*',true),\ '\|','|',true),'\' var $nxt = true } else write '|',$mod,' |',$nam,' |',replace(replace($val,'\*','*',true),\ '\|','|',true),' |' var $sct = true } elsif match($str,'^Attribute Names and Values$') {write '---++ ',$str write '|*Name*|*Value*|' var ($sct,$skp) = (true,true) } elsif match($str,'^Operations on this MBean$') {write '---++ ',$str write '|*Operation*|' var ($sct,$skp) = (true,true) } elsif match($str,'^(ThreadStackDump|\ WeblogicVersion\s+WebLogic Server Temporary Patch)') {write '|',\ replace(replace($str,'\*','*',true),'\s{3,}',' |',true),'\' var $nxt = true } elsif $nxt {if match($str,'^(OSVersion|Parent|TotalHeap)') {write ' |' write '|',replace(replace(\ $str,'\*','*',true),'\s{3,}',' |',true),' |' var $nxt = false } elsif match($str,'^(WebLogic Server\s+\d|\<\/statistics\>)') {write '%BR%',$str,' |' var $nxt = false } else write '%BR%',$str,'\' } elsif $com {if match($str,'^Domain Properties$') {write '---++ ',$str write '|*Property*|*Value*|' var $sct = true } elsif match($str,'^\w+$') {write '---++ ',$str var $dft = '|*Property*|*Value*|' var $sct = true } elsif match($str,'^.*?\s+\|.*?\s+\|.*?\s*$') {var $hdr = '|*Name*|*Status*| *Priority*|' write $hdr } elsif match($str,'^\s*$') {if isCreated() write $TOP var $sct = false } elsif $hdr {var ($nam,$sta,$pri) = split('\s{1,}',replace($str,'\*','*',true),3) write '|',$nam,' |',$sta,' | ',$pri,'|' } else {if $dft {write $dft var $dft = undef } var ($prp,$val) = split('\s{1,}',replace($str,'\*','*',true),2) write '|',$prp,' |',$val,' |' } } elsif match($str,'^\s*$') {if $sct {write $TOP var $sct = false } } else write '|',\ replace(replace($str,'\*','*',true),'\s{3,}',' |',true),' |' } if $sct write $TOP if isCreated(true) toc $det,':[[',getFile(),'][rda_report][',$lnk,']]' } =head2 S This macro returns the WLST output in a list format. =cut macro write_list {var ($buf,$dat) = @arg var ($det,$lnk,$ttl,$loc,$rpt) = split('\|',$dat,5) output F,$rpt prefix {write '---+ ',$ttl write '---## ',$loc write ' * Links point to files that have been collected in their \ original format. Opening them directly in your browser \ can present risks. To prevent them, access the file \ outside the browser or use the link to save them and use \ an adequate viewer.' write '|*File Name*|' } while ?$lin = $buf->get_line write '|',$lin,'|' if isCreated(true) toc $det,':[[',getFile(),'][rda_report][',$lnk,']]' } =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2012, 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