mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
openstack:避免因disk没有设置volume_type而导致同步磁盘数据不全
This commit is contained in:
@@ -3,6 +3,7 @@ package openstack
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -106,7 +107,7 @@ func (disk *SDisk) GetMetadata() *jsonutils.JSONDict {
|
||||
return data
|
||||
}
|
||||
|
||||
func (region *SRegion) GetDisks(category string) ([]SDisk, error) {
|
||||
func (region *SRegion) GetDisks(category, volumeBackendName string) ([]SDisk, error) {
|
||||
_, resp, err := region.CinderList("/volumes/detail", "", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -117,7 +118,7 @@ func (region *SRegion) GetDisks(category string) ([]SDisk, error) {
|
||||
}
|
||||
result := []SDisk{}
|
||||
for _, disk := range disks {
|
||||
if len(category) == 0 || disk.VolumeType == category {
|
||||
if len(category) == 0 || disk.VolumeType == category || strings.HasSuffix(disk.Host, "#"+volumeBackendName) {
|
||||
result = append(result, disk)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,15 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
)
|
||||
|
||||
type SExtraSpecs struct {
|
||||
VolumeBackendName string
|
||||
}
|
||||
|
||||
type SStorage struct {
|
||||
zone *SZone
|
||||
Name string
|
||||
ID string
|
||||
zone *SZone
|
||||
Name string
|
||||
ExtraSpecs SExtraSpecs
|
||||
ID string
|
||||
}
|
||||
|
||||
func (storage *SStorage) GetMetadata() *jsonutils.JSONDict {
|
||||
@@ -42,7 +47,7 @@ func (storage *SStorage) GetIZone() cloudprovider.ICloudZone {
|
||||
}
|
||||
|
||||
func (storage *SStorage) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
|
||||
disks, err := storage.zone.region.GetDisks(storage.Name)
|
||||
disks, err := storage.zone.region.GetDisks(storage.Name, storage.ExtraSpecs.VolumeBackendName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user