candidate

package
v0.3.11-8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 37 Imported by: 9

Documentation

Index

Constants

View Source
const (
	CacheKind = "CandidateCache"

	HostCandidateCache      = "Hosts"
	BaremetalCandidateCache = "Baremetals"

	HostDescBuilder      = HostCandidateCache
	BaremetalDescBuilder = BaremetalCandidateCache
)

Variables

Functions

func FetchGuestByHostIDsQuery

func FetchGuestByHostIDsQuery(idsQuery sqlchemy.IQuery) ([]models.SGuest, error)

func FetchHostsByIds

func FetchHostsByIds(ids []string) ([]computemodels.SHost, error)

func FetchModelIds

func FetchModelIds(q *sqlchemy.SQuery) ([]string, error)

func GetHostIds

func GetHostIds(hosts []models.SHost) []string

func HostResidentTenantCount

func HostResidentTenantCount(id string) (map[string]int64, error)

func HostsResidentTenantStats

func HostsResidentTenantStats(hostIDs []string) (map[string]map[string]interface{}, error)

func IsGuestCreating

func IsGuestCreating(g models.SGuest) bool

func IsGuestPendingDelete

func IsGuestPendingDelete(g models.SGuest) bool

func IsGuestRunning

func IsGuestRunning(g models.SGuest) bool

func IsStorageBackendMediumMatch

func IsStorageBackendMediumMatch(s *api.CandidateStorage, backend string, mediumType string) bool

func NewCandidateManager

func NewCandidateManager(stopCh <-chan struct{}) *cache.GroupManager

func ToDict

func ToDict[O lockman.ILockedObject](objs []O) map[string]*O

Types

type BaremetalBuilder

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

func (*BaremetalBuilder) AllIDs

func (bb *BaremetalBuilder) AllIDs() ([]string, error)

func (*BaremetalBuilder) BuildOne

func (bb *BaremetalBuilder) BuildOne(hostObj *computemodels.SHost, netGetter *networkGetter, baseDesc *BaseHostDesc) (interface{}, error)

func (*BaremetalBuilder) Clone

func (bb *BaremetalBuilder) Clone() BuildActor

func (BaremetalBuilder) Do

func (b BaremetalBuilder) Do(ids []string) ([]interface{}, error)

func (*BaremetalBuilder) FetchHosts

func (bb *BaremetalBuilder) FetchHosts(ids []string) ([]computemodels.SHost, error)

func (*BaremetalBuilder) InitFuncs

func (bb *BaremetalBuilder) InitFuncs() []InitFunc

func (BaremetalBuilder) Type

func (b BaremetalBuilder) Type() string

type BaremetalDesc

type BaremetalDesc struct {
	*BaseHostDesc

	StorageInfo []*baremetal.BaremetalStorage `json:"storage_info"`
	StorageType string                        `json:"storage_type"`
	StorageSize int64                         `json:"storage_size"`
	ServerID    string                        `json:"server_id"`
}

func (*BaremetalDesc) AllocCpuNumaPin

func (bd *BaremetalDesc) AllocCpuNumaPin(vcpuCount, memSizeKB int) []scheduler.SCpuNumaPin

func (*BaremetalDesc) AllocCpuNumaPinWithNodeCount

func (bd *BaremetalDesc) AllocCpuNumaPinWithNodeCount(vcpuCount, memSizeKB, nodeCount int) []scheduler.SCpuNumaPin

func (*BaremetalDesc) FreeCPUCount

func (bd *BaremetalDesc) FreeCPUCount() int64

func (*BaremetalDesc) FreeMemSize

func (bd *BaremetalDesc) FreeMemSize() int64

func (*BaremetalDesc) FreeStorageSize

func (bd *BaremetalDesc) FreeStorageSize() int64

func (*BaremetalDesc) GetGuestCount

func (bd *BaremetalDesc) GetGuestCount() int64

func (*BaremetalDesc) Getter

func (*BaremetalDesc) IndexKey

func (bd *BaremetalDesc) IndexKey() string

func (*BaremetalDesc) String

func (bd *BaremetalDesc) String() string

func (*BaremetalDesc) Type

func (bd *BaremetalDesc) Type() int

type BaseHostDesc

type BaseHostDesc struct {
	*computemodels.SHost
	Region        *computemodels.SCloudregion              `json:"region"`
	Zone          *computemodels.SZone                     `json:"zone"`
	Cloudprovider *computemodels.SCloudprovider            `json:"cloudprovider"`
	Cloudaccount  *computemodels.SCloudaccount             `json:"cloudaccount"`
	Networks      []*api.CandidateNetwork                  `json:"networks"`
	NetInterfaces map[string][]computemodels.SNetInterface `json:"net_interfaces"`
	Storages      []*api.CandidateStorage                  `json:"storages"`

	IsolatedDevices []*core.IsolatedDeviceDesc `json:"isolated_devices"`

	Tenants map[string]int64 `json:"tenants"`

	InstanceGroups map[string]*api.CandidateGroup `json:"instance_groups"`
	IpmiInfo       types.SIPMIInfo                `json:"ipmi_info"`

	Nics []*types.SNic `json:"nics"`

	SharedDomains []string               `json:"shared_domains"`
	PendingUsage  map[string]interface{} `json:"pending_usage"`

	ClassMetadata map[string]string `json:"class_metadata"`
}

func (*BaseHostDesc) GetEnableStatus

func (h *BaseHostDesc) GetEnableStatus() string

func (*BaseHostDesc) GetFreePort

func (b *BaseHostDesc) GetFreePort(netId string) int

func (*BaseHostDesc) GetHostType

func (h *BaseHostDesc) GetHostType() string

func (*BaseHostDesc) GetHypervisorDriver

func (b *BaseHostDesc) GetHypervisorDriver() computemodels.IGuestDriver

func (*BaseHostDesc) GetIsolatedDevice

func (h *BaseHostDesc) GetIsolatedDevice(devID string) *core.IsolatedDeviceDesc

func (*BaseHostDesc) GetIsolatedDevices

func (h *BaseHostDesc) GetIsolatedDevices() []*core.IsolatedDeviceDesc

func (*BaseHostDesc) GetPendingUsage

func (b *BaseHostDesc) GetPendingUsage() *schedmodels.SPendingUsage

func (BaseHostDesc) GetResourceType

func (b BaseHostDesc) GetResourceType() string

func (BaseHostDesc) GetSchedDesc

func (b BaseHostDesc) GetSchedDesc() *jsonutils.JSONDict

func (*BaseHostDesc) UnusedGpuDevices

func (h *BaseHostDesc) UnusedGpuDevices() []*core.IsolatedDeviceDesc

func (*BaseHostDesc) UnusedIsolatedDevices

func (h *BaseHostDesc) UnusedIsolatedDevices() []*core.IsolatedDeviceDesc

func (*BaseHostDesc) UnusedIsolatedDevicesByModel

func (h *BaseHostDesc) UnusedIsolatedDevicesByModel(model string) []*core.IsolatedDeviceDesc

func (*BaseHostDesc) UnusedIsolatedDevicesByModelAndWire

func (h *BaseHostDesc) UnusedIsolatedDevicesByModelAndWire(model, wire string) []*core.IsolatedDeviceDesc

func (*BaseHostDesc) UnusedIsolatedDevicesByType

func (h *BaseHostDesc) UnusedIsolatedDevicesByType(devType string) []*core.IsolatedDeviceDesc

func (*BaseHostDesc) UnusedIsolatedDevicesByVendorModel

func (h *BaseHostDesc) UnusedIsolatedDevicesByVendorModel(vendorModel string) []*core.IsolatedDeviceDesc

type BuildActor

type BuildActor interface {
	Clone() BuildActor
	Type() string
	AllIDs() ([]string, error)
	//Do(ids []string, db DBGroupCacher, sync SyncGroupCacher) ([]interface{}, error)
	Do(ids []string) ([]interface{}, error)
}

type CPUDie

type CPUDie struct {
	LogicalProcessors cpuset.CPUSet
	// Core thread id maps
	CoreThreadIdMaps map[int]int

	CpuFree   SorttedCPUFree
	VcpuCount int
}

type CPUFree

type CPUFree struct {
	Cpu  int
	Free int
}

type DBGroupCacher

type DBGroupCacher interface {
	// contains filtered or unexported methods
}

type DescBuilder

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

func NewDescBuilder

func NewDescBuilder(act BuildActor) *DescBuilder

func (*DescBuilder) Build

func (d *DescBuilder) Build(ids []string) ([]interface{}, error)

type HostBuilder

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

func (*HostBuilder) AllIDs

func (b *HostBuilder) AllIDs() ([]string, error)

func (*HostBuilder) AllIDsQuery

func (b *HostBuilder) AllIDsQuery() sqlchemy.IQuery

func (*HostBuilder) BuildOne

func (b *HostBuilder) BuildOne(host *computemodels.SHost, getter *networkGetter, baseDesc *BaseHostDesc) (interface{}, error)

build host desc

func (*HostBuilder) Clone

func (b *HostBuilder) Clone() BuildActor

func (HostBuilder) Do

func (b HostBuilder) Do(ids []string) ([]interface{}, error)

func (*HostBuilder) FetchHosts

func (b *HostBuilder) FetchHosts(ids []string) ([]computemodels.SHost, error)

func (*HostBuilder) InitFuncs

func (b *HostBuilder) InitFuncs() []InitFunc

func (HostBuilder) Type

func (b HostBuilder) Type() string

type HostDesc

type HostDesc struct {
	*BaseHostDesc

	// cpu
	CPUCmtbound         float32  `json:"cpu_cmtbound"`
	CPUBoundCount       int64    `json:"cpu_bound_count"`
	CPULoad             *float64 `json:"cpu_load"`
	TotalCPUCount       int64    `json:"total_cpu_count"`
	RunningCPUCount     int64    `json:"running_cpu_count"`
	CreatingCPUCount    int64    `json:"creating_cpu_count"`
	RequiredCPUCount    int64    `json:"required_cpu_count"`
	FakeDeletedCPUCount int64    `json:"fake_deleted_cpu_count"`
	FreeCPUCount        int64    `json:"free_cpu_count"`

	// memory
	MemCmtbound        float32 `json:"mem_cmtbound"`
	TotalMemSize       int64   `json:"total_mem_size"`
	FreeMemSize        int64   `json:"free_mem_size"`
	RunningMemSize     int64   `json:"running_mem_size"`
	CreatingMemSize    int64   `json:"creating_mem_size"`
	RequiredMemSize    int64   `json:"required_mem_size"`
	FakeDeletedMemSize int64   `json:"fake_deleted_mem_size"`

	EnableCpuNumaAllocate bool       `json:"enable_cpu_numa_allocate"`
	HostTopo              *SHostTopo `json:"host_topo"`

	// storage
	StorageTypes []string `json:"storage_types"`

	// IO
	IOBoundCount int64    `json:"io_bound_count"`
	IOLoad       *float64 `json:"io_load"`

	// server
	GuestCount         int64 `json:"guest_count"`
	CreatingGuestCount int64 `json:"creating_guest_count"`
	RunningGuestCount  int64 `json:"running_guest_count"`

	//Groups                    *GroupCounts          `json:"groups"`
	Metadata                  map[string]string `json:"metadata"`
	IsMaintenance             bool              `json:"is_maintenance"`
	GuestReservedResource     *ReservedResource `json:"guest_reserved_resource"`
	GuestReservedResourceUsed *ReservedResource `json:"guest_reserved_used"`
}

func (*HostDesc) AllocCpuNumaPin

func (h *HostDesc) AllocCpuNumaPin(vcpuCount, memSizeKB int) []scheduler.SCpuNumaPin

func (*HostDesc) AllocCpuNumaPinWithNodeCount

func (h *HostDesc) AllocCpuNumaPinWithNodeCount(vcpuCount, memSizeKB, nodeCount int) []scheduler.SCpuNumaPin

func (*HostDesc) GetFreeCPUCount

func (h *HostDesc) GetFreeCPUCount(useRsvd bool) int64

func (*HostDesc) GetFreeCpuNuma

func (h *HostDesc) GetFreeCpuNuma() scheduler.SortedFreeNumaCpuMam

func (*HostDesc) GetFreeLocalStorageSize

func (h *HostDesc) GetFreeLocalStorageSize(useRsvd bool) int64

func (*HostDesc) GetFreeMemSize

func (h *HostDesc) GetFreeMemSize(useRsvd bool) int64

func (*HostDesc) GetFreePort

func (h *HostDesc) GetFreePort(netId string) int

func (*HostDesc) GetFreeStorageSizeOfType

func (h *HostDesc) GetFreeStorageSizeOfType(sType string, mediumType string, useRsvd bool, reqMaxSize int64) (int64, int64, error)

func (*HostDesc) GetGuestCount

func (h *HostDesc) GetGuestCount() int64

func (*HostDesc) GetReservedCPUCount

func (h *HostDesc) GetReservedCPUCount() int64

func (*HostDesc) GetReservedMemSize

func (h *HostDesc) GetReservedMemSize() int64

func (*HostDesc) GetReservedStorageSize

func (h *HostDesc) GetReservedStorageSize() int64

func (*HostDesc) GetTotalCPUCount

func (h *HostDesc) GetTotalCPUCount(useRsvd bool) int64

func (*HostDesc) GetTotalLocalStorageSize

func (h *HostDesc) GetTotalLocalStorageSize(useRsvd bool) int64

func (*HostDesc) GetTotalMemSize

func (h *HostDesc) GetTotalMemSize(useRsvd bool) int64

func (*HostDesc) Getter

func (*HostDesc) GuestReservedCPUCountFree

func (h *HostDesc) GuestReservedCPUCountFree() int64

func (*HostDesc) GuestReservedMemSizeFree

func (h *HostDesc) GuestReservedMemSizeFree() int64

func (*HostDesc) GuestReservedStorageSizeFree

func (h *HostDesc) GuestReservedStorageSizeFree() int64

func (*HostDesc) IndexKey

func (h *HostDesc) IndexKey() string

func (*HostDesc) String

func (h *HostDesc) String() string

func (*HostDesc) Type

func (h *HostDesc) Type() int

type IResourceBuilder

type IResourceBuilder interface {
	FetchHosts(ids []string) ([]computemodels.SHost, error)
	InitFuncs() []InitFunc
	BuildOne(host *computemodels.SHost, getter *networkGetter, desc *BaseHostDesc) (interface{}, error)
}

type InitFunc

type InitFunc func(ids []computemodels.SHost, errChan chan error)

type NumaNode

type NumaNode struct {
	CpuDies           SorttedCPUDie
	LogicalProcessors cpuset.CPUSet
	VcpuCount         int
	CpuCount          int

	NodeId                int
	NumaHugeMemSizeKB     int
	NumaHugeFreeMemSizeKB int
}

func NewNumaNode

func NewNumaNode(nodeId, hugepageSizeKb int, nodeHugepages []hostapi.HostNodeHugepageNr) *NumaNode

func (*NumaNode) AllocCpuset

func (n *NumaNode) AllocCpuset(vcpuCount int) []int

type ReservedResource

type ReservedResource struct {
	CPUCount    int64 `json:"cpu_count"`
	MemorySize  int64 `json:"memory_size"`
	StorageSize int64 `json:"storage_size"`
}

func NewGuestReservedResourceByBuilder

func NewGuestReservedResourceByBuilder(b *HostBuilder, host *computemodels.SHost) (ret *ReservedResource)

func NewGuestReservedResourceUsedByBuilder

func NewGuestReservedResourceUsedByBuilder(b *HostBuilder, host *computemodels.SHost, free *ReservedResource) (ret *ReservedResource, err error)

func NewReservedResource

func NewReservedResource(cpu, mem, storage int64) *ReservedResource

type ResidentTenant

type ResidentTenant struct {
	HostId      string `json:"host_id"`
	TenantId    string `json:"tenant_id"`
	TenantCount int64  `json:"tenant_count"`
}

func FetchHostsResidentTenants

func FetchHostsResidentTenants(hostIds []string) ([]ResidentTenant, error)

func (ResidentTenant) First

func (t ResidentTenant) First() string

func (ResidentTenant) Second

func (t ResidentTenant) Second() string

func (ResidentTenant) Third

func (t ResidentTenant) Third() interface{}

type SHostTopo

type SHostTopo struct {
	Nodes       []*NumaNode
	NumaEnabled bool
	CPUCmtbound int
}

func HostTopoSubPendingUsage

func HostTopoSubPendingUsage(topo *SHostTopo, cpuUsage map[int]int, numaMemUsage map[int]int) *SHostTopo

func (*SHostTopo) AllocCpuNumaNodes

func (h *SHostTopo) AllocCpuNumaNodes(vcpuCount, memSizeKB int) []scheduler.SCpuNumaPin

func (*SHostTopo) AllocCpuNumaNodesWithNodeCount

func (h *SHostTopo) AllocCpuNumaNodesWithNodeCount(vcpuCount, memSizeKB, nodeCount int) []scheduler.SCpuNumaPin

func (SHostTopo) Len

func (pq SHostTopo) Len() int

func (SHostTopo) Less

func (pq SHostTopo) Less(i, j int) bool

func (*SHostTopo) LoadCpuNumaPin

func (h *SHostTopo) LoadCpuNumaPin(guestsCpuNumaPin []scheduler.SCpuNumaPin)

func (*SHostTopo) Push

func (pq *SHostTopo) Push(item interface{})

func (SHostTopo) Swap

func (pq SHostTopo) Swap(i, j int)

type SorttedCPUDie

type SorttedCPUDie []*CPUDie

func (SorttedCPUDie) Len

func (pq SorttedCPUDie) Len() int

func (SorttedCPUDie) Less

func (pq SorttedCPUDie) Less(i, j int) bool

func (*SorttedCPUDie) LoadCpus

func (pq *SorttedCPUDie) LoadCpus(cpus []int, vcpuCount int)

func (*SorttedCPUDie) Pop

func (pq *SorttedCPUDie) Pop() interface{}

func (*SorttedCPUDie) Push

func (pq *SorttedCPUDie) Push(item interface{})

func (SorttedCPUDie) Swap

func (pq SorttedCPUDie) Swap(i, j int)

type SorttedCPUFree

type SorttedCPUFree []*CPUFree

func (SorttedCPUFree) Len

func (pq SorttedCPUFree) Len() int

func (SorttedCPUFree) Less

func (pq SorttedCPUFree) Less(i, j int) bool

func (*SorttedCPUFree) LoadCpu

func (pq *SorttedCPUFree) LoadCpu(cpuId int)

func (*SorttedCPUFree) Pop

func (pq *SorttedCPUFree) Pop() interface{}

func (*SorttedCPUFree) Push

func (pq *SorttedCPUFree) Push(item interface{})

func (SorttedCPUFree) Swap

func (pq SorttedCPUFree) Swap(i, j int)

type SyncGroupCacher

type SyncGroupCacher interface {
	// contains filtered or unexported methods
}

type UpdateStatus

type UpdateStatus struct {
	Id        string    `json:"id"`
	UpdatedAt time.Time `json:"updated_at"`
}

func FetchHostsUpdateStatus

func FetchHostsUpdateStatus(isBaremetal bool) ([]UpdateStatus, error)

func FetchModelUpdateStatus

func FetchModelUpdateStatus(man db.IStandaloneModelManager, cond sqlchemy.ICondition) ([]UpdateStatus, error)

type WaitGroupWrapper

type WaitGroupWrapper struct {
	gosync.WaitGroup
}

func (*WaitGroupWrapper) Wrap

func (w *WaitGroupWrapper) Wrap(cb func())

Jump to

Keyboard shortcuts

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