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 LocalTaskRunWithWorkers(task ITask, proc func() (jsonutils.JSONObject, error), ...)
- func RegisterTask(task interface{})
- func RegisterTaskAndWorker(task interface{}, workerMan *appsrv.SWorkerManager)
- func SetServiceUrl(url string)
- 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(index int) 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) GetOwnerId() mcclient.IIdentityProvider
- func (self *STask) GetParams() *jsonutils.JSONDict
- func (self *STask) GetParentTask() *STask
- func (self *STask) GetPendingUsage(quota quotas.IQuota, index int) error
- func (self *STask) GetRequestContext() appctx.AppContextData
- func (task *STask) GetStartTime() time.Time
- func (self *STask) GetTaskId() string
- func (task *STask) GetTaskRequestHeader() http.Header
- func (self *STask) GetUserCred() mcclient.TokenCredential
- func (self *STask) HasParentTask() bool
- func (self *STask) IsCurrentStageComplete() bool
- func (self *STask) IsSubtask() bool
- func (self *STask) NotifyParentTaskComplete(ctx context.Context, body *jsonutils.JSONDict, failed bool)
- func (self *STask) NotifyParentTaskFailure(ctx context.Context, reason jsonutils.JSONObject)
- func (manager *STask) PreCheckPerformAction(ctx context.Context, userCred mcclient.TokenCredential, action string, ...) error
- func (self *STask) SaveParams(data *jsonutils.JSONDict) error
- func (self *STask) SaveRequestContext(data *appctx.AppContextData)
- func (task *STask) ScheduleRun(data jsonutils.JSONObject) error
- func (self *STask) SetPendingUsage(quota quotas.IQuota, index int) error
- func (self *STask) SetStage(stageName string, data *jsonutils.JSONDict) error
- func (self *STask) SetStageComplete(ctx context.Context, data *jsonutils.JSONDict)
- func (self *STask) SetStageFailed(ctx context.Context, reason jsonutils.JSONObject)
- func (self *STask) ValidateDeleteCondition(ctx context.Context, info jsonutils.JSONObject) error
- func (self *STask) ValidateUpdateCondition(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) CreateByInsertOrUpdate() bool
- func (manager *STaskManager) FetchIncompleteTasksOfObject(obj db.IStandaloneModel) ([]STask, error)
- func (manager *STaskManager) FetchTaskById(taskId string) *STask
- func (manager *STaskManager) FetchTasksOfObject(obj db.IStandaloneModel, since time.Time, isOpen *bool) ([]STask, error)
- func (manager *STaskManager) FetchTasksOfObjectLatest(obj db.IStandaloneModel, interval time.Duration, isOpen *bool) ([]STask, error)
- 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, owner mcclient.IIdentityProvider, ...) *sqlchemy.SQuery
- func (manager *STaskManager) IsInTask(obj db.IStandaloneModel) bool
- 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)
- func (manager *STaskManager) QueryTasksOfObject(obj db.IStandaloneModel, since time.Time, isOpen *bool) *sqlchemy.SQuery
- 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" CONVERT_TASK = "convert_task" LANG = "lang" )
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 LocalTaskRunWithWorkers ¶
func LocalTaskRunWithWorkers(task ITask, proc func() (jsonutils.JSONObject, error), wm *appsrv.SWorkerManager)
func RegisterTask ¶
func RegisterTask(task interface{})
func RegisterTaskAndWorker ¶
func RegisterTaskAndWorker(task interface{}, workerMan *appsrv.SWorkerManager)
func SetServiceUrl ¶
func SetServiceUrl(url string)
Types ¶
type IBatchTask ¶
type IBatchTask interface { OnInit(ctx context.Context, objs []db.IStandaloneModel, body jsonutils.JSONObject) ScheduleRun(data jsonutils.JSONObject) error }
type ISingleTask ¶
type ISingleTask interface { OnInit(ctx context.Context, obj db.IStandaloneModel, body jsonutils.JSONObject) ScheduleRun(data jsonutils.JSONObject) error }
type ITask ¶
type ITask interface { GetStartTime() time.Time ScheduleRun(data jsonutils.JSONObject) error GetParams() *jsonutils.JSONDict GetUserCred() mcclient.TokenCredential GetTaskId() string SetStage(stageName string, data *jsonutils.JSONDict) error GetTaskRequestHeader() http.Header SetStageComplete(ctx context.Context, data *jsonutils.JSONDict) SetStageFailed(ctx context.Context, reason jsonutils.JSONObject) GetPendingUsage(quota quotas.IQuota, index int) error ClearPendingUsage(index int) error }
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:"utf8" 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" index:"true"` // 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:"utf8" 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:"utf8" 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) GetOwnerId ¶
func (self *STask) GetOwnerId() mcclient.IIdentityProvider
func (*STask) GetParentTask ¶
func (*STask) GetPendingUsage ¶
func (*STask) GetRequestContext ¶
func (self *STask) GetRequestContext() appctx.AppContextData
func (*STask) GetStartTime ¶
func (*STask) GetTaskRequestHeader ¶
func (*STask) GetUserCred ¶
func (self *STask) GetUserCred() mcclient.TokenCredential
func (*STask) HasParentTask ¶
func (*STask) IsCurrentStageComplete ¶
func (*STask) NotifyParentTaskComplete ¶
func (*STask) NotifyParentTaskFailure ¶
func (self *STask) NotifyParentTaskFailure(ctx context.Context, reason jsonutils.JSONObject)
func (*STask) PreCheckPerformAction ¶
func (manager *STask) PreCheckPerformAction( ctx context.Context, userCred mcclient.TokenCredential, action string, query jsonutils.JSONObject, data jsonutils.JSONObject, ) error
func (*STask) SaveRequestContext ¶
func (self *STask) SaveRequestContext(data *appctx.AppContextData)
func (*STask) ScheduleRun ¶
func (task *STask) ScheduleRun(data jsonutils.JSONObject) error
func (*STask) SetPendingUsage ¶
func (*STask) SetStageComplete ¶
func (*STask) SetStageFailed ¶
func (self *STask) SetStageFailed(ctx context.Context, reason jsonutils.JSONObject)
func (*STask) ValidateDeleteCondition ¶
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) CreateByInsertOrUpdate ¶
func (manager *STaskManager) CreateByInsertOrUpdate() bool
func (*STaskManager) FetchIncompleteTasksOfObject ¶
func (manager *STaskManager) FetchIncompleteTasksOfObject(obj db.IStandaloneModel) ([]STask, error)
func (*STaskManager) FetchTaskById ¶
func (manager *STaskManager) FetchTaskById(taskId string) *STask
func (*STaskManager) FetchTasksOfObject ¶
func (manager *STaskManager) FetchTasksOfObject(obj db.IStandaloneModel, since time.Time, isOpen *bool) ([]STask, error)
func (*STaskManager) FetchTasksOfObjectLatest ¶
func (manager *STaskManager) FetchTasksOfObjectLatest(obj db.IStandaloneModel, interval time.Duration, isOpen *bool) ([]STask, error)
func (*STaskManager) FilterById ¶
func (*STaskManager) FilterByName ¶
func (*STaskManager) FilterByNotId ¶
func (*STaskManager) FilterByOwner ¶
func (manager *STaskManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery
func (*STaskManager) IsInTask ¶
func (manager *STaskManager) IsInTask(obj db.IStandaloneModel) bool
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)
func (*STaskManager) QueryTasksOfObject ¶
func (manager *STaskManager) QueryTasksOfObject(obj db.IStandaloneModel, since time.Time, isOpen *bool) *sqlchemy.SQuery
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.