tasks

package
v0.3.9-9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 40 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustUEFIBootOrder

func AdjustUEFIBootOrder(term *ssh.Client, bm IBaremetal) error

func ExecuteTask

func ExecuteTask(task ITask, args interface{})

func GetNicsInfo

func GetNicsInfo(cli *ssh.Client) ([]*types.SNicDevInfo, error)

func GetWorkManager

func GetWorkManager() *appsrv.SWorkerManager

func NewBaremetalRegisterTask

func NewBaremetalRegisterTask(
	userCred mcclient.TokenCredential, bmManager IBmManager, sshCli *ssh.Client,
	hostname, remoteIp, ipmiUsername, ipmiPassword, ipmiIpAddr string,
	ipmiMac net.HardwareAddr, ipmiLanChannel int, adminWire, ipmiWire string) *sBaremetalRegisterTask

func OnInitStage

func OnInitStage(task ITask) error

func OnStop

func OnStop()

func SetTaskComplete

func SetTaskComplete(task ITask, data jsonutils.JSONObject)

func SetTaskFail

func SetTaskFail(task ITask, err error)

Types

type IBaremetal

type IBaremetal interface {
	Keyword() string

	GetId() string
	GetZoneId() string
	GetStorageCacheId() string
	GetTaskQueue() *TaskQueue
	GetSSHConfig() (*types.SSHConfig, error)
	TestSSHConfig() bool
	GetAdminNic() *types.SNic
	GetName() string
	GetClientSession() *mcclient.ClientSession
	SaveDesc(desc jsonutils.JSONObject) error
	GetNics() []types.SNic
	GetNicByMac(net.HardwareAddr) *types.SNic
	GetRawIPMIConfig() *types.SIPMIInfo
	GetIPMINic(mac net.HardwareAddr) *types.SNic
	SetExistingIPMIIPAddr(ipAddr string)
	GetServer() baremetaltypes.IBaremetalServer

	SyncStatus(status, reason string)
	AutoSyncStatus()
	SyncAllStatus(status string)
	AutoSyncAllStatus()

	GetPowerStatus() (string, error)
	DoPowerShutdown(soft bool) error
	DoPXEBoot() error

	DoRedfishPowerOn() error
	GetAccessIp() string
	EnablePxeBoot() bool
	GenerateBootISO() error
	SendNicInfo(nic *types.SNicDevInfo, idx int, nicType string, reset bool, ipAddr string, reserve bool) error
	DoNTPConfig() error
	GetImageUrl(needImageCache bool) string

	RemoveServer()
	InitializeServer(session *mcclient.ClientSession, name string) error
	SaveSSHConfig(remoteAddr string, key string) error
	ServerLoadDesc() error
	GetDHCPServerIP() (net.IP, error)

	HasBMC() bool
	SSHReachable() (bool, error)
	SSHReboot() error
	SSHShutdown() error
	AdjustUEFICurrentBootOrder(cli *ssh.Client) error
}

type IBmManager

type IBmManager interface {
	GetZoneId() string
	AddBaremetal(jsonutils.JSONObject) (pxe.IBaremetalInstance, error)
	GetClientSession() *mcclient.ClientSession
}

type IPXEBootTask

type IPXEBootTask interface {
	ITask
	OnPXEBoot(ctx context.Context, cli *ssh.Client, args interface{}) error
}

type IServerBaseDeployTask

type IServerBaseDeployTask interface {
	IPXEBootTask

	RemoveEFIOSEntry() bool
	DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error)
	PostDeploys(term *ssh.Client) error
}

type ITask

type ITask interface {
	// GetStage return current task stage func
	GetStage() TaskStageFunc
	// SetStage set task next execute stage func
	SetStage(stage TaskStageFunc)

	// GetSSHStage return current task ssh stage func
	GetSSHStage() SSHTaskStageFunc
	// SetSSHStage set task next execute ssh stage func
	SetSSHStage(stage SSHTaskStageFunc)

	// GetTaskId return remote service task id
	GetTaskId() string
	GetClientSession() *mcclient.ClientSession

	GetTaskQueue() *TaskQueue
	// GetData return TaskData from region
	GetData() jsonutils.JSONObject
	GetName() string

	Execute(args interface{})
	SetSSHStageParams(remoteIP string, passwd string)
	SSHExecute(remoteIP string, passwd string, args interface{})
	NeedPXEBoot() bool

	GetStartTime() time.Time
}

func NewBaremetalCdromTask

func NewBaremetalCdromTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalIpmiProbeTask

func NewBaremetalIpmiProbeTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalMaintenanceTask

func NewBaremetalMaintenanceTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalReprepareTask

func NewBaremetalReprepareTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalResetBMCTask

func NewBaremetalResetBMCTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalServerCreateTask

func NewBaremetalServerCreateTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalServerDeployTask

func NewBaremetalServerDeployTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalServerDestroyTask

func NewBaremetalServerDestroyTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalServerRebuildTask

func NewBaremetalServerRebuildTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalServerStartTask

func NewBaremetalServerStartTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalServerStopTask

func NewBaremetalServerStopTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

func NewBaremetalUnmaintenanceTask

func NewBaremetalUnmaintenanceTask(
	userCred mcclient.TokenCredential,
	baremetal IBaremetal,
	taskId string,
	data jsonutils.JSONObject,
) ITask

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue() *Queue

func (*Queue) Append

func (q *Queue) Append(obj interface{}) *Queue

func (*Queue) First

func (q *Queue) First() interface{}

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

func (*Queue) Pop

func (q *Queue) Pop() interface{}

func (*Queue) String

func (q *Queue) String() string

type SBaremetalCdromTask

type SBaremetalCdromTask struct {
	SBaremetalTaskBase
}

func (*SBaremetalCdromTask) DoEjectISO

func (self *SBaremetalCdromTask) DoEjectISO(ctx context.Context, args interface{}) error

func (*SBaremetalCdromTask) DoInsertISO

func (self *SBaremetalCdromTask) DoInsertISO(ctx context.Context, args interface{}) error

func (*SBaremetalCdromTask) GetName

func (self *SBaremetalCdromTask) GetName() string

type SBaremetalIpmiProbeTask

type SBaremetalIpmiProbeTask struct {
	SBaremetalTaskBase
}

func (*SBaremetalIpmiProbeTask) DoIpmiProbe

func (self *SBaremetalIpmiProbeTask) DoIpmiProbe(ctx context.Context, args interface{}) error

func (*SBaremetalIpmiProbeTask) GetName

func (self *SBaremetalIpmiProbeTask) GetName() string

type SBaremetalMaintenanceTask

type SBaremetalMaintenanceTask struct {
	SBaremetalPXEBootTaskBase
}

func (*SBaremetalMaintenanceTask) OnPXEBoot

func (self *SBaremetalMaintenanceTask) OnPXEBoot(ctx context.Context, term *ssh.Client, args interface{}) error

type SBaremetalPXEBootTaskBase

type SBaremetalPXEBootTaskBase struct {
	SBaremetalTaskBase
	// contains filtered or unexported fields
}

func (*SBaremetalPXEBootTaskBase) GetName

func (self *SBaremetalPXEBootTaskBase) GetName() string

func (*SBaremetalPXEBootTaskBase) IPXEBootTask

func (self *SBaremetalPXEBootTaskBase) IPXEBootTask() IPXEBootTask

func (*SBaremetalPXEBootTaskBase) InitPXEBootTask

func (self *SBaremetalPXEBootTaskBase) InitPXEBootTask(ctx context.Context, args interface{}) error

func (*SBaremetalPXEBootTaskBase) NeedPXEBoot

func (self *SBaremetalPXEBootTaskBase) NeedPXEBoot() bool

func (*SBaremetalPXEBootTaskBase) OnPXEBoot

func (self *SBaremetalPXEBootTaskBase) OnPXEBoot(ctx context.Context, cli *ssh.Client, args interface{}) error

func (*SBaremetalPXEBootTaskBase) OnStopComplete

func (self *SBaremetalPXEBootTaskBase) OnStopComplete(ctx context.Context, args interface{}) error

func (*SBaremetalPXEBootTaskBase) WaitForShutdown

func (self *SBaremetalPXEBootTaskBase) WaitForShutdown(ctx context.Context, args interface{}) error

type SBaremetalReprepareTask

type SBaremetalReprepareTask struct {
	SBaremetalServerBaseDeployTask
}

func (*SBaremetalReprepareTask) DoDeploys

func (self *SBaremetalReprepareTask) DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error)

func (*SBaremetalReprepareTask) GetName

func (self *SBaremetalReprepareTask) GetName() string

func (*SBaremetalReprepareTask) PostDeploys

func (self *SBaremetalReprepareTask) PostDeploys(term *ssh.Client) error

type SBaremetalResetBMCTask

type SBaremetalResetBMCTask struct {
	SBaremetalPXEBootTaskBase
	// contains filtered or unexported fields
}

func (*SBaremetalResetBMCTask) GetIPMITool

func (self *SBaremetalResetBMCTask) GetIPMITool() *ipmitool.SSHIPMI

func (*SBaremetalResetBMCTask) GetName

func (self *SBaremetalResetBMCTask) GetName() string

func (*SBaremetalResetBMCTask) OnBMCReady

func (self *SBaremetalResetBMCTask) OnBMCReady(ctx context.Context, args interface{}) error

func (*SBaremetalResetBMCTask) OnPXEBoot

func (self *SBaremetalResetBMCTask) OnPXEBoot(ctx context.Context, term *ssh.Client, args interface{}) error

func (*SBaremetalResetBMCTask) WaitForBMCReady

func (self *SBaremetalResetBMCTask) WaitForBMCReady(ctx context.Context, args interface{}) error

type SBaremetalServerBaseDeployTask

type SBaremetalServerBaseDeployTask struct {
	SBaremetalPXEBootTaskBase
	// contains filtered or unexported fields
}

func (*SBaremetalServerBaseDeployTask) DoDeploys

func (*SBaremetalServerBaseDeployTask) GetFinishAction

func (self *SBaremetalServerBaseDeployTask) GetFinishAction() string

func (*SBaremetalServerBaseDeployTask) GetName

func (self *SBaremetalServerBaseDeployTask) GetName() string

func (*SBaremetalServerBaseDeployTask) IServerBaseDeployTask

func (self *SBaremetalServerBaseDeployTask) IServerBaseDeployTask() IServerBaseDeployTask

func (*SBaremetalServerBaseDeployTask) IsDisableImageCache

func (self *SBaremetalServerBaseDeployTask) IsDisableImageCache() bool

func (*SBaremetalServerBaseDeployTask) NeedPXEBoot

func (self *SBaremetalServerBaseDeployTask) NeedPXEBoot() bool

func (*SBaremetalServerBaseDeployTask) OnPXEBoot

func (self *SBaremetalServerBaseDeployTask) OnPXEBoot(ctx context.Context, term *ssh.Client, args interface{}) error

func (*SBaremetalServerBaseDeployTask) PostDeploys

func (self *SBaremetalServerBaseDeployTask) PostDeploys(_ *ssh.Client) error

func (*SBaremetalServerBaseDeployTask) RemoveEFIOSEntry

func (self *SBaremetalServerBaseDeployTask) RemoveEFIOSEntry() bool

type SBaremetalServerCreateTask

type SBaremetalServerCreateTask struct {
	SBaremetalServerBaseDeployTask
}

func (*SBaremetalServerCreateTask) DoDeploys

func (self *SBaremetalServerCreateTask) DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error)

func (*SBaremetalServerCreateTask) GetName

func (self *SBaremetalServerCreateTask) GetName() string

func (*SBaremetalServerCreateTask) PostDeploys

func (self *SBaremetalServerCreateTask) PostDeploys(term *ssh.Client) error

func (*SBaremetalServerCreateTask) RemoveEFIOSEntry

func (self *SBaremetalServerCreateTask) RemoveEFIOSEntry() bool

type SBaremetalServerDeployTask

type SBaremetalServerDeployTask struct {
	SBaremetalServerBaseDeployTask
}

func (*SBaremetalServerDeployTask) DoDeploys

func (self *SBaremetalServerDeployTask) DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error)

func (*SBaremetalServerDeployTask) GetName

func (self *SBaremetalServerDeployTask) GetName() string

func (*SBaremetalServerDeployTask) RemoveEFIOSEntry

func (self *SBaremetalServerDeployTask) RemoveEFIOSEntry() bool

type SBaremetalServerDestroyTask

type SBaremetalServerDestroyTask struct {
	SBaremetalServerBaseDeployTask
}

func (*SBaremetalServerDestroyTask) DoDeploys

func (self *SBaremetalServerDestroyTask) DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error)

func (*SBaremetalServerDestroyTask) GetName

func (self *SBaremetalServerDestroyTask) GetName() string

func (*SBaremetalServerDestroyTask) RemoveEFIOSEntry

func (self *SBaremetalServerDestroyTask) RemoveEFIOSEntry() bool

type SBaremetalServerPrepareTask

type SBaremetalServerPrepareTask struct {
	SBaremetalTaskBase
}

func NewBaremetalServerPrepareTask

func NewBaremetalServerPrepareTask(
	baremetal IBaremetal,
) *SBaremetalServerPrepareTask

func (*SBaremetalServerPrepareTask) GetName

func (self *SBaremetalServerPrepareTask) GetName() string

func (*SBaremetalServerPrepareTask) NeedPXEBoot

func (self *SBaremetalServerPrepareTask) NeedPXEBoot() bool

func (*SBaremetalServerPrepareTask) OnPXEBootRequest

func (self *SBaremetalServerPrepareTask) OnPXEBootRequest(ctx context.Context, cli *ssh.Client, args interface{}) error

OnPXEBootRequest called by notify api handler

type SBaremetalServerRebuildTask

type SBaremetalServerRebuildTask struct {
	SBaremetalServerBaseDeployTask
}

func (*SBaremetalServerRebuildTask) DoDeploys

func (self *SBaremetalServerRebuildTask) DoDeploys(term *ssh.Client) (jsonutils.JSONObject, error)

func (*SBaremetalServerRebuildTask) GetName

func (self *SBaremetalServerRebuildTask) GetName() string

func (*SBaremetalServerRebuildTask) PostDeploys

func (self *SBaremetalServerRebuildTask) PostDeploys(term *ssh.Client) error

func (*SBaremetalServerRebuildTask) RemoveEFIOSEntry

func (self *SBaremetalServerRebuildTask) RemoveEFIOSEntry() bool

type SBaremetalServerStartTask

type SBaremetalServerStartTask struct {
	SBaremetalTaskBase
}

func (*SBaremetalServerStartTask) DoBoot

func (self *SBaremetalServerStartTask) DoBoot(ctx context.Context, args interface{}) error

func (*SBaremetalServerStartTask) GetName

func (self *SBaremetalServerStartTask) GetName() string

func (*SBaremetalServerStartTask) OnStartComplete

func (self *SBaremetalServerStartTask) OnStartComplete(ctx context.Context, args interface{}) error

func (*SBaremetalServerStartTask) WaitForStart

func (self *SBaremetalServerStartTask) WaitForStart(ctx context.Context, args interface{}) error

type SBaremetalServerStopTask

type SBaremetalServerStopTask struct {
	SBaremetalTaskBase
	// contains filtered or unexported fields
}

func (*SBaremetalServerStopTask) DoStop

func (task *SBaremetalServerStopTask) DoStop(ctx context.Context, args interface{}) error

func (*SBaremetalServerStopTask) GetName

func (self *SBaremetalServerStopTask) GetName() string

func (*SBaremetalServerStopTask) OnStopComplete

func (self *SBaremetalServerStopTask) OnStopComplete(ctx context.Context, args interface{}) error

func (*SBaremetalServerStopTask) WaitForStop

func (self *SBaremetalServerStopTask) WaitForStop(ctx context.Context, args interface{}) error

type SBaremetalTaskBase

type SBaremetalTaskBase struct {
	object.SObject

	Baremetal IBaremetal
	PxeBoot   bool
	// contains filtered or unexported fields
}

func (*SBaremetalTaskBase) EnsurePowerShutdown

func (self *SBaremetalTaskBase) EnsurePowerShutdown(soft bool) error

func (*SBaremetalTaskBase) EnsurePowerUp

func (self *SBaremetalTaskBase) EnsurePowerUp() error

func (*SBaremetalTaskBase) EnsureSSHReboot

func (self *SBaremetalTaskBase) EnsureSSHReboot() error

func (*SBaremetalTaskBase) Execute

func (task *SBaremetalTaskBase) Execute(args interface{})

func (*SBaremetalTaskBase) GetClientSession

func (task *SBaremetalTaskBase) GetClientSession() *mcclient.ClientSession

func (*SBaremetalTaskBase) GetData

func (task *SBaremetalTaskBase) GetData() jsonutils.JSONObject

func (*SBaremetalTaskBase) GetSSHStage

func (task *SBaremetalTaskBase) GetSSHStage() SSHTaskStageFunc

func (*SBaremetalTaskBase) GetStage

func (task *SBaremetalTaskBase) GetStage() TaskStageFunc

func (*SBaremetalTaskBase) GetStartTime

func (task *SBaremetalTaskBase) GetStartTime() time.Time

func (*SBaremetalTaskBase) GetTaskId

func (task *SBaremetalTaskBase) GetTaskId() string

func (*SBaremetalTaskBase) GetTaskQueue

func (task *SBaremetalTaskBase) GetTaskQueue() *TaskQueue

func (*SBaremetalTaskBase) ITask

func (task *SBaremetalTaskBase) ITask() ITask

func (*SBaremetalTaskBase) NeedPXEBoot

func (self *SBaremetalTaskBase) NeedPXEBoot() bool

func (*SBaremetalTaskBase) SSHExecute

func (task *SBaremetalTaskBase) SSHExecute(remoteIP string, password string, args interface{})

func (*SBaremetalTaskBase) SetSSHStage

func (task *SBaremetalTaskBase) SetSSHStage(stage SSHTaskStageFunc)

func (*SBaremetalTaskBase) SetSSHStageParams

func (task *SBaremetalTaskBase) SetSSHStageParams(remoteIP string, password string)

func (*SBaremetalTaskBase) SetStage

func (task *SBaremetalTaskBase) SetStage(stage TaskStageFunc)

type SBaremetalUnmaintenanceTask

type SBaremetalUnmaintenanceTask struct {
	SBaremetalTaskBase
}

func (*SBaremetalUnmaintenanceTask) DoUnmaintenance

func (task *SBaremetalUnmaintenanceTask) DoUnmaintenance(ctx context.Context, args interface{}) error

func (*SBaremetalUnmaintenanceTask) GetName

func (self *SBaremetalUnmaintenanceTask) GetName() string

func (*SBaremetalUnmaintenanceTask) OnStopComplete

func (self *SBaremetalUnmaintenanceTask) OnStopComplete(ctx context.Context, args interface{}) error

func (*SBaremetalUnmaintenanceTask) WaitForStop

func (self *SBaremetalUnmaintenanceTask) WaitForStop(ctx context.Context, args interface{}) error

type SSHTaskStageFunc

type SSHTaskStageFunc func(ctx context.Context, cli *ssh.Client, args interface{}) error

type TaskFactory

type TaskFactory func(userCred mcclient.TokenCredential, bm IBaremetal, taskId string, data jsonutils.JSONObject) ITask

type TaskQueue

type TaskQueue struct {
	*Queue
}

func NewTaskQueue

func NewTaskQueue() *TaskQueue

func (*TaskQueue) AppendTask

func (q *TaskQueue) AppendTask(task ITask) *TaskQueue

func (*TaskQueue) GetTask

func (q *TaskQueue) GetTask() ITask

func (*TaskQueue) PopTask

func (q *TaskQueue) PopTask() ITask

type TaskStageFunc

type TaskStageFunc func(ctx context.Context, args interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL