mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
region: spec handler
This commit is contained in:
@@ -3,10 +3,10 @@ package baremetal
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
//"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/compute/baremetal"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/api"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/util/baremetal"
|
||||
)
|
||||
|
||||
type StoragePredicate struct {
|
||||
@@ -21,6 +21,27 @@ func (p *StoragePredicate) Clone() core.FitPredicate {
|
||||
return &StoragePredicate{}
|
||||
}
|
||||
|
||||
func toBaremetalDisks(disks []*api.Disk) []*baremetal.Disk {
|
||||
ret := make([]*baremetal.Disk, len(disks))
|
||||
for i, disk := range disks {
|
||||
ret[i] = &baremetal.Disk{
|
||||
Backend: disk.Backend,
|
||||
ImageID: disk.ImageID,
|
||||
Fs: disk.Fs,
|
||||
Os: disk.Os,
|
||||
OSDistribution: disk.OSDistribution,
|
||||
Format: disk.Format,
|
||||
MountPoint: disk.MountPoint,
|
||||
Driver: disk.Driver,
|
||||
Cache: disk.Cache,
|
||||
ImageDiskFormat: disk.ImageDiskFormat,
|
||||
Size: disk.Size,
|
||||
Storage: disk.Storage,
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (p *StoragePredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core.PredicateFailureReason, error) {
|
||||
h := predicates.NewPredicateHelper(p, u, c)
|
||||
schedData := u.SchedData()
|
||||
@@ -35,7 +56,7 @@ func (p *StoragePredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
candidate.Storages,
|
||||
)
|
||||
|
||||
if err == nil && baremetal.CheckDisksAllocable(layouts, schedData.Disks) {
|
||||
if err == nil && baremetal.CheckDisksAllocable(layouts, toBaremetalDisks(schedData.Disks)) {
|
||||
h.SetCapacity(int64(1))
|
||||
} else {
|
||||
h.SetCapacity(int64(0))
|
||||
|
||||
Reference in New Issue
Block a user