# MCalom.ctl:240: Collects Advanced Lights Out Manager (ALOM) Information # $Id: MCalom.ctl,v 1.7 2015/05/09 15:08:04 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCalom.ctl,v 1.7 2015/05/09 15:08:04 RDA Exp $ # # Change History # 20150509 MSC Change handle management. =head1 NAME EXPLORER:MCalom - Collects Advanced Lights Out Manager (ALOM) Information =head1 DESCRIPTION This module collects Advanced Lights Out Manager (ALOM) information. =cut use Buffer use Mrc use Remote use Telnet # Initialization var $VALIDATE = true keep $VALIDATE section begin var $ERR = '---## Associated Errors' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' run EXPLORER:XPLRlib('alomextended') # Get the ping syntax var $PING = check(${RDA.T_OS},\ 'solaris',concat(${CMD.PING:'ping'},' %s'),\ 'linux', concat(${CMD.PING:'ping'},' -c 1 %s'),\ 'cygwin', concat(${CMD.PING:'ping'},' %s 64 1')) #------------------------------------------------------------------------------ # XPLR_alom section #------------------------------------------------------------------------------ section XPLR_alom # Validate the execution context if !${B_GLOBAL:true} return call log_run('Processing ALOM sections ...') pretoc '2:Advanced Lights Out Manager (ALOM)' =head2 Advanced Lights Out Manager (ALOM) Information Gathers the following Advanced Lights Out Manager (ALOM) commands through SSH (requires a working Java environment) or Telnet: =over 2 =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =back =cut # Treat all requests loop $set (@{MOD.ALOM.N_SET}) {var @cmd = () var $val = ${MOD.ALOM.T_HOST_${VAR.set}} next !?$val # Validate the input parameters debug ' Inside ALOM collection, validating ',$val,' access' if !?$hst = isHost($val,true) next log_info(concat('Bad ALOM host name or IP "',$val,'".')) call command(sprintf($PING,$hst)) if status() next log_info(concat('Host ',$hst,' is not reachable.')) var $val = ${MOD.ALOM.T_USER_${VAR.set}} if !?$usr = isUser($val,true) next log_info(concat('Bad ALOM user name "',$val,'".')) if !hasPassword('host',$hst,$usr) call setPassword('host',$hst,$usr,\ askPassword(concat('Enter ',$usr,' password for ALOM ',$hst,': '),'')) # Trying Telnet connection in first place var $ctl = new('Telnet',hst=>$hst) if !$ctl->open {# Could not open Telnet session, so trying SSH var $ctl = addRemoteSession('LOC',$hst,$usr) if and($ctl->set_type('da'),$ctl->set_type('jsch')) next log_warning(concat('Unable to connect to ',$hst,' using Telnet or SSH')) if !$ctl->open next log_warning($ctl->get_message) } if !?$ctl->login($usr,{chk=>'m/Advanced Lights Out Manager/i',\ dis=>'logout',\ flg=>1,\ lim=>10,\ pat=>'m/>[\x20]?$/'}) {# Check for valid prompt when the last line contains an alert message var $buf = $ctl->get_input call $buf->set_handle('eol',false) var ($msg,$pre) = reverse($buf->get_lines(true)) if !and(match($msg,'^SC Alert:'),match($pre,'sc>\s*$',true)) {# Report the login dialog in case of failure var $msg = $ctl->get_message report concat('alom_info_',$hst) prefix {title '---++ ',$hst,' Login Dialog' call addBlock('E','D',concat('sc/',$hst,'/','connect_dialog.out')) } call writeFile($buf,[]) write 'Return code: ',$msg if isCreated(true) toc '3:[[',getFile(),'][rda_report][',$hst,' Connect Dialog]]' call $buf->close call $ctl->close next log_warning($msg) } # Clear the input buffer and perform the collection call $buf->close call $ctl->empty_buffer } # Obtain platform information var $plt = new('Buffer','S') call $ctl->collect($plt,{\ cln=>true,\ cmd=>'showplatform -v',\ nxt=>['m/^.*?--pause--.*?continue.*?$/i',"\012"],\ pat=>'m/>[\x20]?$/',\ skp=>true}) # Describe the Advanced Lights Out Manager service controller commands call push(@cmd,\ ['showdate.out',\ 'showdate',\ '---++ Advanced Lights Out Manager (ALOM) Date'],\ ['shownetwork_-v.out',\ 'shownetwork -v',\ '---++ Current Network Configuration Information'],\ ['showlocator.out',\ 'showlocator',\ '---++ Current State of the Locator LEDs'],\ ['showenvironment.out',\ 'showenvironment',\ '---++ Environmental Status of the Host Server'],\ ['showlogs_-v.out',\ 'showlogs -v',\ '---++ Events Logged in Advanced Lights Out Manager (ALOM) Event Buffer'],\ ['showfru.out',\ 'showfru',\ '---++ Field Replaceable Units (FRUs) Information'],\ ['showsc_version_-v.out',\ 'showsc version -v',\ '---++ Full Advanced Lights Out Manager (ALOM) Version'],\ ['usershow.out',\ 'usershow',\ '---++ List of All User Accounts'],\ ['showusers.out',\ 'showusers',\ '---++ List of Users Currently Logged In to Advanced Lights Out Manager \ (ALOM)'],\ ['showsc_-v.out',\ 'showsc -v',\ '---++ Software Configuration and Firmware Version'],\ ['consolehistory_-v.out',\ 'consolehistory -v',\ '---++ System Console Messages Logged in Advanced Lights Out Manager \ (ALOM) Buffers']) # Add Sun-Fire-Tx000 platform specific collections if $plt->grep('Sun-Fire-T[12]000','f') call push(@cmd,\ ['showfaults_-v.out',\ 'showfaults -v',\ '---++ Current Valid System Faults'],\ ['showkeyswitch.out',\ 'showkeyswitch',\ '---++ Current Virtual Keyswitch Position'],\ ['showcomponent.out',\ 'showcomponent',\ '---++ System Components and Their Test Status'],\ ['showhost.out',\ 'showhost',\ '---++ Version Information for Host-Side Components']) # Genererate the report debug ' Inside ALOM collection, gathering ',$hst,' information (can take time)' report concat('alom_info_',$hst) title '---+!! Advanced Lights Out Manager System Controller (ALOM)' title '---## ',$hst,' Information' title $TOC loop $rec (@cmd) {if ref($rec) {prefix {write $rec->[2] write '---## Using: ',encode($rec->[1]) call beginBlock(true) call addBlock('E','D',concat('sc/',$hst,'/',$rec->[0])) } if $ctl->collect(${CUR.O_REPORT},{\ cln=>true,\ cmd=>$rec->[1],\ max=>90,\ nxt=>['m/^.*?--pause--.*?continue.*?$/i',"\012"],\ pat=>'m/>[\x20]?$/',\ skp=>true}) call log_warning($ctl->get_message) if hasOutput(true) {call endBlock() write $TOP } } else write $rec } # Close the connection call $ctl->close # Add platform information previously collected call do_exec(\ {cmd => 'BUFFER',\ buf => $plt,\ det => 'showplatform -v',\ nam => concat('sc/',$hst,'/showplatform_-v.out'),\ ttl => '---++ System Hardware Configuration'}) call $plt->close # Add the report to the table of content if isCreated(true) toc '3:[[',getFile(),'][rda_report][',$hst,' Information]]' } =head2 alom_input - Input File Lists the characteristics of the specified input file. =cut if ?testFile('r',catFile(${MOD.ALOM.F_CFG})) {debug ' Inside ALOM collection, getting input file characteristics' report alom_input title '---+ Input File Details' call do_exec(\ [concat('sc/ls_-l_',replace(lastFile(),'\/','@',true)),\ ${CMD.LS:'ls'},concat('-l ',quote(lastFile())),\ '---+ Explorer Input File']) if isCreated() toc '3:[[',getFile(),'][rda_report][Input File]]' } unpretoc #------------------------------------------------------------------------------ # Input file conversion section #------------------------------------------------------------------------------ section input # Define the input file parser macro macro parse_input {var ($fil,$flg) = @arg var @sta = getStat($fil) if !expr('&',$sta[2],077) {# Parse the input file var ($set,@set) = (0) loop $lin (grepFile($fil,'^\s*#','v')) {var ($hst,$usr,$pwd) = split('\s+',trim($lin),3) next !?$hst = isHost($hst,true) next !?$usr = isUser($usr,true) if ?$pwd call setPassword('host',$hst,$usr,$pwd) call push(@set,incr($set)) var ${RUN.EXPLORER.XPLR.ALOM.T_HOST_${VAR.set}} = $hst var ${RUN.EXPLORER.XPLR.ALOM.T_USER_${VAR.set}} = $usr } # Save the parsing results if $set {var ${RUN.EXPLORER.XPLR.ALOM.F_CFG} = $fil var ${RUN.EXPLORER.XPLR.ALOM.N_SET} = [@set] var ${RUN.EXPLORER.B_USE_ALOM} = true } else var ${RUN.EXPLORER.B_USE_ALOM} = $flg } } # Parse the input file if and(defined($fil = ${ENV.EXP_ALOMINPUT_CONFIG}),\ defined(testFile('frs',catFile($fil)))) call parse_input(lastTestFile(),true) elsif ?testFile('frs',catFile(${RUN.EXPLORER.D_ETC},'alominput.txt')) call parse_input(lastTestFile(),false) =head1 SEE ALSO L, L =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