Merge pull request #895 in YUNIONIO/onecloud from ~LIZEXI/onecloud:feature/lzx-sched-filter-zone-status to release/2.5.0

* commit 'c0102d0a32bfe2c0307c3cf4d71e0aa9eadfbe66':
  scheduler: host 的 zone status 为 enable 时才能调度
This commit is contained in:
邱剑
2019-01-05 20:14:09 +08:00
3 changed files with 8 additions and 4 deletions
@@ -50,6 +50,10 @@ func (p *StatusPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core
h.Exclude2("enable_status", curEnableStatus, true)
}
if hc.Zone.Status != ExpectedEnableStatus {
h.Exclude2("zone_status", hc.Zone.Status, ExpectedEnableStatus)
}
if hc.Cloudprovider != nil {
if hc.Cloudprovider.Status != models.CLOUD_PROVIDER_CONNECTED {
h.Exclude2("cloud_provider_status", hc.Cloudprovider.Status, models.CLOUD_PROVIDER_CONNECTED)
+3 -4
View File
@@ -40,7 +40,7 @@ type baseHostDesc struct {
NodeCount int64 `json:"node_count"`
Tenants map[string]int64 `json:"tenants"`
ZoneID string `json:"zone_id"`
Zone string `json:"zone"`
Zone *models.Zone `json:"zone"`
PoolID string `json:"pool_id"`
ClusterID string `json:"cluster_id"`
Aggregates []*models.Aggregate `json:"aggregates"`
@@ -110,7 +110,7 @@ func (b baseHostDesc) GetSchedDesc() *jsonutils.JSONDict {
desc.Add(jsonutils.NewInt(b.MemSize), "mem_size")
desc.Add(jsonutils.NewString(b.HostType), "host_type")
desc.Add(jsonutils.NewString(b.ZoneID), "zone_id")
desc.Add(jsonutils.NewString(b.Zone), "zone")
desc.Add(jsonutils.NewString(b.Zone.Name), "zone")
desc.Add(jsonutils.NewString(b.ResourceType), "resource_type")
if b.Cloudprovider != nil {
@@ -146,8 +146,7 @@ func (b *baseHostDesc) fillZone(host *models.Host) error {
if err != nil {
return err
}
b.ZoneID = zone.ID
b.Zone = zone.Name
b.Zone = zone
return nil
}
+1
View File
@@ -6,6 +6,7 @@ import (
type Zone struct {
StandaloneModel
Status string `json:"status" gorm:"column:status;not null"`
Location string `gorm:"column:location"`
ManagerUri string `gorm:"column:manager_uri"`
CloudregionId string `gorm:"column:cloudregion_id"`