Documentation ¶
Index ¶
- Constants
- Variables
- func AddTaskHandler(prefix string, app *appsrv.Application)
- func Error2TaskData(err error) jsonutils.JSONObject
- func LocalTaskRun(task ITask, proc func() (jsonutils.JSONObject, error))
- func RegisterTask(task interface{})
- type IBatchTask
- type ISingleTask
- type ITask
- type SSubTask
- type SSubTaskmanager
- type STask
- func (self *STask) AllowDeleteItem(ctx context.Context, userCred mcclient.TokenCredential, ...) bool
- func (self *STask) AllowGetDetails(ctx context.Context, userCred mcclient.TokenCredential, ...) bool
- func (self *STask) AllowUpdateItem(ctx context.Context, userCred mcclient.TokenCredential) bool
- func (self *STask) BeforeInsert()
- func (self *STask) ClearPendingUsage() error
- func (self *STask) GetId() string
- func (self *STask) GetName() string
- func (self *STask) GetObject() db.IStandaloneModel
- func (self *STask) GetObjectIdStr() string
- func (self *STask) GetObjects() []db.IStandaloneModel
- func (self *STask) GetParams() *jsonutils.JSONDict
- func (self *STask) GetParentTask() *STask
- func (self *STask) GetPendingUsage(quota quotas.IQuota) error
- func (self *STask) GetRequestContext() appctx.AppContextData
- func (self *STask) GetTaskId() string
- func (self *STask) GetUserCred() mcclient.TokenCredential
- func (self *STask) IsCurrentStageComplete() bool
- func (self *STask) NotifyParentTaskComplete(ctx context.Context, body *jsonutils.JSONDict, failed bool)
- func (self *STask) NotifyParentTaskFailure(ctx context.Context, reason string)
- func (self *STask) SaveRequestContext(data *appctx.AppContextData)
- func (task *STask) ScheduleRun(data jsonutils.JSONObject)
- func (self *STask) SetPendingUsage(quota quotas.IQuota) error
- func (self *STask) SetStage(stageName string, data *jsonutils.JSONDict)
- func (self *STask) SetStageComplete(ctx context.Context, data *jsonutils.JSONDict)
- func (self *STask) SetStageFailed(ctx context.Context, reason string)
- func (self *STask) ValidateDeleteCondition(ctx context.Context) error
- type STaskManager
- func (manager *STaskManager) AllowCreateItem(ctx context.Context, userCred mcclient.TokenCredential, ...) bool
- func (manager *STaskManager) AllowListItems(ctx context.Context, userCred mcclient.TokenCredential, ...) bool
- func (manager *STaskManager) AllowPerformAction(ctx context.Context, userCred mcclient.TokenCredential, action string, ...) bool
- func (manager *STaskManager) FilterById(q *sqlchemy.SQuery, idStr string) *sqlchemy.SQuery
- func (manager *STaskManager) FilterByName(q *sqlchemy.SQuery, name string) *sqlchemy.SQuery
- func (manager *STaskManager) FilterByNotId(q *sqlchemy.SQuery, idStr string) *sqlchemy.SQuery
- func (manager *STaskManager) FilterByOwner(q *sqlchemy.SQuery, ownerProjId string) *sqlchemy.SQuery
- func (manager *STaskManager) NewParallelTask(ctx context.Context, taskName string, objs []db.IStandaloneModel, ...) (*STask, error)
- func (manager *STaskManager) NewTask(ctx context.Context, taskName string, obj db.IStandaloneModel, ...) (*STask, error)
- func (manager *STaskManager) PerformAction(ctx context.Context, userCred mcclient.TokenCredential, taskId string, ...) (jsonutils.JSONObject, error)
- type STaskObject
- type STaskObjectManager
Constants ¶
View Source
const ( SUBTASK_INIT = "init" SUBTASK_FAIL = "fail" SUBTASK_SUCC = "succ" )
View Source
const ( PARENT_TASK_ID_KEY = "parent_task_id" PENDING_USAGE_KEY = "__pending_usage__" PARENT_TASK_NOTIFY_KEY = "__parent_task_notifyurl" REQUEST_CONTEXT_KEY = "__request_context" TASK_STAGE_FAILED = "failed" TASK_STAGE_COMPLETE = "complete" MAX_REMOTE_NOTIFY_TRIES = 5 MULTI_OBJECTS_ID = "[--MULTI_OBJECTS--]" TASK_INIT_STAGE = "on_init" )
Variables ¶
View Source
var IBatchTaskType reflect.Type
View Source
var ITaskType reflect.Type
Functions ¶
func AddTaskHandler ¶
func AddTaskHandler(prefix string, app *appsrv.Application)
func Error2TaskData ¶
func Error2TaskData(err error) jsonutils.JSONObject
func LocalTaskRun ¶
func LocalTaskRun(task ITask, proc func() (jsonutils.JSONObject, error))
func RegisterTask ¶
func RegisterTask(task interface{})
Types ¶
type IBatchTask ¶
type IBatchTask interface { OnInit(ctx context.Context, objs []db.IStandaloneModel, body jsonutils.JSONObject) ScheduleRun(data jsonutils.JSONObject) }
type ISingleTask ¶
type ISingleTask interface { OnInit(ctx context.Context, obj db.IStandaloneModel, body jsonutils.JSONObject) ScheduleRun(data jsonutils.JSONObject) }
type ITask ¶
type ITask interface { ScheduleRun(data jsonutils.JSONObject) GetParams() *jsonutils.JSONDict GetUserCred() mcclient.TokenCredential GetTaskId() string SetStage(stageName string, data *jsonutils.JSONDict) SetStageComplete(ctx context.Context, data *jsonutils.JSONDict) SetStageFailed(ctx context.Context, reason string) }
type SSubTask ¶
type SSubTask struct { db.SModelBase TaskId string `width:"36" charset:"ascii" nullable:"false" primary:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False, primary_key=True) Stage string `width:"64" charset:"ascii" nullable:"false" primary:"true"` // Column(VARCHAR(64, charset='ascii'), nullable=False, primary_key=True) SubtaskId string `width:"36" charset:"ascii" nullable:"false" primary:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False, primary_key=True) Status string `width:"36" charset:"ascii" nullable:"false" default:"init"` // Column(VARCHAR(36, charset='ascii'), nullable=False, default=SUBTASK_INIT) Result string `length:"medium" charset:"ascii" nullable:"true"` // Column(MEDIUMTEXT(charset='ascii'), nullable=True) }
func (*SSubTask) SaveResults ¶
func (self *SSubTask) SaveResults(failed bool, result jsonutils.JSONObject) error
type SSubTaskmanager ¶
type SSubTaskmanager struct {
db.SModelBaseManager
}
var SubTaskManager *SSubTaskmanager
func (*SSubTaskmanager) GetInitSubtasks ¶
func (manager *SSubTaskmanager) GetInitSubtasks(taskId string, stage string) []SSubTask
func (*SSubTaskmanager) GetSubTask ¶
func (manager *SSubTaskmanager) GetSubTask(ptaskId string, subtaskId string) *SSubTask
func (*SSubTaskmanager) GetTotalSubtasks ¶
func (manager *SSubTaskmanager) GetTotalSubtasks(taskId string, stage string, status string) []SSubTask
type STask ¶
type STask struct { db.SResourceBase Id string `width:"36" charset:"ascii" primary:"true" list:"user"` // Column(VARCHAR(36, charset='ascii'), primary_key=True, default=get_uuid) ObjName string `width:"128" charset:"utf8" nullable:"false" list:"user"` // Column(VARCHAR(128, charset='utf8'), nullable=False) ObjId string `width:"128" charset:"ascii" nullable:"false" list:"user"` // Column(VARCHAR(ID_LENGTH, charset='ascii'), nullable=False) TaskName string `width:"64" charset:"ascii" nullable:"false" list:"user"` // Column(VARCHAR(64, charset='ascii'), nullable=False) UserCred mcclient.TokenCredential `width:"1024" charset:"ascii" nullable:"false" get:"user"` // Column(VARCHAR(1024, charset='ascii'), nullable=False) // OwnerCred string `width:"512" charset:"ascii" nullable:"true"` // Column(VARCHAR(512, charset='ascii'), nullable=True) Params *jsonutils.JSONDict `charset:"ascii" length:"medium" nullable:"false" get:"user"` // Column(MEDIUMTEXT(charset='ascii'), nullable=False) Stage string `width:"64" charset:"ascii" nullable:"false" default:"on_init" list:"user"` // Column(VARCHAR(64, charset='ascii'), nullable=False, default='on_init') // contains filtered or unexported fields }
func (*STask) AllowDeleteItem ¶
func (self *STask) AllowDeleteItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool
func (*STask) AllowGetDetails ¶
func (self *STask) AllowGetDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool
func (*STask) AllowUpdateItem ¶
func (*STask) BeforeInsert ¶
func (self *STask) BeforeInsert()
func (*STask) ClearPendingUsage ¶
func (*STask) GetObject ¶
func (self *STask) GetObject() db.IStandaloneModel
func (*STask) GetObjectIdStr ¶
func (*STask) GetObjects ¶
func (self *STask) GetObjects() []db.IStandaloneModel
func (*STask) GetParentTask ¶
func (*STask) GetRequestContext ¶
func (self *STask) GetRequestContext() appctx.AppContextData
func (*STask) GetUserCred ¶
func (self *STask) GetUserCred() mcclient.TokenCredential
func (*STask) IsCurrentStageComplete ¶
func (*STask) NotifyParentTaskComplete ¶
func (*STask) NotifyParentTaskFailure ¶
func (*STask) SaveRequestContext ¶
func (self *STask) SaveRequestContext(data *appctx.AppContextData)
func (*STask) ScheduleRun ¶
func (task *STask) ScheduleRun(data jsonutils.JSONObject)
func (*STask) SetStageComplete ¶
func (*STask) SetStageFailed ¶
type STaskManager ¶
type STaskManager struct {
db.SResourceBaseManager
}
var TaskManager *STaskManager
func (*STaskManager) AllowCreateItem ¶
func (manager *STaskManager) AllowCreateItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool
func (*STaskManager) AllowListItems ¶
func (manager *STaskManager) AllowListItems(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool
func (*STaskManager) AllowPerformAction ¶
func (manager *STaskManager) AllowPerformAction(ctx context.Context, userCred mcclient.TokenCredential, action string, query jsonutils.JSONObject, data jsonutils.JSONObject) bool
func (*STaskManager) FilterById ¶
func (*STaskManager) FilterByName ¶
func (*STaskManager) FilterByNotId ¶
func (*STaskManager) FilterByOwner ¶
func (*STaskManager) NewParallelTask ¶
func (*STaskManager) PerformAction ¶
func (manager *STaskManager) PerformAction(ctx context.Context, userCred mcclient.TokenCredential, taskId string, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error)
type STaskObject ¶
type STaskObject struct { db.SModelBase TaskId string `width:"36" charset:"ascii" nullable:"false" primary:"true" index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False, primary_key=True, index=True) ObjId string `width:"36" charset:"ascii" nullable:"false" primary:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False, primary_key=True) }
type STaskObjectManager ¶
type STaskObjectManager struct {
db.SModelBaseManager
}
var TaskObjectManager *STaskObjectManager
func (*STaskObjectManager) GetObjectIds ¶
func (manager *STaskObjectManager) GetObjectIds(task *STask) []string
Click to show internal directories.
Click to hide internal directories.