mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): cloudpods baremetal (#20133)
This commit is contained in:
@@ -44,7 +44,8 @@ func (p *CloudproviderSchedtagPredicate) Clone() core.FitPredicate {
|
||||
}
|
||||
|
||||
func (p *CloudproviderSchedtagPredicate) PreExecute(ctx context.Context, u *core.Unit, cs []core.Candidater) (bool, error) {
|
||||
if !u.GetHypervisorDriver().DoScheduleCloudproviderTagFilter() {
|
||||
driver := u.GetHypervisorDriver()
|
||||
if driver != nil && !driver.DoScheduleCloudproviderTagFilter() {
|
||||
return false, nil
|
||||
}
|
||||
return p.ServerBaseSchedtagPredicate.PreExecute(ctx, u, cs)
|
||||
|
||||
@@ -129,7 +129,11 @@ func (p *DiskSchedtagPredicate) IsResourceFitInput(ctx context.Context, u *core.
|
||||
}
|
||||
}
|
||||
}
|
||||
storageTypes := p.GetHypervisorDriver().GetStorageTypes()
|
||||
storageTypes := []string{}
|
||||
driver := p.GetHypervisorDriver()
|
||||
if driver != nil {
|
||||
storageTypes = driver.GetStorageTypes()
|
||||
}
|
||||
if len(storageTypes) != 0 && !utils.IsInStringArray(storage.StorageType, storageTypes) {
|
||||
return &FailReason{
|
||||
fmt.Sprintf("Storage %s storage type %s not in %v", storage.Name, storage.StorageType, storageTypes),
|
||||
@@ -148,7 +152,7 @@ func (p *DiskSchedtagPredicate) IsResourceFitInput(ctx context.Context, u *core.
|
||||
}
|
||||
}
|
||||
|
||||
if u.GetHypervisorDriver().DoScheduleStorageFilter() {
|
||||
if driver != nil && driver.DoScheduleStorageFilter() {
|
||||
// free capacity check
|
||||
isMigrate := len(u.SchedData().HostId) > 0
|
||||
if !isMigrate || !utils.IsInStringArray(storage.StorageType, computeapi.SHARED_STORAGE) {
|
||||
|
||||
@@ -37,7 +37,8 @@ func (f *CPUPredicate) Clone() core.FitPredicate {
|
||||
}
|
||||
|
||||
func (f *CPUPredicate) PreExecute(ctx context.Context, u *core.Unit, cs []core.Candidater) (bool, error) {
|
||||
if !u.GetHypervisorDriver().DoScheduleCPUFilter() {
|
||||
driver := u.GetHypervisorDriver()
|
||||
if driver != nil && !driver.DoScheduleCPUFilter() {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func (f *ImagePredicate) PreExecute(ctx context.Context, u *core.Unit, cs []core
|
||||
if len(imageId) == 0 || u.SchedData().PreferZone != "" {
|
||||
return false, nil
|
||||
}
|
||||
if !utils.IsInStringArray(u.SchedData().Hypervisor, compute.PUBLIC_CLOUD_HYPERVISORS) && !utils.IsInStringArray(u.SchedData().Hypervisor, compute.PRIVATE_CLOUD_HYPERVISORS) {
|
||||
if !utils.IsInStringArray(u.SchedData().Provider, compute.PUBLIC_CLOUD_PROVIDERS) && !utils.IsInStringArray(u.SchedData().Provider, compute.PRIVATE_CLOUD_PROVIDERS) {
|
||||
return false, nil
|
||||
}
|
||||
obj, err := models.CachedimageManager.FetchById(imageId)
|
||||
|
||||
@@ -37,7 +37,8 @@ func (p *MemoryPredicate) Clone() core.FitPredicate {
|
||||
}
|
||||
|
||||
func (p *MemoryPredicate) PreExecute(ctx context.Context, u *core.Unit, cs []core.Candidater) (bool, error) {
|
||||
if !u.GetHypervisorDriver().DoScheduleMemoryFilter() {
|
||||
driver := u.GetHypervisorDriver()
|
||||
if driver != nil && !driver.DoScheduleMemoryFilter() {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ func (p *StoragePredicate) Clone() core.FitPredicate {
|
||||
}
|
||||
|
||||
func (p *StoragePredicate) PreExecute(ctx context.Context, u *core.Unit, cs []core.Candidater) (bool, error) {
|
||||
if !u.GetHypervisorDriver().DoScheduleStorageFilter() {
|
||||
driver := u.GetHypervisorDriver()
|
||||
if driver != nil && !driver.DoScheduleStorageFilter() {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
|
||||
@@ -294,7 +294,11 @@ func IsNetworkAvailable(
|
||||
}
|
||||
|
||||
func (p *NetworkPredicate) GetNetworkTypes(u *core.Unit, specifyType string) []string {
|
||||
netTypes := p.GetHypervisorDriver(u).GetRandomNetworkTypes()
|
||||
netTypes := []string{}
|
||||
driver := p.GetHypervisorDriver(u)
|
||||
if driver != nil {
|
||||
netTypes = driver.GetRandomNetworkTypes()
|
||||
}
|
||||
if len(specifyType) > 0 {
|
||||
netTypes = []string{specifyType}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,11 @@ func (p *NetworkSchedtagPredicate) IsResourceFitInput(ctx context.Context, u *co
|
||||
}
|
||||
|
||||
func (p *NetworkSchedtagPredicate) GetNetworkTypes(specifyType string) []string {
|
||||
netTypes := p.GetHypervisorDriver().GetRandomNetworkTypes()
|
||||
netTypes := []string{}
|
||||
driver := p.GetHypervisorDriver()
|
||||
if driver != nil {
|
||||
netTypes = driver.GetRandomNetworkTypes()
|
||||
}
|
||||
if len(specifyType) > 0 {
|
||||
netTypes = []string{specifyType}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ func (b *BasePredicate) PreExecute(ctx context.Context, unit *core.Unit, candis
|
||||
}
|
||||
|
||||
func (b *BasePredicate) GetHypervisorDriver(u *core.Unit) models.IGuestDriver {
|
||||
return models.GetDriver(u.GetHypervisor())
|
||||
driver, _ := models.GetDriver(u.GetHypervisor(), u.SchedInfo.Provider)
|
||||
return driver
|
||||
}
|
||||
|
||||
type PredicateHelper struct {
|
||||
@@ -280,6 +281,7 @@ type BaseSchedtagPredicate struct {
|
||||
CandidateInputResources *CandidateInputResourcesMap
|
||||
|
||||
Hypervisor string
|
||||
Provider string
|
||||
}
|
||||
|
||||
func NewBaseSchedtagPredicate() *BaseSchedtagPredicate {
|
||||
@@ -344,7 +346,8 @@ func (w SchedtagResourceW) GetDynamicSchedDesc() *jsonutils.JSONDict {
|
||||
}
|
||||
|
||||
func (p *BaseSchedtagPredicate) GetHypervisorDriver() models.IGuestDriver {
|
||||
return models.GetDriver(p.Hypervisor)
|
||||
driver, _ := models.GetDriver(p.Hypervisor, p.Provider)
|
||||
return driver
|
||||
}
|
||||
|
||||
func (p *BaseSchedtagPredicate) check(input ISchedtagCustomer, candidate ISchedtagCandidateResource, u *core.Unit, c core.Candidater) (*PredicatedSchedtagResource, error) {
|
||||
|
||||
@@ -35,7 +35,8 @@ func (p *InstanceTypePredicate) Clone() core.FitPredicate {
|
||||
}
|
||||
|
||||
func (p *InstanceTypePredicate) PreExecute(ctx context.Context, u *core.Unit, cs []core.Candidater) (bool, error) {
|
||||
if u.SchedData().InstanceType == "" || !u.GetHypervisorDriver().DoScheduleSKUFilter() {
|
||||
driver := u.GetHypervisorDriver()
|
||||
if u.SchedData().InstanceType == "" || (driver == nil || !driver.DoScheduleSKUFilter()) {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
|
||||
Reference in New Issue
Block a user