diff --git a/perl-xCAT/xCAT/DHCP/Backend/ISC.pm b/perl-xCAT/xCAT/DHCP/Backend/ISC.pm index aeeefc14d5..fa531a1653 100644 --- a/perl-xCAT/xCAT/DHCP/Backend/ISC.pm +++ b/perl-xCAT/xCAT/DHCP/Backend/ISC.pm @@ -43,7 +43,10 @@ sub implemented { sub dhcp6_restart_needed { my ( $class, %args ) = @_; - return $args{changed} ? 1 : 0; + # xCAT writes the dhcpd6 configuration only for an IPv6 network. Without one the file + # stays absent, which the caller reads as a configuration to replace, and dhcpd6 has no + # subnet to serve. + return ( $args{changed} and $args{ipv6} ) ? 1 : 0; } 1; diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index aa09537d80..385d870d83 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -1332,6 +1332,7 @@ sub runxcmd } $::xcmd_outref = []; + $::xcmd_errorcode = 0; %::xcmd_outref_hash = (); my $req; if (ref($cmd) eq "HASH") @@ -1374,6 +1375,12 @@ sub runxcmd $::CALLBACK = $save_CALLBACK; # in case the subreq call changed it $::callback = $save_callback; # To keep $::callback also since some module use this global variable + + # The result of the subrequest is the errorcode of its responses. Every plugin it reaches + # runs commands of its own, and runcmd and the service helpers assign the exit status of + # each one to $::RUNCMD_RC, so the global holds the last command of the subrequest and not + # its result. + $::RUNCMD_RC = $::xcmd_errorcode; if ($::RUNCMD_RC) { my $displayerror = 1; @@ -1519,7 +1526,7 @@ sub runxcmd_output { if (ref(\($node->{errorcode}->[0])) eq 'SCALAR') { - $::RUNCMD_RC |= $node->{errorcode}->[0]; + $::xcmd_errorcode |= $node->{errorcode}->[0]; } } push @$::xcmd_outref, $desc; @@ -1539,14 +1546,14 @@ sub runxcmd_output { foreach my $ecode (@{ $resp->{errorcode} }) { - $::RUNCMD_RC |= $ecode; + $::xcmd_errorcode |= $ecode; } } else { # assume it is a non-reference scalar - $::RUNCMD_RC |= $resp->{errorcode}; + $::xcmd_errorcode |= $resp->{errorcode}; } } @@ -1596,14 +1603,14 @@ sub runxcmd_output2 push @{ $::xcmd_outref_hash->{errorcode} }, @{ $resp->{errorcode} }; foreach my $ecode (@{ $resp->{errorcode} }) { - $::RUNCMD_RC |= $ecode; + $::xcmd_errorcode |= $ecode; } } else { # assume it is a non-reference scalar - $::RUNCMD_RC |= $resp->{errorcode}; + $::xcmd_errorcode |= $resp->{errorcode}; } } return 0;