From 534d10486c4e505a5e872b4a2ae72ada45cbc6df Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Fri, 8 Nov 2019 11:27:38 +0800 Subject: [PATCH] webconsole: fix baremetal ipmitool sol payload active on another session --- pkg/webconsole/command/ipmi_command.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pkg/webconsole/command/ipmi_command.go b/pkg/webconsole/command/ipmi_command.go index 78af288960..57f001c69f 100644 --- a/pkg/webconsole/command/ipmi_command.go +++ b/pkg/webconsole/command/ipmi_command.go @@ -18,6 +18,8 @@ import ( "fmt" "os/exec" + "yunion.io/x/log" + o "yunion.io/x/onecloud/pkg/webconsole/options" ) @@ -44,15 +46,24 @@ func NewIpmitoolSolCommand(info *IpmiInfo) (*IpmitoolSol, error) { return nil, fmt.Errorf("Empty password") } name := o.Options.IpmitoolPath - cmd := NewBaseCommand(name, "-I", "lanplus") - cmd.AppendArgs("-H", info.IpAddr) - cmd.AppendArgs("-U", info.Username) - cmd.AppendArgs("-P", info.Password) - cmd.AppendArgs("sol", "activate") + solArgs := []string{ + "-I", "lanplus", + "-H", info.IpAddr, + "-U", info.Username, + "-P", info.Password, + "sol", + } + cmd := NewBaseCommand(name, solArgs...) + cmd.AppendArgs("activate") tool := &IpmitoolSol{ BaseCommand: cmd, Info: info, } + deactiveCmd := exec.Command(name, solArgs...) + deactiveCmd.Args = append(deactiveCmd.Args, "deactivate") + if err := deactiveCmd.Run(); err != nil { + log.Errorf("ipmitool sol deactive %q error: %v", info.IpAddr, err) + } return tool, nil }