diff --git a/perl-xCAT/xCAT/PPCdb.pm b/perl-xCAT/xCAT/PPCdb.pm index 8620c07b4..6a6131426 100644 --- a/perl-xCAT/xCAT/PPCdb.pm +++ b/perl-xCAT/xCAT/PPCdb.pm @@ -45,7 +45,8 @@ sub add_ppc { my $hwtype = shift; my $values = shift; my $not_overwrite = shift; - my @tabs = qw(ppc vpd nodehm nodelist nodetype); + my $otherinterfaces = shift; + my @tabs = qw(ppc vpd nodehm nodelist nodetype hosts mac); my %db = (); my %nodetype = ( fsp => $::NODETYPE_FSP, @@ -77,7 +78,8 @@ sub add_ppc { $server, $pprofile, $parent, - $ips ) = split /,/; + $ips, + $mac ) = split /,/; ############################### # Update nodetype table @@ -155,7 +157,27 @@ sub add_ppc { }); $db{vpd}{commit} = 1; } + + ############################### + # Update hosts table + ############################### + if ( $otherinterfaces ) { + $db{hosts}->setNodeAttribs( $name, + { otherinterfaces=>$ips }); + } else { + $db{hosts}->setNodeAttribs( $name, + { ip=>$ips }); + } + $db{hosts}{commit} = 1; + ############################### + # Update mac table + ############################### + if ( $mac ) { + $db{mac}->setNodeAttribs( $name, + { mac=>$mac }); + } + $db{mac}{commit} = 1; } ################################### @@ -477,10 +499,12 @@ sub updategroups { sub add_ppchcp { my $hwtype = shift; - my $name = shift; - my @tabs = qw(ppchcp nodehm nodelist nodetype); + my $values = shift; + my @tabs = qw(ppchcp nodehm nodelist nodetype mac); my %db = (); + my ($name, $mac) = split ',', $values; + ################################### # Open database needed ################################### @@ -510,6 +534,11 @@ sub add_ppchcp { ################################### $db{nodetype}->setNodeAttribs( $name, {nodetype=>lc($hwtype)}); + ################################### + # Update mac table + ################################### + $db{mac}->setNodeAttribs( $name, {mac=>$mac}); + ################################### # Update nodelist table ################################### diff --git a/perl-xCAT/xCAT/PPCfsp.pm b/perl-xCAT/xCAT/PPCfsp.pm index 447bd33e5..31361e608 100644 --- a/perl-xCAT/xCAT/PPCfsp.pm +++ b/perl-xCAT/xCAT/PPCfsp.pm @@ -277,7 +277,7 @@ sub process_cmd { # Run command ################################## my $res = $cmds{$command}{$_}[1]($exp, $request, $form, \%menu); - push @result, $res + push @result, $res; } return( \@result ); } @@ -1855,34 +1855,17 @@ sub set_netcfg return ( [RC_ERROR,join "\n", @lines_to_print]); } + $ua->timeout( 10 ); + $form = HTML::Form->parse( $res->content, $res->base ); $data = $form->click('submit'); - #xCAT::MsgUtils->message("I", "Updating network configuration for node " . $exp->[1] . "..."); - $ua->timeout( 10); $res = $ua->request( $data); -#We should update the /etc/hosts for users, but -#following line can cause problem, because multiple processes will try to -#update /etc/hosts concurrently. And for 0.0.0.0, what should we do? -#Comment these lines -# if( $inc_ip and $inc_ip ne '0.0.0.0') -# { -# my %host_ip; -# $host_ip{$exp->[1]} = $inc_ip; -# xCAT::Utils::updateEtcHosts(\%host_ip); -# } ############################################################## # We cannot get the result of this update, since the network # is updated, the old URI is invalid anymore # Return success directory ############################################################## - #if ($res->is_success()) - #{ return ( [SUCCESS, "Success to set " . join ',', @set_entries]); - #} - #else - #{ - # return ( [RC_ERROR, "Failed to set " . join ',', @set_entries]); - #} } ########################################################################## diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 5c312778a..f0b564819 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -2527,11 +2527,8 @@ sub nodeonmynet { $nodetocheck = shift; } - unless (inet_aton($nodetocheck)) - { - return 0; - } - my $nodeip = inet_ntoa(inet_aton($nodetocheck)); + + my $nodeip = getNodeIPaddress( $nodetocheck ); unless ($nodeip =~ /\d+\.\d+\.\d+\.\d+/) { return 0; #Not supporting IPv6 here IPV6TODO @@ -2589,6 +2586,36 @@ sub nodeonmynet return 0; } +------------------------------------------------------------------------------- + +=head3 getNodeIPaddress + +=cut + +#------------------------------------------------------------------------------- + +sub getNodeIPaddress +{ + my $nodetocheck = shift; + my $nodeip; + + if ( inet_aton($nodetocheck) ) { + $nodeip = inet_ntoa(inet_aton($nodetocheck)); + } else { + my $hoststab = xCAT::Table->new( 'hosts'); + my $ent = $hoststab->getNodeAttribs( $nodetocheck, ['ip'] ); + if ( $ent->{'ip'} ) { + $nodeip = $ent->{'ip'}; + } + } + + if ( $nodeip ) { + return $nodeip; + } else { + return undef; + } +} + #------------------------------------------------------------------------------- =head3 thishostisnot