fix(region): openstack available zones

This commit is contained in:
Qu Xuan
2020-12-08 16:18:33 +08:00
parent 18c919399a
commit 9ddf207441
2 changed files with 15 additions and 2 deletions
+4
View File
@@ -21,6 +21,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudprovider"
@@ -191,6 +192,9 @@ func (vpc *SVpc) GetIWires() ([]cloudprovider.ICloudWire, error) {
}
iwire := []cloudprovider.ICloudWire{}
for i := range vpc.region.zones {
if !utils.IsInStringArray(vpc.region.zones[i].ZoneName, vpc.AvailabilityZones) {
continue
}
wire := &SWire{vpc: vpc, zone: &vpc.region.zones[i]}
iwire = append(iwire, wire)
}
+11 -2
View File
@@ -39,7 +39,10 @@ type HostState struct {
type SZone struct {
region *SRegion
ZoneName string
ZoneName string
ZoneState ZoneState
Hosts map[string]jsonutils.JSONObject
hosts []SHypervisor
}
@@ -65,7 +68,10 @@ func (zone *SZone) IsEmulated() bool {
}
func (zone *SZone) GetStatus() string {
return api.ZONE_ENABLE
if zone.ZoneState.Available {
return api.ZONE_ENABLE
}
return api.ZONE_DISABLE
}
func (zone *SZone) Refresh() error {
@@ -160,6 +166,9 @@ func (zone *SZone) fetchHosts() error {
if strings.Index(hypervisor, "vmware") != -1 {
continue
}
if _, ok := zone.Hosts[hypervisors[i].GetName()]; !ok {
continue
}
zone.hosts = append(zone.hosts, hypervisors[i])
}
return nil