mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
temp
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package hostman
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/appctx"
|
||||
"yunion.io/x/onecloud/pkg/hostman/options"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
var session *mcclient.ClientSession
|
||||
|
||||
func GetComputeSession() *mcclient.ClientSession {
|
||||
return session
|
||||
}
|
||||
|
||||
func init() {
|
||||
session = auth.GetAdminSession(options.HostOptions.Region, "v2")
|
||||
}
|
||||
|
||||
func TaskFailed(ctx context.Context, reason string) error {
|
||||
if taskId := ctx.Value(appctx.APP_CONTEXT_KEY_TASK_ID); taskId != nil {
|
||||
modules.ComputeTasks.TaskFailed(ctx, taskId.(string), reason)
|
||||
return nil
|
||||
} else {
|
||||
log.Errorln("Reqeuest task failed missing task id, with reason(%s)", reason)
|
||||
return fmt.Errorf("Reqeuest task failed missing task id")
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/workmanager"
|
||||
"yunion.io/x/onecloud/pkg/hostman/guestfs"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/pkg/util/regutils"
|
||||
"yunion.io/x/pkg/util/seclib"
|
||||
)
|
||||
@@ -350,15 +348,6 @@ func Init(serversPath string) {
|
||||
|
||||
var guestManger *SGuestManager
|
||||
var wm *workmanager.SWorkManager
|
||||
var session *mcclient.ClientSession
|
||||
|
||||
func SetClientSession() *mcclient.ClientSession {
|
||||
session = auth.GetAdminSession(o.Options.Region, "v2")
|
||||
}
|
||||
|
||||
func GetClinetSession() *mcclient.ClientSession {
|
||||
return session
|
||||
}
|
||||
|
||||
func GetGuestManager() *SGuestManager {
|
||||
return guestManger
|
||||
|
||||
@@ -41,8 +41,7 @@ func (s *SGuestStopTask) onPowerdownGuest(results string) {
|
||||
|
||||
func (s *SGuestStopTask) checkGuestRunning() {
|
||||
if !s.IsRunning() || time.Now().Sub(*s.startPowerdown) > (s.timeout*time.Duration) {
|
||||
// force stop
|
||||
s.Stop()
|
||||
s.Stop() // force stop
|
||||
httpclients.TaskComplete(s.ctx, nil)
|
||||
} else {
|
||||
s.CheckGuestRunningLater()
|
||||
|
||||
@@ -20,10 +20,8 @@ type ComputeTasksManager struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
Tasks = NewITSMManager("task", "taskman",
|
||||
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "instance_id", "business_id", "task_id", "task_type", "task_name", "task_status", "current_approver", "approver_name", "receive_time", "finish_time", "result", "content", "common_start_string"},
|
||||
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "instance_id", "business_id", "task_id", "task_type", "task_name", "task_status", "current_approver", "approver_name", "receive_time", "finish_time", "result", "content", "common_start_string"},
|
||||
)
|
||||
cols := []string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "instance_id", "business_id", "task_id", "task_type", "task_name", "task_status", "current_approver", "approver_name", "receive_time", "finish_time", "result", "content", "common_start_string"}
|
||||
Tasks = NewITSMManager("task", "taskman", cols, cols)
|
||||
register(&Tasks)
|
||||
|
||||
ComputeTasks = ComputeTasksManager{
|
||||
|
||||
Reference in New Issue
Block a user