2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 09:36:41 +00:00

use nic facing ip address instead of master

This commit is contained in:
Casandra Qiu 2017-10-18 15:25:55 -04:00
parent eac35e7e3d
commit 0f2cba3ce7

View File

@ -150,7 +150,17 @@ sub config_ip {
# Validate if this IP is reachable
my $p = Net::Ping->new();
if (!$p->ping($dip)) {
print "$dip is not reachable\n";
print "$dip is not reachable, will not change ip address\n";
#clean up discovery switch deifnition if any
my $ip_str = $dip;
$ip_str =~ s/\./\-/g;
my $dswitch = "switch-$ip_str";
$cmd = "makedns -d $dswitch";
$rc= xCAT::Utils->runcmd($cmd, 0);
$cmd = "makehosts -d $dswitch";
$rc= xCAT::Utils->runcmd($cmd, 0);
$cmd = "rmdef $dswitch";
$rc= xCAT::Utils->runcmd($cmd, 0);
next;
}
@ -248,10 +258,6 @@ sub config_hostname {
my $switchtab = xCAT::Table->new('switches');
my $switchhash = $switchtab->getNodesAttribs(\@nodes,['sshusername']);
# get the site domain value
my @domains = xCAT::TableUtils->get_site_attribute("domain");
my $sitedomain = $domains[0];
foreach my $switch (@nodes) {
my $user= $switchhash->{$switch}->[0]->{sshusername};
if (!$user) {
@ -263,7 +269,13 @@ sub config_hostname {
$cmd = "makehosts $switch";
$rc= xCAT::Utils->runcmd($cmd, 0);
$cmd="xdsh $switch -l $user --devicetype IBSwitch::Mellanox 'enable;configure terminal;hostname $switch;ip name-server $master;ip domain-list $sitedomain;ip default-gateway $master;configuration write' ";
my $server = $master;
my @servers = xCAT::NetworkUtils->my_ip_facing($switch);
unless ($servers[0]) {
$server = $servers[1];
}
$cmd="xdsh $switch -l $user --devicetype IBSwitch::Mellanox 'enable;configure terminal;hostname $switch;ip name-server $server;ip domain-list $server;ip default-gateway $server;configuration write' ";
$rc= xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0) {
xCAT::MsgUtils->message("E","Failed to setup hostname for $switch");
@ -349,6 +361,11 @@ sub run_rspconfig {
foreach my $switch (@nodes) {
my $user= $switchhash->{$switch}->[0]->{sshusername};
my $server = $master;
my @servers = xCAT::NetworkUtils->my_ip_facing($switch);
unless ($servers[0]) {
$server = $servers[1];
}
# enable the snmp trap
$cmd=`rspconfig $switch alert=enable`;
@ -357,7 +374,7 @@ sub run_rspconfig {
$cmd=`rspconfig $switch logdest=$master`;
# config ntp
$cmd = "xdsh $switch -l $user --devicetype IBSwitch::Mellanox 'enable;configure terminal;ntp enable;ntpdate $master; ntp server $master;configuration write;show ntp' ";
$cmd = "xdsh $switch -l $user --devicetype IBSwitch::Mellanox 'enable;configure terminal;ntp enable;ntpdate $server; ntp server $server;configuration write;show ntp' ";
$rc= xCAT::Utils->runcmd($cmd, 0);
push (@config_switches, $switch);