# MCb16s.ctl:240: Collects Sun Blade B1600 Server Switch Information # $Id: MCb16s.ctl,v 1.6 2015/05/09 15:08:04 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCb16s.ctl,v 1.6 2015/05/09 15:08:04 RDA Exp $ # # Change History # 20150509 MSC Change handle management. =head1 NAME EXPLORER:MCb16s - Collects Sun Blade B1600 Server Switch System Controller Information =head1 DESCRIPTION This module collects Switch System Controller (SSC) information in Sun Blade B1600 servers. =cut use Buffer use Mrc use Telnet # Initialization var $VALIDATE = true keep $VALIDATE section begin var $ERR = '---## Associated Errors' var $NXT = 'm/---More---/' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' run EXPLORER:XPLRlib('b1600switch') # 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_b16s section #------------------------------------------------------------------------------ section XPLR_b16s # Validate the execution context if !${B_GLOBAL:true} return call log_run('Processing B16S sections ...') pretoc '2:B1600 System Controller' =head2 Sun Blade B1600 Switch System Controller Information Gathers the following Switch System Controller commands through 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 =back =cut # Describe the Service Controller commands var @cmd = (\ '---+ Switch System Controller',\ ['show_version.out',\ 'show version',\ '---++ Hardware and Software Version Information'],\ ['show_system.out',\ 'show system',\ '---++ System Information'],\ ['show_running-config.out',\ 'show running-config',\ '---++ Configuration Information Currently in Use'],\ ['show_vlan.out',\ 'show vlan',\ '---++ Virtual Local Area Network (Vlan) Information'],\ ['show_interfaces_status.out',\ 'show interfaces status',\ '---++ Status for Ethernet Port, Aggregated Link, or VLAN Interfaces'],\ ['show_interfaces_switchport.out',\ 'show interfaces switchport',\ '---++ Advanced Interface Configuration Settings'],\ ['show_ip_interface.out',\ 'show ip interface',\ '---++ Settings for All IP Interfaces'],\ ['show_logging_ram.out',\ 'show logging ram',\ '---++ Event History in Temporary RAM'],\ ['show_logging_flash.out',\ 'show logging flash',\ '---++ Event History in Flash Memory'],\ ['show_gvrp_configuration.out',\ 'show gvrp configuration',\ '---++ GARP VLAN Registration Protocol (GVRP) Status']) # Treat all requests loop $set (@{MOD.B16S.N_SET}) {var $val = ${MOD.B16S.T_HOST_${VAR.set}} next !?$val # Validate the input parameters debug ' Inside B16S collection, validating ',$val,' access' if !?$hst = isHost($val,true) next log_info(concat('Bad B1600 SCC host name or IP "',$val,'".')) call command(sprintf($PING,$hst)) if status() next log_info(concat('Host ',$hst,' is not reachable.')) var $val = ${MOD.B16S.T_USER_${VAR.set}} if !?$usr = isUser($val,true) next log_info(concat('Bad B1600 SCC user name "',$val,'".')) if !hasPassword('host',$hst,$usr) call setPassword('host',$hst,$usr,\ askPassword(concat('Enter ',$usr,' password for B1600 SSC ',$hst,': '),'')) # Connect to the System Controller var $ctl = new('Telnet',hst=>$hst) if !?$ctl->open next log_warning($ctl->get_info('msg')) if !?$ctl->login($usr,{dis=>'quit',\ flg=>1,\ lim=>10,\ pat=>'m/Vty-.*#/'}) {# 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,'Vty-.*#',true)) {# Report the login dialog in case of failure var $msg = $ctl->get_message report concat('b16s_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 } # Genererate the report debug ' Inside B16S collection, gathering ',$hst,' information' report concat('b16s_info_',$hst) title '---+!! Sun Blade B1600 Server Switch System Controller' title '---## ',$hst,' Information' title $TOC loop $rec (@cmd) {if !ref($rec) write $rec else {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},{cmd=>$rec->[1],nxt=>[$NXT,' ']}) call log_warning($ctl->get_info('msg')) if hasOutput(true) {call endBlock() write $TOP } } } if isCreated(true) toc '3:[[',getFile(),'][rda_report][',$hst,' Information]]' # Close the connection call $ctl->quit } =head2 b16s_input - Input File Lists the characteristics of the specified input file. =cut if ?testFile('r',catFile(${MOD.B16S.F_CFG})) {debug ' Inside B16S collection, getting input file characteristics' report b16s_input 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]]' } # Adjust the table of content 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.B16S.T_HOST_${VAR.set}} = $hst var ${RUN.EXPLORER.XPLR.B16S.T_USER_${VAR.set}} = $usr } # Save the parsing results if $set {var ${RUN.EXPLORER.XPLR.B16S.F_CFG} = $fil var ${RUN.EXPLORER.XPLR.B16S.N_SET} = [@set] var ${RUN.EXPLORER.B_USE_B16S} = true } else var ${RUN.EXPLORER.B_USE_B16S} = $flg } } # Parse the input file if and(defined($fil = ${ENV.EXP_B1600SWITCHINPUT_CONFIG}),\ defined(testFile('frs',catFile($fil)))) call parse_input(lastTestFile(),true) elsif ?testFile('frs',catFile(${RUN.EXPLORER.D_ETC},'b1600switchinput.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