# ASITlib.def: Defines Common Macros for Oracle Application Server 11g # $Id: ASITlib.def,v 1.4 2009/05/20 15:20:40 mschenke Exp $ # ARCS: $Header: /u02/webapps/workbench/cvs/RDA_4/src/scripting/lib/modules/ASITlib.def,v 1.4 2009/05/20 15:20:40 mschenke Exp $ # # Change History # 20090520 KRA Include 'opmnctl.bat' file for validating instance location. =head1 NAME ASITlib - Defines Common Macros for Oracle Application Server 11g =head1 DESCRIPTION This persistent sub module regroups macros that are common to several Oracle Application Server 11g related-modules. The following macros are available: =cut # Make the module persistent and share macros keep $KEEP_BLOCK,@SHARE_MACROS var @SHARE_MACROS = ('get_components','get_instances','sort_results') =head2 S This macro retrieves the instance components that have a type matching the specified pattern and returns the instance name. =cut macro get_components {var (\%cmp,$dir,$ins,$pat) = @arg var %cmp = () var ($opmnctl) = grepDir(catDir($dir,'bin'),'^opmnctl(\.(bat|exe))?$','fip') if loadCommand(concat(quote($opmnctl,'x'),' status -fmt %cmp%prt%uid 2>&1')) {loop $lin (getLines()) {next match($lin,'^(-+|\s*$|ias-component)',true) if match($lin,'Processes in Instance:\s*(.*?)$',true) var ($dsc) = (last) else {var ($cmp,$typ,$uid) = split('\s*\|\s*',$lin,3) if and($cmp,$typ,match($typ,$pat,true)) var $cmp{join('|',$typ,$cmp)} = check($uid,'^\d+$',$uid,0) } } } if !?$dsc {var ($fil) = grepDir(catDir($dir,'config','OPMN'),'^opmn\.xml$','fr') if testFile('r',$fil) {var $top = xmlLoadFile($fil,xmlDisable(xmlParser(),'DR')) if xmlFind($top,'opmn/process-manager/ias-instance') {var ($obj) = last var $dsc = xmlValue($obj,'name') loop $xml (xmlFind($obj,'ias-component')) {var $nam = xmlValue($xml,'id') loop $typ (xmlFind($xml,'process-type')) {if match($typ,$pat,true) var $cmp{join('|',xmlValue($typ,'id'),$nam)} = 0 } } } } } return nvl($dsc,$ins) } =head2 S This macro returns the list of valid instances found, derived from the specified setting. =cut macro get_instances {var ($hom,$key) = @arg var @ins = () # Identify the type of collection var $val = getSetting($key,'') if match($val,'\*All\*') var @tbl = grepDir($hom,'^[^\.]','n') else var @tbl = split('\|',$val) # Validate the instances loop $ins (@tbl) {var $dir = catDir($hom,$ins) next !or(testFile('f',catFile($dir,'bin','opmnctl')),\ testFile('f',catFile($dir,'bin','opmnctl.bat')),\ testFile('f',catFile($dir,'bin','opmnctl.exe'))) var @ins = (@ins,$ins) } return @ins } =head2 S This macro uses the unsorted file list to generate links in the RDA menu structure for each directory and the files located in that directory. =cut macro sort_results {var ($lvl,$lgt,$pre,$abr,@fil) = @arg import $CNT,$TOP,%DUP keep $TOP # Filter the file list loop $fil (@fil) {if $abr next !testFile('frT',$fil) next match($fil,'\.(bmp|exe|gif|jar|jpe?g|wav|wbmp)$',true) var $fil{join("\001",dirname($fil),basename($fil))} = $fil } # Generate the reports and related index links var $lst = '' var $det = $lvl incr $det loop $fil (keys(%fil)) {var $fil = $fil{$fil} # Check for a new section var $grp = dirname($fil) if compare('ne',$grp,$lst) {var $lst = $grp toc $lvl,':',encode(replace($grp,$pre,$abr)),' ' } # Create the report associated with the file debug ' Inside sort_results, getting ',$fil var $nam = basename($fil) if missing($DUP{$fil}) {incr $CNT report concat('log',$CNT,'_',$nam) if match($nam,'^USData.xml$',true) {write '---+ Display of ',encode($nam),' File' write '---## Information Taken from ',encode($fil) call statFile('b',$fil) write '**File was not collected, because of the file size.**%BR%' } elsif match($fil,'(logs?[\/\\]|log$)',true) {if exists($LOG{$fil}) var $cnt = $LOG{$fil} else var $cnt = $lgt if $cnt write '---+ Last ',$cnt,' Lines of ',encode($nam),' File' else write '---+ Display of ',encode($nam),' File' write '---## Information Taken from ',encode($fil) call statFile('b',$fil) if $cnt call writeTail($fil,$cnt) else call writeFile($fil) write $TOP } else {write '---+ Display of ',encode($nam),' File' write '---## Information Taken from ',encode($fil) call statFile('b',$fil) call writeFile($fil) write $TOP } var $rpt = getFile() var $DUP{$fil} = $rpt } if isCreated(true) toc $det,':[[',$rpt,'][rda_report][',encode($nam),']]' } } =head1 COPYRIGHT NOTICE Copyright (c) 2002-2009, Oracle. All rights reserved. =head1 TRADEMARK NOTICE Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. =cut