diff --git a/xCAT-probe/lib/perl/LogParse.pm b/xCAT-probe/lib/perl/LogParse.pm index bd750267f..d9e4a9e6d 100644 --- a/xCAT-probe/lib/perl/LogParse.pm +++ b/xCAT-probe/lib/perl/LogParse.pm @@ -62,7 +62,7 @@ sub new { my $logfiledir = "/tmp/xcatprobedebug/"; mkpath("$logfiledir") unless (-d "$logfiledir"); $self->{debuglogpath} = $logfiledir; - $self->{debuglogfd}; + $self->{debuglogfd} = undef; } bless($self, ref($class) || $class); @@ -94,8 +94,7 @@ sub obtain_candidate_mn_hostname_in_log { push(@candidate_svr_hostname_inlog, $svr_hostname_short); push(@candidate_svr_hostname_inlog, "$svr_hostname_short.$svr_hostname_domain"); if ($self->{debug}) { - my $tmpstr = ""; - $tmpstr .= "$_ " foreach (@candidate_svr_hostname_inlog); + my $tmpstr = join(" ", @candidate_svr_hostname_inlog); probe_utils->send_msg("stdout", "d", "The candidate MN hostname(s) in log are $tmpstr"); } return @candidate_svr_hostname_inlog; @@ -180,9 +179,7 @@ sub obtain_one_second_logs { if ($self->{debug}) { my $logfile = "$self->{debuglogpath}/obtain_one_second_logs.$the_time_to_load"; - my $fd; - open($fd, "> $logfile"); - $self->{debuglogfd} = $fd; + open($self->{debuglogfd}, "> $logfile"); } #read log for the first time @@ -554,13 +551,13 @@ sub convert_to_epoch_seconds { $yday = $self->{current_ref_year}; $epoch_seconds = timelocal($s, $m, $h, $dday, $monthsmap{$mday}, $yday); if ($epoch_seconds > $self->{current_ref_time}) { - $yday -= 1; + --$yday; $epoch_seconds = timelocal($s, $m, $h, $dday, $monthsmap{$mday}, $yday); } # The time format looks like "15/Aug/2016:01:10:24" } elsif ($timestr =~ /(\d+)\/(\w+)\/(\d+):(\d+):(\d+):(\d+)/) { - $epoch_seconds = timelocal($6, $5, $4, $1, $monthsmap{$2}, ($3 - 1900)); + $epoch_seconds = timelocal($6, $5, $4, $1, $monthsmap{$2}, $3); } return $epoch_seconds; } @@ -676,8 +673,7 @@ sub debuglogger { my $self = shift; my $msg = shift; if ($self->{debug}) { - my $fd = $self->{debuglogfd}; - print $fd "$msg\n"; + print {$self->{debuglogfd}} "$msg\n"; } } 1; diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index d62b9ef51..e99845562 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -540,7 +540,7 @@ sub parse_node_range { my $noderange = shift; $noderange= shift if (($noderange) && ($noderange =~ /probe_utils/)); my @nodeslist = `nodels $noderange`; - chomp($_) foreach(@nodeslist); + chomp @nodeslist; return @nodeslist; } 1; diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index d948b3686..e7c78a1d3 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -423,7 +423,7 @@ sub do_replay { sub conclusion_report { my $node_state_ref = shift; - probe_utils->send_msg("stdout", "", "==================conclusion_report================="); + probe_utils->send_msg("stdout", "", "==================osdeploy_probe_report================="); if ($debug) { print "---->the result of %node_state<------\n"; @@ -431,17 +431,22 @@ sub conclusion_report { } if ($verbose) { - probe_utils->send_msg("stdout", "d", "----------node history state----------"); + probe_utils->send_msg("stdout", "d", "----------node state history----------"); foreach my $node (keys %$node_state_ref) { my $allhistorystate; my $historystate; + probe_utils->send_msg("stdout", "d", "[$node]:"); if (@{ $node_state_ref->{$node}{allstatehistory} }) { - $allhistorystate .= "$::STATE_DESC{$_} " foreach (@{ $node_state_ref->{$node}{allstatehistory} }); - probe_utils->send_msg("stdout", "d", "[$node] the history before last loop provision: $allhistorystate"); + $allhistorystate .= "$::STATE_DESC{$_}=>" foreach (@{ $node_state_ref->{$node}{allstatehistory} }); + $allhistorystate =~ s/=>$//g; + probe_utils->send_msg("stdout", "d", "Setps executed prior to last provisioning attempt:"); + probe_utils->send_msg("stdout", "d", "$allhistorystate"); } - $historystate .= "$::STATE_DESC{$_} " foreach (@{ $node_state_ref->{$node}{statehistory} }); - probe_utils->send_msg("stdout", "d", "[$node] last loop provision history: $historystate"); + $historystate .= "$::STATE_DESC{$_}=>" foreach (@{ $node_state_ref->{$node}{statehistory} }); + $historystate =~ s/=>$//g; + probe_utils->send_msg("stdout", "d", "Steps executed for last provisioning attempt:"); + probe_utils->send_msg("stdout", "d", "$historystate"); } probe_utils->send_msg("stdout", "d", "--------------------------------------"); } @@ -503,7 +508,7 @@ sub conclusion_report { } } } else { - probe_utils->send_msg("stdout", "o", "All nodes provisioned successfully"); + probe_utils->send_msg("stdout", "o", "All nodes provision successfully"); } return 0; } @@ -919,7 +924,9 @@ sub handle_cluster_msg { set_node_state($node_state_ref, $node, $::STATE_POWERINGON); } elsif ($status eq "booting") { set_node_state($node_state_ref, $node, $::STATE_BOOTING); - } + } elsif ($status eq "failed") { + $node_state_ref->{$node}{done} = 1; + } } } }