api

package
v0.3.10-0-alpha2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 21 Imported by: 8

Documentation

Index

Constants

View Source
const (
	HostTypeHost         = "host"
	HostTypeBaremetal    = "baremetal"
	SchedTypeGuest       = "guest"
	SchedTypeBaremetal   = "baremetal"
	SchedTypeContainer   = "container"
	SchedTypeEsxi        = "esxi"
	SchedTypeHyperV      = "hyperv"
	SchedTypeKvm         = "kvm"
	HostHypervisorForKvm = "hypervisor"
	HostTypeKubelet      = "kubelet"

	AggregateStrategyRequire = "require"
	AggregateStrategyExclude = "exclude"
	AggregateStrategyPrefer  = "prefer"
	AggregateStrategyAvoid   = "avoid"

	// passthrough device type
	DIRECT_PCI_TYPE = "PCI"
	GPU_HPC_TYPE    = "GPU-HPC"
	GPU_VGA_TYPE    = "GPU-VGA"
	USB_TYPE        = "USB"
	NIC_TYPE        = "NIC"

	// Hard code vendor const
	NVIDIA           = "NVIDIA"
	AMD              = "AMD"
	NVIDIA_VENDOR_ID = "10de"
	AMD_VENDOR_ID    = "1002"
)
View Source
const (
	DefaultCandidateListArgsLimit = 20
)

Variables

View Source
var (
	AggregateStrategySets = sets.NewString(
		AggregateStrategyRequire,
		AggregateStrategyExclude,
		AggregateStrategyPrefer,
		AggregateStrategyAvoid,
	)

	ValidGpuTypes = sets.NewString(
		GPU_HPC_TYPE,
		GPU_VGA_TYPE,
	)

	ValidPassthroughTypes = sets.NewString(
		DIRECT_PCI_TYPE,
		USB_TYPE,
		NIC_TYPE,
	).Union(ValidGpuTypes)

	IsolatedVendorIDMap = map[string]string{
		NVIDIA: NVIDIA_VENDOR_ID,
		AMD:    AMD_VENDOR_ID,
	}

	IsolatedIDVendorMap = map[string]string{}
)

Functions

func FetchAuthToken

func FetchAuthToken(req *http.Request) (mcclient.TokenCredential, error)

func FetchUserCred

func FetchUserCred(req *http.Request) (mcclient.TokenCredential, error)

func SchedtagStrategyCheck

func SchedtagStrategyCheck(strategy string) (err error)

Types

type CandidateDetailArgs

type CandidateDetailArgs struct {
	ID   string
	Type string
}

CandidateDetailArgs is a struct just for parsing candidate resource parameters.

func NewCandidateDetailArgs

func NewCandidateDetailArgs(sjson *simplejson.Json, id string) (*CandidateDetailArgs, error)

NewCandidateDetailArgs provides a function that will parse candidate's args from a json data.

type CandidateDetailResult

type CandidateDetailResult struct {
	Candidate interface{} `json:"candidate"`
}

type CandidateGroup

type CandidateGroup struct {
	*models.SGroup
	ReferCount int
}

type CandidateListArgs

type CandidateListArgs struct {
	Type   string `json:"type"`
	Region string `json:"region"`
	Zone   string `json:"zone"`
	//Pool      string
	Limit     int64 `json:"limit"`
	Offset    int64 `json:"offset"`
	Avaliable bool  `json:"available"`
}

CandidateListArgs is a struct just for parsing candidate resource list parameters.

func NewCandidateListArgs

func NewCandidateListArgs(r io.Reader) (*CandidateListArgs, error)

NewCandidateListArgs provides a function that will parse candidate's list args from a json data.

type CandidateListResult

type CandidateListResult struct {
	Data   []CandidateListResultItem `json:"data"`
	Total  int64                     `json:"total"`
	Limit  int64                     `json:"limit"`
	Offset int64                     `json:"offset"`
}

type CandidateListResultItem

type CandidateListResultItem struct {
	ID           string                 `json:"id"`
	Name         string                 `json:"name"`
	Cpu          ResultResource         `json:"cpu"`
	Mem          ResultResource         `json:"mem"`
	Storage      ResultResource         `json:"storage"`
	Status       string                 `json:"status"`
	HostStatus   string                 `json:"host_status"`
	EnableStatus string                 `json:"enable_status"`
	HostType     string                 `json:"host_type"`
	PendingUsage map[string]interface{} `json:"pending_usage"`
}

type CandidateNetwork

type CandidateNetwork struct {
	*models.SNetwork
	Schedtags []models.SSchedtag `json:"schedtags"`
	FreePort  int                `json:"free_port"`

	Provider string
	VpcId    string
}

type CandidateStorage

type CandidateStorage struct {
	*models.SStorage
	Schedtags          []models.SSchedtag `json:"schedtags"`
	FreeCapacity       int64              `json:"free_capacity"`
	ActualFreeCapacity int64              `json:"actual_free_capacity"`
}

type CleanupArgs

type CleanupArgs struct {
	ResType string
}

func NewCleanupArgs

func NewCleanupArgs(sjson *simplejson.Json) (*CleanupArgs, error)

type CleanupResult

type CleanupResult struct {
}

type CompletedNotifyArgs

type CompletedNotifyArgs struct {
	SessionID string
}

func NewCompletedNotifyArgs

func NewCompletedNotifyArgs(sjson *simplejson.Json, sessionId string) (*CompletedNotifyArgs, error)

type CompletedNotifyResult

type CompletedNotifyResult struct {
}

type ExpireArgs

type ExpireArgs struct {
	DirtyHosts      []string
	DirtyBaremetals []string
	SessionId       string
}

type ExpireResult

type ExpireResult struct {
}

type FilteredCandidate

type FilteredCandidate struct {
	ID         string   `json:"id"`
	Name       string   `json:"name"`
	FilterName string   `json:"filter_name"`
	Reasons    []string `json:"reasons"`
}

type ForecastFilter

type ForecastFilter struct {
	Filter   string   `json:"filter"`
	Messages []string `json:"messages"`
	Count    int64    `json:"count"`
}

type HistoryArgs

type HistoryArgs struct {
	Offset       int64
	Limit        int64
	All          bool
	IsSuggestion bool
}

func NewHistoryArgs

func NewHistoryArgs(sjson *simplejson.Json) (*HistoryArgs, error)

type HistoryDetail

type HistoryDetail struct {
	Time      string        `json:"time"`
	Consuming string        `json:"consuming"`
	SessionID string        `json:"session_id"`
	Tasks     []HistoryTask `json:"tasks"`
	Input     string        `json:"input"`
	Output    string        `json:"output"`
	Error     string        `json:"error"`
}

type HistoryDetailArgs

type HistoryDetailArgs struct {
	ID  string
	Raw bool
	Log bool
}

func NewHistoryDetailArgs

func NewHistoryDetailArgs(sjson *simplejson.Json, id string) (*HistoryDetailArgs, error)

type HistoryDetailResult

type HistoryDetailResult struct {
	Detail *HistoryDetail `json:"history"`
}

type HistoryItem

type HistoryItem struct {
	Time         string   `json:"time"`
	Consuming    string   `json:"consuming"`
	SessionID    string   `json:"session_id"`
	Count        string   `json:"count"`
	Tenants      []string `json:"tenants"`
	Status       string   `json:"status"`
	Guests       []string `json:"guests"`
	IsSuggestion bool     `json:"is_suggestion"`
}

type HistoryResult

type HistoryResult struct {
	Items  []*HistoryItem `json:"data"`
	Total  int64          `json:"total"`
	Offset int64          `json:"offset"`
	Limit  int64          `json:"limit"`
}

type HistoryTask

type HistoryTask struct {
	Type      string     `json:"type"`
	Status    string     `json:"status"`
	Data      *SchedInfo `json:"data"`
	Time      string     `json:"time"`
	Consuming string     `json:"consuming"`
	//Result    []SchedResultItem `json:"result"`
	Result      interface{} `json:"result"`
	Error       string      `json:"error"`
	Logs        []string    `json:"logs"`
	CapacityMap interface{} `json:"capacity_map"`
}

type ReservedResourcesArgs

type ReservedResourcesArgs struct {
	Name   string
	Remove string
}

type ReservedResourcesResult

type ReservedResourcesResult struct {
	Resources interface{} `json:"resources"`
}

type ResultResource

type ResultResource struct {
	Free     float64 `json:"free"`
	Reserved float64 `json:"reserverd"`
	Total    float64 `json:"total"`
}

func NewResultResource

func NewResultResource(f, r, t float64) *ResultResource

func NewResultResourceInt64

func NewResultResourceInt64(f, r, t int64) *ResultResource

func NewResultResourceString

func NewResultResourceString(free, reserverd, total string) (*ResultResource, error)

type SchedBackupResultItem

type SchedBackupResultItem struct {
	MasterID string `json:"master_id"`
	SlaveID  string `json:"slave_id"`
}

type SchedErrItem

type SchedErrItem struct {
	Error string `json:"error"`
}

type SchedForecastResult

type SchedForecastResult struct {
	CanCreate          bool                     `json:"can_create"`
	Candidates         []*api.CandidateResource `json:"candidates"`
	ReqCount           int64                    `json:"req_count"`
	AllowCount         int64                    `json:"allow_count"`
	NotAllowReasons    []string                 `json:"not_allow_reasons"`
	FilteredCandidates []FilteredCandidate      `json:"filtered_candidates"`
}

type SchedInfo

type SchedInfo struct {
	*api.ScheduleInput

	Tag                string   `json:"tag"`
	Type               string   `json:"type"`
	IsContainer        bool     `json:"is_container"`
	PreferCandidates   []string `json:"candidates"`
	RequiredCandidates int      `json:"required_candidates"`

	IgnoreFilters         map[string]bool `json:"ignore_filters"`
	IsSuggestion          bool            `json:"suggestion"`
	ShowSuggestionDetails bool            `json:"suggestion_details"`
	Raw                   string

	InstanceGroupsDetail map[string]*models.SGroup

	UserCred mcclient.TokenCredential
}

func FetchSchedInfo

func FetchSchedInfo(req *http.Request) (*SchedInfo, error)

func NewSchedInfo

func NewSchedInfo(input *api.ScheduleInput) *SchedInfo

func (*SchedInfo) AllDiskBackendSize

func (d *SchedInfo) AllDiskBackendSize() map[string]int64

func (*SchedInfo) GetCandidateHostTypes

func (d *SchedInfo) GetCandidateHostTypes() []string

func (*SchedInfo) SkipDirtyMarkHost

func (d *SchedInfo) SkipDirtyMarkHost() bool

type SchedNormalResultItem

type SchedNormalResultItem struct {
	ID   string                 `json:"id"`
	Name string                 `json:"name"`
	Data map[string]interface{} `json:"data"`
}

type SchedResult

type SchedResult struct {
	Items []SchedResultItem `json:"scheduler"`
}

type SchedResultItem

type SchedResultItem interface{}

type SchedSuccItem

type SchedSuccItem struct {
	Candidate interface{} `json:"candidate"`
}

type SchedTestResult

type SchedTestResult struct {
	Data   interface{} `json:"data"`
	Total  int64       `json:"total"`
	Limit  int64       `json:"limit"`
	Offset int64       `json:"offset"`
}

Jump to

Keyboard shortcuts

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