# MCsans.ctl:252: Collects Storage Area Network (SAN) Switches Information # $Id: MCsans.ctl,v 1.7 2015/05/29 11:41:06 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCsans.ctl,v 1.7 2015/05/29 11:41:06 RDA Exp $ # # Change History # 20150527 KRA Improve the documentation. =head1 NAME EXPLORER:MCsans - Collects Storage Area Network (SAN) Switches Information =head1 DESCRIPTION This module collects Storage Area Network (SAN) switches information. =cut use Buffer use Mrc 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('sanextended') # Get the ping syntax var $PING = check(${RDA.T_OS},'solaris','/usr/sbin/ping %s',\ 'linux', '/bin/ping -c 1 %s',\ 'cygwin', '/bin/ping %s 64 1') #------------------------------------------------------------------------------ # XPLR_sans section #------------------------------------------------------------------------------ section XPLR_sans # Validate the execution context if !${B_GLOBAL:true} return call log_run('Processing SANS sections ...') pretoc '2:Storage Area Network (SAN) Switches' =head2 Storage Area Network (SAN) Switches Information Gathers SAN switches information using the following commands: =over 2 =item o C (sanbox1) =item o C =back In addition, gathers SAN switches information from remote switch using the following commands through telnet: =over 2 =item o C (brocade) =item o C (brocade) =item o C (mcdata) =item o C (mcdata) =item o C (mcdata) =item o C (mcdata) =item o C (mcdata) =item o C (mcdata) =item o C (mcdata) =item o C (mcdata) =item o C (mcdata) =item o C (mcdata) =item o C (mcdata) =item o C (sanbox1, sanbox2) =item o C (mcdata) =item o C (mcdata) =item o C (cisco) =item o C (mcdata) =item o C (brocade) =item o C =back =cut # Treat all requests loop $set (@{MOD.SANS.N_SET}) {var ($lgo,$pmt,@cmd,@tbl) = ('exit') var $val = ${MOD.SANS.T_HOST_${VAR.set}} next !?$val var $typ = ${MOD.SANS.T_TYPE_${VAR.set}} if !match($typ,'^(brocade|cisco|mcdata|sanbox[12])$') next log_info(concat('Unknown switch type ',$typ,' for ',$val)) if compare('eq',$typ,'brocade') var $pmt = ':admin> ' elsif compare('eq',$typ,'cisco') {var $pmt = '# ' var @cmd = (\ ['terminal_length_0.out',\ 'terminal length 0',\ '---++ Disable Page Scroll'],\ ['show_tech-support_details.out',\ 'show tech-support details',\ '---++ Router Detailed Information']) } elsif compare('eq',$typ,'mcdata') {var $lgo = 'logout' var $pmt = 'Root> ' } elsif compare('eq',$typ,'sanbox1') var $pmt = '>' elsif compare('eq',$typ,'sanbox2') var $pmt = '#> ' # Validate the input parameters debug ' Inside SANS collection, validating ',$val,' access' if !?$hst = isHost($val,true) next log_info(concat('Bad Storage Area Network (SAN) switch name or IP "',\ $val,'".')) call command(sprintf($PING,$hst)) if status() next log_info(concat('Switch ',$hst,' is not reachable.')) var $val = ${MOD.SANS.T_USER_${VAR.set}} if !?$usr = isUser($val,true) next log_info(concat('Bad Storage Area Network (SAN) user name "',$val,'".')) if !hasPassword('host',$hst,$usr) call setPassword('host',$hst,$usr,\ askPassword(concat('Enter ',$usr,' password for Storage Area Network ',\ '(SAN) switch ',$hst,': '),'')) # Connect to the Storage Area Network (SAN) switch var $ctl = new('Telnet',hst=>$hst) if !?$ctl->open next log_warning($ctl->get_info('msg')) if !?$ctl->login($usr,{dis=>$lgo,\ flg=>1,\ lim=>10,\ pat=>concat('m/',$pmt,'/')}) {# 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,$pmt,true)) {# Report the login dialog in case of failure var $msg = $ctl->get_message report concat('sans_info_',$hst) prefix {title '---++ ',$hst,' Login Dialog' call addBlock('E','D',concat('san/',$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 } # Verify the switch type is correct if compare('ne',$typ,'cisco') {var @out = $ctl->command('switchtype') if grep(@out,'Fabric OS') {# Brocade switch type var @cmd = (\ ['supportshow.out',\ 'supportshow',\ '---++ Detailed Switch Information']) var @out = $ctl->command('supportshow') var ($mod) = grep(@out,'switchType') var $mod = field('\.',0,field('\s+',1,$mod)) if match($mod,'^1$|^2$|^3$|^5$') call push(@cmd,\ ['loomphantomshow.out',\ 'loomphantomshow',\ '---++ Phantom Translation Tables']) elsif match($mod,'^9$|^12$|^16$') call push(@cmd,\ ['bloomphantomshow.out',\ 'bloomphantomshow',\ '---++ Phantom Translation Tables']) } elsif grep(@out,'Sanbox','i') {# Sanbox2 switch type var @cmd = (\ ['show_support.out',\ 'show support',\ '---++ Detailed Switch Information']) } elsif grep(@out,'^Login:') {# Sanbox1 switch type var @out = $ctl->command('show support') if grep(@out,'version','i') var @cmd = (\ ['show_support.out',\ 'show support',\ '---++ Detailed Switch Information']) else {var $bin = get_bin_tool('capture') if defined($bin) var @tbl = (\ [join('/','san',$hst,basename($bin)),\ $bin,undef,\ '---++ Detailed Switch Information']) } } elsif grep(@out,'Root') {# Mcdata switch type var @cmd = (\ ['show_ip_ethernet.out',\ 'show ip ethernet',\ '---++ Ethernet Attributes'],\ ['show_eventlog.out',\ 'show eventlog',\ '---++ Event Log Information'],\ ['show_features.out',\ 'show features',\ '---++ Feature Sets and Their States'],\ ['show_frus.out',\ 'show frus',\ '---++ FRU Information'],\ ['show_loginserver.out',\ 'show loginserver',\ concat('---++ Login Server Database Information for Devices Attached ',\ 'to This Switch')],\ ['show_nameServer.out',\ 'show nameServer',\ concat('---++ Name Server Database Information for Devices Attached ',\ 'to This Switch')],\ ['show_security_portbinding.out',\ 'show security portbinding',\ '---++ Port Binding Configuration'],\ ['show_port_config.out',\ 'show port config',\ '---++ Port Configuration'],\ ['show_port_info.out',\ 'show port info',\ '---++ Port Information'],\ ['show_port_status.out',\ 'show port status',\ '---++ Port Status'],\ ['show_port_technology.out',\ 'show port technology',\ '---++ Port Technology Information'],\ ['show_switch.out',\ 'show switch',\ '---++ Switch Attributes'],\ ['show_system.out',\ 'show system',\ '---++ System Attributes'],\ ['show_zoning.out',\ 'show zoning',\ '---++ Zoning Configuration Saved on the Fabric']) } else next log_info(concat($hst,' switch type cannot be determined. ',\ 'Data gathering is not possible.')) } # Genererate the report debug ' Inside SANS collection, gathering ',$hst,' information' report concat('sans_',$hst) title '---+!! Storage Area Network (SAN) Switch' 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('san/',$hst,'/',$rec->[0])) } if $ctl->collect(${CUR.O_REPORT},{cmd=>$rec->[1]}) call log_warning($ctl->get_info('msg')) if hasOutput(true) {call endBlock() write $TOP } } } call do_exec(@tbl) if isCreated(true) toc '3:[[',getFile(),'][rda_report][',$hst,' Information]]' # Close the connection call $ctl->quit } =head2 sans_input - Input File Lists the characteristics of the specified input file. =cut if ?testFile('r',catFile(${MOD.SANS.F_CFG})) {debug ' Inside SANS collection, getting input file characteristics' report sans_input title '---+ Input File Details' call do_exec(\ [concat('san/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,$typ,$pwd,$usr) = split('\s+',trim($lin),4) 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.SANS.T_HOST_${VAR.set}} = $hst var ${RUN.EXPLORER.XPLR.SANS.T_TYPE_${VAR.set}} = $typ var ${RUN.EXPLORER.XPLR.SANS.T_USER_${VAR.set}} = $usr } # Save the parsing results if $set {var ${RUN.EXPLORER.XPLR.SANS.F_CFG} = $fil var ${RUN.EXPLORER.XPLR.SANS.N_SET} = [@set] var ${RUN.EXPLORER.B_USE_SANS} = true } else var ${RUN.EXPLORER.B_USE_SANS} = $flg } } # Parse the input file if and(defined($fil = ${ENV.EXP_SANINPUT_CONFIG}),\ defined(testFile('frs',catFile($fil)))) call parse_input(lastTestFile(),true) elsif ?testFile('frs',catFile(${RUN.EXPLORER.D_ETC},'saninput.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