# TSTexl.def: Tests Connection to Oracle Exalogic Nodes # $Id: TSTexl.def,v 1.5 2012/05/11 10:04:03 mschenke Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_4/src/scripting/lib/modules/TSTexl.def,v 1.5 2012/05/11 10:04:03 mschenke Exp $ # # Change History # 20120508 KRA Improve the credential management. =head1 NAME TSTexl - Tests Connection to Oracle Exalogic Nodes =head1 DESCRIPTION This test module tests the connection to Oracle Exalogic nodes and can be used in two ways: =over 3 =item a) Runs interactively. It requests the user to input the user for connecting to the remote nodes. -vT exl =item b) Runs from the command line. You can specify the user for connecting to the remote nodes, using the following syntax: -vT exl:userid =back It extracts the node access information by executing the F command. This test module executes the following tests: =over 2 =cut use Remote echo tput('bold'),'Processing Oracle Exalogic Node tool ...',tput('off') if getSetting('TST_ARGS') var $USERID = last else {call requestSetting('TSTexl') var $USERID = getSetting('NODE_USERID') } =item o Tests which commands are available from the PATH. =cut echo '\012Command Availability:' loop $cmd ('rcp','remsh','rsh','scp','ssh','ssh-add','ssh-agent') echo sprintf(' %-12s %s',$cmd,nvl(findCommand($cmd),'(Not found)')) =item o Checks the existence and the permissions of the F<.ssh> directory. =item o Checks the existence and the permissions of a DSA or RSA key file. =cut if or(isUnix(),isCygwin()) {var $dir = catDir(getEnv('HOME'),'.ssh') echo '\012.ssh Directory:' if testDir('e',$dir) {var @sta = getStat($dir) echo ' File permissions of .ssh directory are: ',\ sprintf('%03o',expr('&',$sta[2],511)) if expr('&',$sta[2],63) echo ' Other users than the owner have permissions on it' var $flg = true if testFile('f',catFile($dir,'id_dsa')) {var @sta = getStat(lastFile()) if expr('&',$sta[2],7) echo ' DSA key file is ignored due to invalid permissions: ',\ sprintf('%03o',expr('&',$sta[2],511)) else var $flg= false } if testFile('s',catFile($dir,'id_rsa')) {var @sta = getStat(lastFile()) if expr('&',$sta[2],7) echo ' RSA key file is ignored due to invalid permissions: ',\ sprintf('%03o',expr('&',$sta[2],511)) else var $flg= false } if $flg echo ' No DSA or RSA key file found' } else echo ' ',$dir,' directory does not exist' } =item o Tests if an authentication agent is configured. When possible, it checks if identities have been added. =cut macro chk_env {var ($key,$flg) = @arg if $val = getEnv($key,$flg) {import $TTL if ?$TTL {echo $TTL var $TTL = undef } echo ' ',$key,'=',$val } } var $TTL = '\012Check if an authentication agent is running' call chk_env('SSH_AGENT_PID') call chk_env('SSH_AUTH_SOCK') var $agt = $TTL if !$agt {echo '\012Agent identities:' loop $lin (command('ssh-add -l')) echo ' ',$lin } =item o Tests which drivers are available for the remote connection. =cut echo '\012Driver Availability:' loop $typ ('da','jsch','ssh') echo sprintf(' %4s %s',$typ,cond($[REM]->can_use($typ),'Available','-')) =item o Checks the access to the F file. =cut if !loadCommand('/usr/sbin/ibnodes') {echo '\012Unable to get the node information by executing /usr/sbin/ibnodes \ command. Check the permission.' return } =item o Checks the connectivity with the best driver that is available. =cut var $pwd = undef loop $lin (grepLastFile('\".*?\sEL-C\s.*?\"')) {if match($lin,'\"(.*?)\sEL-C\s.*?\"') {var $nod = join(".",last,${RDA.DOMAIN}) next compare('eq',$nod,${RDA.HOST}) call addRemoteSession('exl',$nod,$USERID) if and(defined($pwd),not(hasPassword('host',$nod,$USERID))) call setPassword('host',$nod,$USERID,$pwd) if needPassword('exl') {var $pwd = askPassword(concat('Enter ',$USERID,'@',$nod,' password:')) call setPassword('host',$nod,$USERID,$pwd) if needPassword('exl') {echo 'Connection error connecting to node ',$nod call endRemoteSession('exl') next } } if rexec('exl','env') echo 'Connection error connecting to node ',$nod,' (error code:',last,')' else echo 'Successful connection to node ',$nod call endRemoteSession('exl') } } =back =begin credits =over 10 =item RDA 4.25: Chenna Gaddam, Wes Root. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2012, 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