diff --git a/pkg/util/openstack/disk.go b/pkg/util/openstack/disk.go index ff1d2cb6ab..8c05b1ebf3 100644 --- a/pkg/util/openstack/disk.go +++ b/pkg/util/openstack/disk.go @@ -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) } } diff --git a/pkg/util/openstack/storage.go b/pkg/util/openstack/storage.go index a4f03fee3a..94ca80a480 100644 --- a/pkg/util/openstack/storage.go +++ b/pkg/util/openstack/storage.go @@ -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 }