mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-30 17:13:08 +08:00
fix(baremetal): some tasks don't implement IServerBaseDeployTask interface (#20786)
This commit is contained in:
@@ -32,8 +32,8 @@ type IServerBaseDeployTask interface {
|
||||
IPXEBootTask
|
||||
|
||||
RemoveEFIOSEntry() bool
|
||||
DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error)
|
||||
PostDeploys(term *ssh.Client) error
|
||||
DoDeploys(ctx context.Context, term *ssh.Client) (jsonutils.JSONObject, error)
|
||||
PostDeploys(ctx context.Context, term *ssh.Client) error
|
||||
}
|
||||
|
||||
type SBaremetalServerBaseDeployTask struct {
|
||||
@@ -85,11 +85,11 @@ func (self *SBaremetalServerBaseDeployTask) RemoveEFIOSEntry() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SBaremetalServerBaseDeployTask) DoDeploys(_ *ssh.Client) (jsonutils.JSONObject, error) {
|
||||
func (self *SBaremetalServerBaseDeployTask) DoDeploys(ctx context.Context, _ *ssh.Client) (jsonutils.JSONObject, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (self *SBaremetalServerBaseDeployTask) PostDeploys(_ *ssh.Client) error {
|
||||
func (self *SBaremetalServerBaseDeployTask) PostDeploys(_ context.Context, _ *ssh.Client) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func (self *SBaremetalServerBaseDeployTask) OnPXEBoot(ctx context.Context, term
|
||||
}
|
||||
}
|
||||
|
||||
result, err := self.IServerBaseDeployTask().DoDeploys(term)
|
||||
result, err := self.IServerBaseDeployTask().DoDeploys(ctx, term)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Do deploy")
|
||||
}
|
||||
@@ -119,7 +119,7 @@ func (self *SBaremetalServerBaseDeployTask) OnPXEBoot(ctx context.Context, term
|
||||
return errors.Wrap(err, "Sync disk")
|
||||
}
|
||||
|
||||
if err := self.IServerBaseDeployTask().PostDeploys(term); err != nil {
|
||||
if err := self.IServerBaseDeployTask().PostDeploys(ctx, term); err != nil {
|
||||
return errors.Wrap(err, "post deploy")
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/util/ssh"
|
||||
)
|
||||
|
||||
var _ IServerBaseDeployTask = new(SBaremetalServerCreateTask)
|
||||
|
||||
type SBaremetalServerCreateTask struct {
|
||||
SBaremetalServerBaseDeployTask
|
||||
}
|
||||
@@ -94,7 +96,7 @@ func doPoweroff(term *ssh.Client) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SBaremetalServerCreateTask) PostDeploys(term *ssh.Client) error {
|
||||
func (self *SBaremetalServerCreateTask) PostDeploys(ctx context.Context, term *ssh.Client) error {
|
||||
if self.Baremetal.HasBMC() {
|
||||
return doPoweroff(term)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
@@ -22,6 +24,8 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/util/ssh"
|
||||
)
|
||||
|
||||
var _ IServerBaseDeployTask = new(SBaremetalServerDeployTask)
|
||||
|
||||
type SBaremetalServerDeployTask struct {
|
||||
SBaremetalServerBaseDeployTask
|
||||
}
|
||||
@@ -48,7 +52,7 @@ func (self *SBaremetalServerDeployTask) RemoveEFIOSEntry() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SBaremetalServerDeployTask) DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error) {
|
||||
func (self *SBaremetalServerDeployTask) DoDeploys(ctx context.Context, term *ssh.Client) (jsonutils.JSONObject, error) {
|
||||
tool, err := self.Baremetal.GetServer().NewConfigedSSHPartitionTool(term)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewConfigedSSHPartitionTool")
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
@@ -22,6 +24,8 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/util/ssh"
|
||||
)
|
||||
|
||||
var _ IServerBaseDeployTask = new(SBaremetalServerDestroyTask)
|
||||
|
||||
type SBaremetalServerDestroyTask struct {
|
||||
SBaremetalServerBaseDeployTask
|
||||
}
|
||||
@@ -48,7 +52,7 @@ func (self *SBaremetalServerDestroyTask) RemoveEFIOSEntry() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SBaremetalServerDestroyTask) DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error) {
|
||||
func (self *SBaremetalServerDestroyTask) DoDeploys(ctx context.Context, term *ssh.Client) (jsonutils.JSONObject, error) {
|
||||
if err := self.Baremetal.GetServer().DoEraseDisk(term); err != nil {
|
||||
log.Errorf("Delete server do erase disk: %v", err)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -24,6 +25,8 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/util/ssh"
|
||||
)
|
||||
|
||||
var _ IServerBaseDeployTask = new(SBaremetalServerRebuildTask)
|
||||
|
||||
type SBaremetalServerRebuildTask struct {
|
||||
SBaremetalServerBaseDeployTask
|
||||
}
|
||||
@@ -50,7 +53,7 @@ func (self *SBaremetalServerRebuildTask) RemoveEFIOSEntry() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SBaremetalServerRebuildTask) DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error) {
|
||||
func (self *SBaremetalServerRebuildTask) DoDeploys(ctx context.Context, term *ssh.Client) (jsonutils.JSONObject, error) {
|
||||
tool, err := self.Baremetal.GetServer().NewConfigedSSHPartitionTool(term)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewConfigedSSHPartitionTool")
|
||||
@@ -73,7 +76,7 @@ func (self *SBaremetalServerRebuildTask) DoDeploys(term *ssh.Client) (jsonutils.
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SBaremetalServerRebuildTask) PostDeploys(term *ssh.Client) error {
|
||||
func (self *SBaremetalServerRebuildTask) PostDeploys(ctx context.Context, term *ssh.Client) error {
|
||||
if self.Baremetal.HasBMC() {
|
||||
return doPoweroff(term)
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/util/ssh"
|
||||
)
|
||||
|
||||
var _ IServerBaseDeployTask = new(SBaremetalReprepareTask)
|
||||
|
||||
type SBaremetalReprepareTask struct {
|
||||
SBaremetalServerBaseDeployTask
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user