mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Automatic merge from release/2.6.0 -> master
* commit 'bf4159d0159123d6ce02a7711a91e8390a78e582': 修正:storage增加IsSysDiskStore属性,标示是否支持系统盘创建。阿里云cloud存储不支持系统盘创建
This commit is contained in:
@@ -123,6 +123,8 @@ type ICloudStorage interface {
|
||||
GetIDiskById(idStr string) (ICloudDisk, error)
|
||||
|
||||
GetMountPoint() string
|
||||
|
||||
IsSysDiskStore() bool
|
||||
}
|
||||
|
||||
type ICloudHost interface {
|
||||
|
||||
@@ -14,6 +14,7 @@ type SCapabilities struct {
|
||||
Hypervisors []string `json:",allowempty"`
|
||||
ResourceTypes []string `json:",allowempty"`
|
||||
StorageTypes []string `json:",allowempty"`
|
||||
DataStorageTypes []string `json:",allowempty"`
|
||||
GPUModels []string `json:",allowempty"`
|
||||
MinNicCount int
|
||||
MaxNicCount int
|
||||
@@ -28,7 +29,8 @@ func GetCapabilities(ctx context.Context, userCred mcclient.TokenCredential, que
|
||||
capa := SCapabilities{}
|
||||
capa.Hypervisors = getHypervisors(zone)
|
||||
capa.ResourceTypes = getResourceTypes(zone)
|
||||
capa.StorageTypes = getStorageTypes(zone)
|
||||
capa.StorageTypes = getStorageTypes(zone, true)
|
||||
capa.DataStorageTypes = getStorageTypes(zone, false)
|
||||
capa.GPUModels = getGPUs(zone)
|
||||
capa.SchedPolicySupport = isSchedPolicySupported(zone)
|
||||
capa.MinNicCount = getMinNicCount(zone)
|
||||
@@ -97,7 +99,7 @@ func getResourceTypes(zone *SZone) []string {
|
||||
return resourceTypes
|
||||
}
|
||||
|
||||
func getStorageTypes(zone *SZone) []string {
|
||||
func getStorageTypes(zone *SZone, isSysDisk bool) []string {
|
||||
storages := StorageManager.Query().SubQuery()
|
||||
hostStorages := HoststorageManager.Query().SubQuery()
|
||||
hosts := HostManager.Query().SubQuery()
|
||||
@@ -121,6 +123,9 @@ func getStorageTypes(zone *SZone) []string {
|
||||
q = q.Filter(sqlchemy.IsNotNull(storages.Field("medium_type")))
|
||||
q = q.Filter(sqlchemy.In(storages.Field("status"), []string{STORAGE_ENABLED, STORAGE_ONLINE}))
|
||||
q = q.Filter(sqlchemy.IsTrue(storages.Field("enabled")))
|
||||
if isSysDisk {
|
||||
q = q.Filter(sqlchemy.IsTrue(storages.Field("is_sys_disk_store")))
|
||||
}
|
||||
q = q.Distinct()
|
||||
rows, err := q.Rows()
|
||||
if err != nil {
|
||||
|
||||
@@ -129,6 +129,9 @@ type SStorage struct {
|
||||
|
||||
Enabled bool `nullable:"false" default:"true" list:"user" create:"optional"`
|
||||
Status string `width:"36" charset:"ascii" nullable:"false" default:"offline" list:"user" create:"optional"`
|
||||
|
||||
// indicating whether system disk can be allocated in this storage
|
||||
IsSysDiskStore bool `nullable:"false" default:"true" list:"user" create:"optional" update:"admin"`
|
||||
}
|
||||
|
||||
func (manager *SStorageManager) GetContextManager() []db.IModelManager {
|
||||
@@ -741,6 +744,8 @@ func (self *SStorage) syncWithCloudStorage(extStorage cloudprovider.ICloudStorag
|
||||
self.IsEmulated = extStorage.IsEmulated()
|
||||
self.ManagerId = extStorage.GetManagerId()
|
||||
|
||||
self.IsSysDiskStore = extStorage.IsSysDiskStore()
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -768,6 +773,8 @@ func (manager *SStorageManager) newFromCloudStorage(extStorage cloudprovider.ICl
|
||||
storage.IsEmulated = extStorage.IsEmulated()
|
||||
storage.ManagerId = extStorage.GetManagerId()
|
||||
|
||||
storage.IsSysDiskStore = extStorage.IsSysDiskStore()
|
||||
|
||||
err := manager.TableSpec().Insert(&storage)
|
||||
if err != nil {
|
||||
log.Errorf("newFromCloudStorage fail %s", err)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
@@ -131,3 +132,10 @@ func (self *SStorage) GetIDiskById(idStr string) (cloudprovider.ICloudDisk, erro
|
||||
func (self *SStorage) GetMountPoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SStorage) IsSysDiskStore() bool {
|
||||
if utils.IsInStringArray(self.storageType, self.zone.getSysDiskCategories()) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
+13
-2
@@ -152,9 +152,13 @@ func (self *SZone) GetIRegion() cloudprovider.ICloudRegion {
|
||||
}
|
||||
|
||||
func (self *SZone) fetchStorages() error {
|
||||
self.istorages = make([]cloudprovider.ICloudStorage, len(self.AvailableDiskCategories.DiskCategories))
|
||||
categories := self.AvailableDiskCategories.DiskCategories
|
||||
// if len(self.AvailableResources.ResourcesInfo) > 0 {
|
||||
// categories = self.AvailableResources.ResourcesInfo[0].SystemDiskCategories.SupportedSystemDiskCategory
|
||||
// }
|
||||
self.istorages = make([]cloudprovider.ICloudStorage, len(categories))
|
||||
|
||||
for i, sc := range self.AvailableDiskCategories.DiskCategories {
|
||||
for i, sc := range categories {
|
||||
storage := SStorage{zone: self, storageType: sc}
|
||||
self.istorages[i] = &storage
|
||||
}
|
||||
@@ -236,3 +240,10 @@ func (self *SZone) getNetworkById(vswitchId string) *SVSwitch {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SZone) getSysDiskCategories() []string {
|
||||
if len(self.AvailableResources.ResourcesInfo) > 0 {
|
||||
return self.AvailableResources.ResourcesInfo[0].SystemDiskCategories.SupportedSystemDiskCategory
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -128,3 +128,7 @@ func (self *SStorage) GetIDiskById(idStr string) (cloudprovider.ICloudDisk, erro
|
||||
func (self *SStorage) GetMountPoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SStorage) IsSysDiskStore() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -130,3 +130,7 @@ func (self *SClassicStorage) Refresh() error {
|
||||
func (self *SClassicStorage) GetMountPoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SClassicStorage) IsSysDiskStore() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -164,3 +164,7 @@ func (self *SStorage) Refresh() error {
|
||||
func (self *SStorage) GetMountPoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SStorage) IsSysDiskStore() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -671,3 +671,7 @@ func (self *SDatastore) RemoveDir(ctx context.Context, remotePath string) error
|
||||
|
||||
return dnm.DeleteDirectory(ctx, dcObj, remotePath)
|
||||
}
|
||||
|
||||
func (self *SDatastore) IsSysDiskStore() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -131,3 +131,7 @@ func (self *SStorage) GetIDiskById(idStr string) (cloudprovider.ICloudDisk, erro
|
||||
func (self *SStorage) GetMountPoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SStorage) IsSysDiskStore() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -109,3 +109,7 @@ func (storage *SStorage) GetIDiskById(idStr string) (cloudprovider.ICloudDisk, e
|
||||
func (storage *SStorage) GetMountPoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (storage *SStorage) IsSysDiskStore() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -101,3 +101,7 @@ func (self *SLocalStorage) GetIDiskById(idStr string) (cloudprovider.ICloudDisk,
|
||||
func (self *SLocalStorage) GetMountPoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SLocalStorage) IsSysDiskStore() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -134,3 +134,7 @@ func (self *SStorage) GetIDiskById(idStr string) (cloudprovider.ICloudDisk, erro
|
||||
func (self *SStorage) GetMountPoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SStorage) IsSysDiskStore() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user