mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
esxi support
This commit is contained in:
@@ -2,6 +2,7 @@ package taskman
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -14,6 +15,8 @@ type ITask interface {
|
||||
GetTaskId() string
|
||||
SetStage(stageName string, data *jsonutils.JSONDict)
|
||||
|
||||
GetTaskRequestHeader() http.Header
|
||||
|
||||
SetStageComplete(ctx context.Context, data *jsonutils.JSONDict)
|
||||
SetStageFailed(ctx context.Context, reason string)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func init() {
|
||||
func Error2TaskData(err error) jsonutils.JSONObject {
|
||||
errJson := jsonutils.NewDict()
|
||||
errJson.Add(jsonutils.NewString("ERROR"), "__status__")
|
||||
errJson.Add(jsonutils.NewString(err.Error()), "reason")
|
||||
errJson.Add(jsonutils.NewString(err.Error()), "__reason__")
|
||||
return errJson
|
||||
}
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ func execITask(taskValue reflect.Value, task *STask, odata jsonutils.JSONObject,
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("Call %s %s", task.TaskName, stageName)
|
||||
log.Debugf("Call %s %s %#v", task.TaskName, stageName, params)
|
||||
funcValue.Call(params)
|
||||
|
||||
// call save request context
|
||||
@@ -648,3 +648,11 @@ func (self *STask) GetObject() db.IStandaloneModel {
|
||||
func (self *STask) GetObjects() []db.IStandaloneModel {
|
||||
return self.taskObjects
|
||||
}
|
||||
|
||||
func (task *STask) GetTaskRequestHeader() http.Header {
|
||||
header := http.Header{}
|
||||
header.Set(mcclient.AUTH_TOKEN, task.GetUserCred().GetTokenString())
|
||||
header.Set(mcclient.TASK_ID, task.GetTaskId())
|
||||
header.Set(mcclient.REGION_VERSION, "v2")
|
||||
return header
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user