models

package
v0.0.0-...-6410feb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Action = SAction{/* contains filtered or unexported fields */}

Action itself is meaningless, a meaningful Action is generated by calling Resource, Operation, Session and DefaultParams. A example:

Action.ResourceOperation(ServerStart).Session(...).Apply(...)

Modules describe the correspondence between Resource and modulebase.ResourceManager, which is equivalent to onecloud resource client.

View Source
var (
	TIMERLANG = "timerLang"
)

Functions

func Register

func Register(resource Resource, manager modulebase.ResourceManager)

Every Resource should call Register to register their modulebase.ResourceManager.

Types

type Resource

type Resource string

Resoruce describe a onecloud resource, such as:

const (
	ResourceServer       Resource = api.ST_RESOURCE_SERVER
	ResourceCloudAccount Resource = api.ST_RESOURCE_CLOUDACCOUNT
)

type ResourceOperation

type ResourceOperation struct {
	Resource      Resource
	Operation     string
	StatusSuccess []string
	Fail          []ResourceOperationFail
	Params        *jsonutils.JSONDict
}

ResourceOperation describe the operation for onecloud resource like create, update, delete and so on.

var (
	ServerStart          ResourceOperation
	ServerStop           ResourceOperation
	ServerRestart        ResourceOperation
	CloudAccountSync     ResourceOperation
	ResourceOperationMap map[string]ResourceOperation
)

type ResourceOperationFail

type ResourceOperationFail struct {
	Status   string
	LogEvent string
}

type SAction

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

SAction encapsulates action to for onecloud resources

func (SAction) Apply

func (r SAction) Apply(id string) (success bool, failReason string)

func (SAction) List

func (r SAction) List(opts *WrapperListOptions) (map[string]string, error)

func (SAction) ResourceOperation

func (r SAction) ResourceOperation(oper ResourceOperation) SAction

func (SAction) Session

func (r SAction) Session(session *mcclient.ClientSession) SAction

func (SAction) Timeout

func (r SAction) Timeout(time time.Duration) SAction

type SScheduledTask

type SScheduledTask struct {
	db.SVirtualResourceBase
	db.SEnabledResourceBase

	ScheduledType string `width:"16" charset:"ascii" create:"required" list:"user" get:"user"`

	STimer

	ResourceType string `width:"32" charset:"ascii" create:"required" list:"user" get:"user"`
	Operation    string `width:"32" charset:"ascii" create:"required" list:"user" get:"user"`
	LabelType    string `width:"4" charset:"ascii" create:"required" list:"user" get:"user"`
}

func (*SScheduledTask) Action

func (st *SScheduledTask) Action(ctx context.Context, userCred mcclient.TokenCredential) SAction

func (*SScheduledTask) CustomizeDelete

func (st *SScheduledTask) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error

func (*SScheduledTask) Execute

func (st *SScheduledTask) Execute(ctx context.Context, userCred mcclient.TokenCredential) (err error)

func (*SScheduledTask) ExecuteNotify

func (st *SScheduledTask) ExecuteNotify(ctx context.Context, userCred mcclient.TokenCredential, name string)

func (*SScheduledTask) IsExecuted

func (st *SScheduledTask) IsExecuted() (bool, error)

func (*SScheduledTask) Labels

func (st *SScheduledTask) Labels() ([]string, error)

func (*SScheduledTask) NewActivity

func (st *SScheduledTask) NewActivity(ctx context.Context, reject bool) (*SScheduledTaskActivity, error)

func (*SScheduledTask) PerformDisable

func (*SScheduledTask) PerformEnable

func (*SScheduledTask) PerformSetLabels

func (*SScheduledTask) PerformTrigger

func (*SScheduledTask) PostCreate

func (*SScheduledTask) ResourceOperation

func (st *SScheduledTask) ResourceOperation() ResourceOperation

func (*SScheduledTask) STLabels

func (st *SScheduledTask) STLabels() ([]SScheduledTaskLabel, error)

func (*SScheduledTask) ValidateDeleteCondition

func (st *SScheduledTask) ValidateDeleteCondition(ctx context.Context, info jsonutils.JSONObject) error

type SScheduledTaskActivity

type SScheduledTaskActivity struct {
	db.SStatusStandaloneResourceBase
	ScheduledTaskId string    `width:"36" charset:"ascii" nullable:"true" list:"user" index:"true"`
	StartTime       time.Time `list:"user"`
	EndTime         time.Time `list:"user"`
	Reason          string    `charset:"utf8" list:"user"`
}

func (*SScheduledTaskActivity) Fail

func (sa *SScheduledTaskActivity) Fail(reason string) error

func (*SScheduledTaskActivity) GetOwnerId

func (*SScheduledTaskActivity) PartFail

func (sa *SScheduledTaskActivity) PartFail(reason string) error

func (*SScheduledTaskActivity) SetResult

func (sa *SScheduledTaskActivity) SetResult(status, reason string) error

func (*SScheduledTaskActivity) Succeed

func (sa *SScheduledTaskActivity) Succeed() error

type SScheduledTaskActivityManager

type SScheduledTaskActivityManager struct {
	db.SStatusStandaloneResourceBaseManager
}

+onecloud:swagger-gen-model-singular=scheduledtaskactivity +onecloud:swagger-gen-model-singular=scheduledtaskactivities

var ScheduledTaskActivityManager *SScheduledTaskActivityManager

func (*SScheduledTaskActivityManager) FetchCustomizeColumns

func (sam *SScheduledTaskActivityManager) FetchCustomizeColumns(
	ctx context.Context,
	userCred mcclient.TokenCredential,
	query jsonutils.JSONObject,
	objs []interface{},
	fields stringutils2.SSortedStrings,
	isList bool,
) []api.ScheduledTaskActivityDetails

func (*SScheduledTaskActivityManager) FetchOwnerId

func (*SScheduledTaskActivityManager) FileterByOwner

func (*SScheduledTaskActivityManager) InitializeData

func (sam *SScheduledTaskActivityManager) InitializeData() error

func (*SScheduledTaskActivityManager) ListItemFilter

func (*SScheduledTaskActivityManager) NamespaceScope

func (sam *SScheduledTaskActivityManager) NamespaceScope() rbacscope.TRbacScope

func (*SScheduledTaskActivityManager) OrderByExtraFields

func (*SScheduledTaskActivityManager) QueryDistinctExtraField

func (sam *SScheduledTaskActivityManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error)

func (*SScheduledTaskActivityManager) ResourceScope

func (sam *SScheduledTaskActivityManager) ResourceScope() rbacscope.TRbacScope

type SScheduledTaskLabel

type SScheduledTaskLabel struct {
	db.SResourceBase
	ScheduledTaskId string `width:"36" charset:"ascii" nullable:"false" primary:"true"`
	Label           string `width:"64" charset:"utf8" nullable:"false" primary:"true"`
}

func (*SScheduledTaskLabel) Detach

type SScheduledTaskLabelManager

type SScheduledTaskLabelManager struct {
	db.SResourceBaseManager
}
var ScheduledTaskLabelManager *SScheduledTaskLabelManager

func (*SScheduledTaskLabelManager) Attach

func (slm *SScheduledTaskLabelManager) Attach(ctx context.Context, taskId, label string) error

type SScheduledTaskManager

type SScheduledTaskManager struct {
	db.SVirtualResourceBaseManager
	db.SEnabledResourceBaseManager
}

+onecloud:swagger-gen-model-singular=scheduledtask +onecloud:swagger-gen-model-singular=scheduledtasks

var ScheduledTaskManager *SScheduledTaskManager

func (*SScheduledTaskManager) FetchCustomizeColumns

func (stm *SScheduledTaskManager) FetchCustomizeColumns(
	ctx context.Context,
	userCred mcclient.TokenCredential,
	query jsonutils.JSONObject,
	objs []interface{},
	fields stringutils2.SSortedStrings,
	isList bool,
) []api.ScheduledTaskDetails

func (*SScheduledTaskManager) ListItemFilter

func (*SScheduledTaskManager) OrderByExtraFields

func (*SScheduledTaskManager) Timer

func (stm *SScheduledTaskManager) Timer(ctx context.Context, userCred mcclient.TokenCredential, isStart bool)

type STimeScope

type STimeScope struct {
	Start  time.Time
	End    time.Time
	Median time.Time
}

type STimer

type STimer struct {
	// Cycle type
	Type string `width:"8" charset:"ascii"`
	// 0-59
	Minute int `nullable:"false"`
	// 0-23
	Hour int `nullable:"false"`

	CycleNum int `nullable:"false"`

	// 0-7 1 is Monday 0 is unlimited
	WeekDays uint8 `nullable:"false"`
	// 0-31 0 is unlimited
	MonthDays uint32 `nullable:"false"`

	// StartTime represent the start time of this timer
	StartTime time.Time
	// EndTime represent deadline of this timer
	EndTime time.Time
	// NextTime represent the time timer should bell
	NextTime  time.Time `index:"true"`
	IsExpired bool
}

func (*STimer) CycleTimerDetails

func (st *STimer) CycleTimerDetails() api.CycleTimerDetails

func (*STimer) Description

func (st *STimer) Description(ctx context.Context, createdAt time.Time, zone *time.Location) string

func (*STimer) GetMonthDays

func (st *STimer) GetMonthDays() []int

func (*STimer) GetWeekDays

func (st *STimer) GetWeekDays() []int

func (*STimer) MonthDaySum

func (st *STimer) MonthDaySum(t time.Time) int

MonthDaySum calculate the number of month's days

func (*STimer) SetMonthDays

func (st *STimer) SetMonthDays(days []int)

func (*STimer) SetWeekDays

func (st *STimer) SetWeekDays(days []int)

func (*STimer) TimerDetails

func (st *STimer) TimerDetails() api.TimerDetails

func (*STimer) Update

func (st *STimer) Update(now time.Time)

Update will update the SScalingTimer

type WrapperListOptions

type WrapperListOptions struct {
	options.BaseListOptions
}

Jump to

Keyboard shortcuts

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