added switches.protocol for running xdsh for swithes

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14579 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2012-12-06 21:11:29 +00:00
parent 7a2b7f65d5
commit 3413ba4568
3 changed files with 21 additions and 17 deletions

View File

@ -993,7 +993,7 @@ sub fork_fanout_dsh
#get user name and password from the switches table
my $switchestab=xCAT::Table->new('switches',-create=>0);
my $switchents = $switchestab->getNodesAttribs($targets_waiting,[qw/switch sshusername sshpassword/]);
my $switchents = $switchestab->getNodesAttribs($targets_waiting,[qw/switch sshusername sshpassword protocol/]);
foreach my $entry (values %$switchents) {
my $switch=$entry->[0]->{switch};
if (defined($entry->[0]->{sshusername})) {
@ -1002,6 +1002,9 @@ sub fork_fanout_dsh
if (defined($entry->[0]->{sshpassword})) {
$resolved_targets->{$switch}->{'password'}=$entry->[0]->{sshpassword};
}
if (defined($entry->[0]->{protocol})) {
$resolved_targets->{$switch}->{'remotecmdproto'}=$entry->[0]->{protocol};
}
}
}
}
@ -1076,6 +1079,9 @@ sub fork_fanout_dsh
$remote_shell = "$::XCATROOT/sbin/rshell_api";
$rsh_extension='RShellAPI';
$rsh_config{'password'}=$$target_properties{'password'};
if ($$target_properties{'remotecmdproto'}) {
$rsh_config{'remotecmdproto'}=$$target_properties{'remotecmdproto'};
}
if ($$options{'trace'}) {
$rsh_config{'trace'}=1;
}

View File

@ -591,7 +591,7 @@ noderes => {
},
},
switches => {
cols => [qw(switch snmpversion username password privacy auth linkports sshusername sshpassword switchtype comments disable)],
cols => [qw(switch snmpversion username password privacy auth linkports sshusername sshpassword protocol switchtype comments disable)],
keys => [qw(switch)],
nodecol => "switch",
table_desc => 'Parameters to use when interrogating switches',
@ -603,8 +603,9 @@ noderes => {
privacy => 'The privacy protocol to use for v3. DES is assumed if v3 enabled, as it is the most readily available.',
auth => 'The authentication protocol to use for SNMPv3. SHA is assumed if v3 enabled and this is unspecified',
linkports => 'The ports that connect to other switches. Currently, this column is only used by vlan configuration. The format is: "port_number:switch,port_number:switch...". Please refer to the switch table for details on how to specify the port numbers.',
sshusername => 'The user name for ssh. For Ethernet switches, it can be telnet username, use the format "tn:username" to indicate that it is for telnet.',
sshpassword => 'The password for ssh. For Ethernet switches, it can be password for telnet.',
sshusername => 'The remote login user name. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet".',
sshpassword => 'The remote login password. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet".',
protocol => 'Prorocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. Leave it blank or set to "ssh" for Mellanox IB switch.',
switchtype => 'The type of switch. It is used to identify the file name that implements the functions for this swithc. The valid values are: MellanoxIB etc.',
},
},

View File

@ -42,20 +42,12 @@ sub remote_shell_command {
if ( $$config{'trace'} ) {
push @command, "-v";
}
if ( $$config{'remotecmdproto'} && ($$config{'remotecmdproto'} =~ /^telnet$/)) {
push @command, "-t";
}
if ($$config{'user'} && ($$config{'user'} !~ /^none$/i)) {
my $username=$$config{'user'};
my $telnet=0;
if ($username =~ /^(tn:)(.*)$/) {
$telnet=1;
$username=$2;
}
if ($telnet) {
push @command, "-t";
}
if ($username) {
@tmp=split(' ', "-l $username");
push @command, @tmp;
}
@tmp=split(' ', "-l $$config{'user'}");
push @command, @tmp;
}
if ($$config{'password'} && ($$config{'password'} !~ /^none$/i)) {
@tmp=split(' ', "-p $$config{'password'}");
@ -97,10 +89,12 @@ sub run_remote_shell_api {
my $more_prompt='(.*key to continue.*|.*--More--\s*|.*--\(more.*\)--.*$)';
my $output;
my $errmsg;
my $ssh_tried=0;
if (!$telnet) {
eval {
$output="start SSH session...\n";
$ssh_tried=1;
$t = new xCAT::SSHInteract(
-username=>$user,
-password=>$passwd,
@ -135,6 +129,9 @@ sub run_remote_shell_api {
} else {
#ssh failed.. fallback to a telnet attempt
if ($ssh_tried) {
$output.="Warning: SSH failed, will try Telnet. Please set switches.protocol=telnet next time if you wish to use telnet directly.\n";
}
$output.="start Telnet session...\n";
require Net::Telnet;
$t = new Net::Telnet(