Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 296238 Details for
Bug 232492
RFE: Feature request for ssh capabilities in fence_drac script
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Add ssh capability
drac-ssh.patch (text/plain), 4.66 KB, created by
Marek Grac
on 2008-02-28 17:09:12 UTC
(
hide
)
Description:
Add ssh capability
Filename:
MIME Type:
Creator:
Marek Grac
Created:
2008-02-28 17:09:12 UTC
Size:
4.66 KB
patch
obsolete
>? Fencing.pm >? GMP.pm >? drac-ssh.patch >? fence_drac-new.pl >Index: fence_drac.pl >=================================================================== >RCS file: /cvs/cluster/cluster/fence/agents/drac/fence_drac.pl,v >retrieving revision 1.8.2.2 >diff -u -r1.8.2.2 fence_drac.pl >--- fence_drac.pl 27 Jun 2007 15:38:17 -0000 1.8.2.2 >+++ fence_drac.pl 28 Feb 2008 17:03:40 -0000 >@@ -29,6 +29,7 @@ > > use Getopt::Std; > use Net::Telnet (); >+use Net::SSH::Perl; > > # Get the program name from $0 and strip directory names > $_=$0; >@@ -38,6 +39,7 @@ > my $telnet_timeout = 10; # Seconds to wait for matching telent response > my $power_timeout = 20; # time to wait in seconds for power state changes > $action = 'reboot'; # Default fence action. >+$secure = 0; # Default is to use telnet > > my $logged_in = 0; > my $quiet = 0; >@@ -81,6 +83,7 @@ > print " -p <string> Login password\n"; > print " -S <path> Script to run to retrieve password\n"; > print " -q quiet mode\n"; >+ print " -x use ssh\n"; > print " -V version\n"; > print "\n"; > print "CCS Options:\n"; >@@ -190,7 +193,6 @@ > # Take a guess as to what the prompt might be if not already defined > $cmd_prompt="/(\\[$login\\]# |DRAC\\/MC:|\\\$ )/" unless defined $cmd_prompt; > >- > # Send login > $t->print($login); > >@@ -245,20 +247,25 @@ > $cmd = "serveraction -d 0 $svr_action"; > } > >- $t->print($cmd); >+ if ($secure == 0) { >+ $t->print($cmd); > >- # Expect /$cmd_prompt/ >- ($_) = $t->waitfor($cmd_prompt) or >- fail "failed: unexpected serveraction response"; >+ # Expect /$cmd_prompt/ >+ ($_) = $t->waitfor($cmd_prompt) or >+ fail "failed: unexpected serveraction response"; >+ } else { >+ my ($stdout, $stderr, $exit) = $ssh->cmd($cmd); >+ ($_) = $stdout; >+ } > > my @cmd_out = split /\n/; > > # discard command sent to DRAC >- $_ = shift @cmd_out; >+ $_ = shift @cmd_out unless $secure == 1; > s/\e\[(([0-9]+;)*[0-9]+)*[ABCDfHJKmsu]//g; #strip ansi chars > s/^.*\x0D//; > >- fail "failed: unkown dialog exception: '$_'" unless (/^$cmd$/); >+ fail "failed: unkown dialog exception: '$_'" unless ((/^$cmd$/) || ($secure == 1)); > > # Additional lines of output probably means an error. > # Aborting to be safe. Note: additional user debugging will be >@@ -301,9 +308,13 @@ > $cmd = "getmodinfo"; > } > >- $t->print($cmd); >- >- ($_) = $t->waitfor($cmd_prompt); >+ if ($secure == 0) { >+ $t->print($cmd); >+ ($_) = $t->waitfor($cmd_prompt); >+ } else { >+ my ($stdout, $stderr, $exit) = $ssh->cmd($cmd); >+ ($_) = $stdout; >+ } > > my $found_header = 0; > my $found_module = 0; >@@ -311,12 +322,13 @@ > my @cmd_out = split /\n/; > > # discard command sent to DRAC >- $_ = shift @cmd_out; >+ $_ = shift @cmd_out unless $secure == 1; >+ > #strip ansi control chars > s/\e\[(([0-9]+;)*[0-9]+)*[ABCDfHJKmsu]//g; > s/^.*\x0D//; > >- fail "failed: unkown dialog exception: '$_'" unless (/^$cmd$/); >+ fail "failed: unkown dialog exception: '$_'" unless ((/^$cmd$/) || ($secure == 1)); > > if ($drac_version ne $DRAC_VERSION_5) { > #Expect: >@@ -422,8 +434,12 @@ > # > sub logout > { >- $t->print(""); >- $t->print("exit"); >+ if ($secure == 0) { >+ $t->print(""); >+ $t->print("exit"); >+ } else { >+ $ssh->cmd("exit"); >+ } > } > > # >@@ -563,6 +579,10 @@ > { > $cmd_prompt = $val; > } >+ elsif ($name eq "secure") >+ { >+ $secure = 1; >+ } > # Excess name/vals will fail > else > { >@@ -578,7 +598,7 @@ > # Check parameters > # > if (@ARGV > 0) { >- getopts("a:c:d:D:hl:m:o:p:S:qVv") || fail_usage ; >+ getopts("a:c:d:D:hl:m:o:p:S:qVvx") || fail_usage ; > > usage if defined $opt_h; > version if defined $opt_V; >@@ -595,6 +615,7 @@ > $login = $opt_l; > > $modulename = $opt_m if defined $opt_m; >+ $secure = 1 if defined $opt_x; > > if (defined $opt_S) { > $pwd_script_out = `$opt_S`; >@@ -638,15 +659,31 @@ > unless $action =~ /^(Off|On|Reboot|status)$/i; > } > >+if ($secure == 0) { >+ $t->timeout($telnet_timeout); >+ $t->input_log($debug) if $debug; >+ $t->errmode('return'); > >-$t->timeout($telnet_timeout); >-$t->input_log($debug) if $debug; >-$t->errmode('return'); >+ login; > >-login; >+ # Abort on failure beyond here >+ $t->errmode(\&telnet_error); >+} else { >+ $ssh = Net::SSH::Perl->new($address); >+ $ssh->login($login, $passwd) || fail "Unable to login"; >+ my ($stdout, $stderr, $exit) = $ssh->cmd("racadm version"); >+ >+ ## ssh support tested just for DRAC 5.0.1.0 >+ ## we can't use earlier matching because we are not able to get >+ ## messages sent to us by server before executing commands >+ ##### >+ if ($stdout =~ /RACADM version (\d+)\./) { >+ if ($1 == 5) { >+ $drac_version = $DRAC_VERSION_5; >+ } >+ } >+} > >-# Abort on failure beyond here >-$t->errmode(\&telnet_error); > > if ($drac_version eq $DRAC_VERSION_III_XT) > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 232492
: 296238