mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-29 09:13:08 +00:00
make the xdsh to switches look for passwd table for default username/password/protocol
This commit is contained in:
parent
98684916f8
commit
99b45ea072
@ -1001,21 +1001,46 @@ sub fork_fanout_dsh
|
||||
}
|
||||
} else {
|
||||
#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 protocol/]);
|
||||
foreach my $entry (values %$switchents) {
|
||||
my $passwdtab=xCAT::Table->new('passwd',-create=>1);
|
||||
my @passwd_ent = $passwdtab->getAttribs({key => "switch"}, ['username', 'password', 'comments']);
|
||||
my $switchestab=xCAT::Table->new('switches',-create=>0);
|
||||
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})) {
|
||||
$resolved_targets->{$switch}->{'user'}=$entry->[0]->{sshusername};
|
||||
}
|
||||
if (defined($entry->[0]->{sshpassword})) {
|
||||
$resolved_targets->{$switch}->{'password'}=$entry->[0]->{sshpassword};
|
||||
}
|
||||
if (defined($entry->[0]->{protocol})) {
|
||||
$resolved_targets->{$switch}->{'remotecmdproto'}=$entry->[0]->{protocol};
|
||||
}
|
||||
}
|
||||
my $username = "admin";
|
||||
my $password;
|
||||
my $protocol;
|
||||
|
||||
if (defined($entry->[0]->{sshusername})) { #use switch table first
|
||||
$username = $entry->[0]->{sshusername};
|
||||
if (defined($entry->[0]->{sshpassword})) {
|
||||
$password = $entry->[0]->{sshpassword};
|
||||
}
|
||||
if (defined($entry->[0]->{protocol})) {
|
||||
$protocol = $entry->[0]->{protocol};
|
||||
}
|
||||
}
|
||||
elsif (defined($passwd_ent[0]->{username})) { #use passwd table as default
|
||||
$username=$passwd_ent[0]->{username};
|
||||
if (defined($passwd_ent[0]->{password})) {
|
||||
$password = $passwd_ent[0]->{password};
|
||||
}
|
||||
if (defined($passwd_ent[0]->{comments}) && ($passwd_ent[0]->{comments} eq "telnet")) {
|
||||
$protocol = $passwd_ent[0]->{comments};
|
||||
}
|
||||
}
|
||||
|
||||
if ($username) {
|
||||
$resolved_targets->{$switch}->{'user'} = $username;
|
||||
}
|
||||
if ($password) {
|
||||
$resolved_targets->{$switch}->{'password'} = $password;
|
||||
}
|
||||
if ($protocol) {
|
||||
$resolved_targets->{$switch}->{'remotecmdproto'} = $protocol;
|
||||
}
|
||||
#print "username=$username, password=$password, protocol=$protocol\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -677,9 +677,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 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.',
|
||||
sshusername => 'The remote login user name. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key.',
|
||||
sshpassword => 'The remote login password. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key.',
|
||||
protocol => 'Prorocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. The passwd.comments attribute is used for protocol.',
|
||||
switchtype => 'The type of switch. It is used to identify the file name that implements the functions for this swithc. The valid values are: Mellanox, Cisco, BNT and Jun (for Juniper).',
|
||||
},
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user