mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): openstack available zones
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user