From 0f2cba3ce766d24012f62b017af3f6d8c72a1f43 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 18 Oct 2017 15:25:55 -0400 Subject: [PATCH] use nic facing ip address instead of master --- xCAT-server/share/xcat/scripts/configMellanox | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/xCAT-server/share/xcat/scripts/configMellanox b/xCAT-server/share/xcat/scripts/configMellanox index 0c1a1e1c8..545ba47e2 100755 --- a/xCAT-server/share/xcat/scripts/configMellanox +++ b/xCAT-server/share/xcat/scripts/configMellanox @@ -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);