# S090OCM.def: Setting up Configuration Manager Interface # $Id: S090OCM.def,v 1.24 2009/08/13 16:34:44 mschenke Exp $ # ARCS: $Header: /u02/webapps/workbench/cvs/RDA_4/src/scripting/lib/modules/S090OCM.def,v 1.24 2009/08/13 16:34:44 mschenke Exp $ # # Change History # 20090813 MSC Improve feedbacks. =head1 NAME S090OCM - Interacts with the Oracle Configuration Manager =head1 DESCRIPTION This module executes Oracle Configuration Manager to collect configuration data when possible. =cut # Check if the collection must be done if getSetting('NO_OCM') return macro skip_ocm {if !getSetting('RDA_ARGC') return false else {loop $mod (split('\|',getSetting('RDA_ARGV'))) {if match($mod,'^((T[:/])?(S090)?OCM)$',true) return false } } output EN,status var $fil = getFile('/') close return isNewer($fil,1) } if skip_ocm() return # Initialization var $DOMAIN_NAME = getSetting('DOMAIN_NAME') var $MACHINE_NAME = getSetting('MACHINE_NAME') var $ORACLE_HOME = getSetting('ORACLE_HOME') var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' echo tput('bold'),'Processing OCM module ...',tput('off') # Define the collection macro macro do_collect {var ($cmd,$dir,$not) = @arg import $TOC,$TOP # Get the OCM status output EN,status write '---+!! Oracle Configuration Manager Status' call writeCommand(concat($cmd,' status 2>&1')) write '**Note:** Status collected before executing any OCM command' call renderFile() # Perform an OCM collection decr $dur,time() call loadCommand(concat($cmd,' -annotation=',$not,' collect'),false,4) incr $dur,time() var $sta = statCommand() call log('OCM','collect',$not,$dur,$sta) # Generate the report if the collect was successful if !$sta {output EN,collect write '---+!! Configuration Collection' write $TOC write '---+ Collection Identification' write '|*Annotation*|',$not,'|' write $TOP prefix {write '---+ Collection Details' write '|*Name*|*File*|*Time Stamp*|' } var $xml = xmlLoadFile(catFile($dir,'state','review','targetMap.xml')) loop $itm (xmlFind($xml,'.../Collection')) write '|',xmlValue($itm,'name'),' |',xmlValue($itm,'file'),' |',\ xmlValue($itm,'collection_timestamp'),' |' if hasOutput(true) write $TOP call renderFile() } } # Define the upgrade macro macro do_upgrade {var ($cmd,$dir) = @arg var $top = catDir(getSetting('RDA_HOME'),'ccr') if testDir('d',$top) {# Search for an OCM software kit if getSetting('OCM_DISTRIBUTION') var $kit = cond(testFile('r',catFile($top,last)),last) else {# Look for a distribution kit for the current operating system var %map = ('aix', 'AIX',\ 'dec_osf','OSF1',\ 'hpux', 'HP-UX',\ 'linux', 'Linux',\ 'solaris','SunOS',\ 'MSWin32','Windows') var $plt = getOsName() var $plt = nvl($map{$plt},$plt) loop $fil (grepDir($top,concat('^ccr-Production\-\d+(\.\d+){2,}\-',$plt,\ '(\-.*)?\.zip$'),'i')) {next !testFile('r',catFile($top,$fil)) if $kit return log('OCM','upgrade','','?',0,-9008) var $kit = $fil } } } if $kit {var $log = catFile($dir,'upgrade.rda') if or(getSetting('OCM_UPGRADE_RETRY'),\ not(grepFile($log,concat('^',quote($kit),'='),'fi'))) {# Perform an OCM upgrade decr $dur,time() call loadCommand(concat($cmd,' update_components -distribution=',\ catCommand($top,$kit)),false,4) incr $dur,time() var $sta = statCommand() call log('OCM','upgrade','',field('-',2,$kit),$dur,$sta) # Record the upgrade result call command(concat('echo ',$kit,'=',$sta, '>>',$log)) } } } # Collect the configuration when possible if or(testDir('d',catDir($ORACLE_HOME,'ccr')),\ testDir('d',catDir($ORACLE_HOME,'livelink')),\ testDir('d',catDir($ORACLE_HOME,upDir(),'utils','ccr'))) {var $dir = lastDir() if testFile('frx',catFile($dir,'bin',cond(isWindows(),'emCCR.bat','emCCR'))) {# Determine the command path var $cmd = lastCommand() # Try to upgrade the OCM software debug ' Inside OCM module, trying OCM software upgrade (can take time)' call do_upgrade($cmd,$dir) # Find the CONFIG_HOME if testDir('d',catDir($dir,'hosts')) {if getEnv('ORACLE_CONFIG_HOME') var $dir = catDir(last,'ccr') elsif testDir('d',catDir($dir,'hosts',\ concat($MACHINE_NAME,'.',$DOMAIN_NAME))) var $dir = lastDir() else var $dir = catDir($dir,'hosts',$MACHINE_NAME) } call setSetting('LAST_INFO_S090OCM') # Apply the appropriate treatment based on the OCM connection mode var $fil = catFile($dir,'config','collector.properties') var ($lin) = grepFile($fil,'ccr.disconnected','fi') if match(value($lin),'true',true) {# Determine the annotation (in disconnected mode) var $hsh = hash($MACHINE_NAME,$DOMAIN_NAME,$ORACLE_HOME) var $not = join('_','D',$hsh,'RDA',getPid(),\ gmtime('%Y%m%d_%H%M%S')) # Perform the OCM collection in foreground debug ' Inside OCM module, collecting the configuration (can take time)' call do_collect($cmd,$dir,$not) # Transfer the payload file debug ' Inside OCM module, transfering the OCM results' call transfer(catDir($dir,'state','upload'),'ocmconfig.jar',\ catDir(getSetting('RPT_DIRECTORY'),'extern'),\ concat(getSetting('RPT_GROUP'),'_OCM_payload.jar'),true) } elsif canFork() {# Determine the annotation (in connected mode) var ($fil) = grepDir(catDir($dir,'state','review'),\ '-oracle_home_config\.xml','i') var ($not) = match($fil,'^([0-9A-Z]+)\-',true) var $not = join('_','C',uc(nvl($not,'OCM')),'RDA',getPid(),\ gmtime('%Y%m%d_%H%M%S')) # Perform the OCM collection in a background job debug ' Inside OCM module, collecting the configuration in background' job call do_collect($cmd,$dir,$not) } else call setSetting('LAST_INFO_S090OCM',\ 'OCM-09101: Cannot fork an OCM collection') } else {# Get the OCM status output EN,status write '---+!! Oracle Configuration Manager Status' write 'Not authorized to execute ``emCCR``' call renderFile() call setSetting('LAST_INFO_S090OCM',\ 'OCM-9100: Not authorized to execute emCCR') } } =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