From 7a8d431650b1be81112c5e8e971f942d51eaecc1 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 2 May 2017 10:49:39 -0400 Subject: [PATCH 1/3] Initialize IPMI variables earlier In some scenarios, an IPMI instance could be called to handle data earlier than it should. Ensure the state of the object is in adequate shape to react as soon as possible. --- xCAT-server/lib/perl/xCAT/IPMI.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/perl/xCAT/IPMI.pm b/xCAT-server/lib/perl/xCAT/IPMI.pm index d7223dc6b..54d33289a 100644 --- a/xCAT-server/lib/perl/xCAT/IPMI.pm +++ b/xCAT-server/lib/perl/xCAT/IPMI.pm @@ -181,6 +181,7 @@ sub new { my $self = {}; bless $self, $class; my %args = @_; + $self->init(); unless ($ipmi2support) { $self->{ipmi15only} = 1; } @@ -238,7 +239,6 @@ sub new { } else { $self->{peeraddr} = sockaddr_in($self->{port}, $bmc_n); } - $self->init(); return $self; } From 13ee6733e706b76f50f23e7c9e8fae30e5b2c602 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 2 May 2017 11:19:54 -0400 Subject: [PATCH 2/3] Fix FPC reseat behavior on multiple nodes --- xCAT-server/lib/perl/xCAT/IPMI.pm | 8 ++++++++ xCAT-server/lib/xcat/plugins/ipmi.pm | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/IPMI.pm b/xCAT-server/lib/perl/xCAT/IPMI.pm index 54d33289a..bd0b480c6 100644 --- a/xCAT-server/lib/perl/xCAT/IPMI.pm +++ b/xCAT-server/lib/perl/xCAT/IPMI.pm @@ -471,6 +471,11 @@ sub checksum { sub subcmd { my $self = shift; my %args = @_; + while ($self->{incommand}) { + $self->waitforrsp(); + } + $self->{incommand} = 1; + $self->{expectedcmd} = $args{command}; $self->{expectednetfn} = $args{netfn} + 1; if ($self->{onlogon_args}->{xcatdebugmode}) { @@ -573,6 +578,7 @@ sub timedout { $self->{timeout} = $initialtimeout + (0.5 * rand()); my $rsp = {}; $rsp->{error} = "timeout"; + $self->{incommand} = 0; $self->{ipmicallback}->($rsp, $self->{ipmicallback_args}); $self->{nowait} = 0; return; @@ -833,6 +839,7 @@ sub init { #if we should incur 7 bumps, clear the taboo list and continue on, hoping for best (pessimistically assuming the spec means seq number or that someone could at least interpret it that way) #I'll implement this later... $self->{'logged'} = 0; + $self->{'incommand'} = 0; } sub relog { @@ -1008,6 +1015,7 @@ sub parse_ipmi_payload { $rsp->{code} = shift @payload; $rsp->{data} = \@payload; $self->{timeout} = $initialtimeout + (0.5 * rand()); + $self->{incommand} = 0; $self->{ipmicallback}->($rsp, $self->{ipmicallback_args}); return 0; } diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 00302d365..9bbecab53 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2301,6 +2301,8 @@ sub fpc_firmxfer_watch { } } +my %fpcsessions; + sub reseat_node { my $sessdata = shift; if (1) { # TODO: FPC path checked for @@ -2321,8 +2323,19 @@ sub reseat_node { my $nodeuser = $authdata->{$fpc}->{username}; my $nodepass = $authdata->{$fpc}->{password}; $sessdata->{slotnumber} = $mpent->{id}; - $sessdata->{fpcipmisession} = xCAT::IPMI->new(bmc => $mpent->{mpa}, userid => $nodeuser, password => $nodepass); - $sessdata->{fpcipmisession}->login(callback => \&fpc_node_reseat, callback_args => $sessdata); + if (exists $fpcsessions{$mpent->{mpa}}) { + $sessdata->{fpcipmisession} = $fpcsessions{$mpent->{mpa}}; + until ($sessdata->{fpcipmisession}->{logged}) { + $sessdata->{fpcipmisession}->waitforrsp(); + } + $sessdata->{fpcipmisession}->subcmd(netfn => 0x32, command => 0xa4, + data => [ $sessdata->{slotnumber}, 2 ], + callback => \&fpc_node_reseat_complete, callback_args => $sessdata); + } else { + $sessdata->{fpcipmisession} = xCAT::IPMI->new(bmc => $mpent->{mpa}, userid => $nodeuser, password => $nodepass); + $fpcsessions{$mpent->{mpa}} = $sessdata->{fpcipmisession}; + $sessdata->{fpcipmisession}->login(callback => \&fpc_node_reseat, callback_args => $sessdata); + } } } From e61b6c3789fa3d77b08d3693800962c5858699db Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 3 May 2017 11:34:22 -0400 Subject: [PATCH 3/3] Implement timeout for session sharing When an ipmi session is shared, have waitforrsp have a specified timeout. --- xCAT-server/lib/perl/xCAT/IPMI.pm | 2 +- xCAT-server/lib/xcat/plugins/ipmi.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/IPMI.pm b/xCAT-server/lib/perl/xCAT/IPMI.pm index bd0b480c6..4b444ac48 100644 --- a/xCAT-server/lib/perl/xCAT/IPMI.pm +++ b/xCAT-server/lib/perl/xCAT/IPMI.pm @@ -472,7 +472,7 @@ sub subcmd { my $self = shift; my %args = @_; while ($self->{incommand}) { - $self->waitforrsp(); + $self->waitforrsp(timeout=>1); } $self->{incommand} = 1; diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 9bbecab53..fc10adc97 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2326,7 +2326,7 @@ sub reseat_node { if (exists $fpcsessions{$mpent->{mpa}}) { $sessdata->{fpcipmisession} = $fpcsessions{$mpent->{mpa}}; until ($sessdata->{fpcipmisession}->{logged}) { - $sessdata->{fpcipmisession}->waitforrsp(); + $sessdata->{fpcipmisession}->waitforrsp(timeout=>1); } $sessdata->{fpcipmisession}->subcmd(netfn => 0x32, command => 0xa4, data => [ $sessdata->{slotnumber}, 2 ],