From f7b16c592fe52154b61de41050a4f522511e2b8a Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Mon, 19 Oct 2020 12:05:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9Egoogle=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/apis/compute/storage_const.go | 1 + pkg/compute/guestdrivers/google.go | 7 +++++-- pkg/compute/hostdrivers/google.go | 2 +- pkg/multicloud/google/instance.go | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/apis/compute/storage_const.go b/pkg/apis/compute/storage_const.go index 527b763735..d9c4eeaa45 100644 --- a/pkg/apis/compute/storage_const.go +++ b/pkg/apis/compute/storage_const.go @@ -81,6 +81,7 @@ const ( STORAGE_GOOGLE_LOCAL_SSD = "local-ssd" //本地SSD暂存盘 (最多8个) STORAGE_GOOGLE_PD_STANDARD = "pd-standard" //标准永久性磁盘 STORAGE_GOOGLE_PD_SSD = "pd-ssd" //SSD永久性磁盘 + STORAGE_GOOGLE_PD_BALANCED = "pd-balanced" //平衡永久性磁盘 // ctyun storage type STORAGE_CTYUN_SSD = "SSD" // 超高IO云硬盘 diff --git a/pkg/compute/guestdrivers/google.go b/pkg/compute/guestdrivers/google.go index 652412d541..3cc28026ee 100644 --- a/pkg/compute/guestdrivers/google.go +++ b/pkg/compute/guestdrivers/google.go @@ -77,6 +77,7 @@ func (self *SGoogleGuestDriver) GetStorageTypes() []string { return []string{ api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD, + api.STORAGE_GOOGLE_PD_BALANCED, api.STORAGE_GOOGLE_LOCAL_SSD, } } @@ -113,7 +114,7 @@ func (self *SGoogleGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *m if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING}) { return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status) } - if !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD}) { + if !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD, api.STORAGE_GOOGLE_PD_BALANCED}) { return fmt.Errorf("Cannot resize %s disk", storage.StorageType) } return nil @@ -132,13 +133,15 @@ func (self *SGoogleGuestDriver) ValidateCreateData(ctx context.Context, userCred minGB := -1 maxGB := -1 switch disk.Backend { - case api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD: + case api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD, api.STORAGE_GOOGLE_PD_BALANCED: minGB = 10 maxGB = 65536 case api.STORAGE_GOOGLE_LOCAL_SSD: minGB = 375 maxGB = 375 localDisk++ + default: + return nil, httperrors.NewInputParameterError("Unknown google storage type %s", disk.Backend) } if i == 0 && disk.Backend == api.STORAGE_GOOGLE_LOCAL_SSD { return nil, httperrors.NewInputParameterError("System disk does not support %s disk", disk.Backend) diff --git a/pkg/compute/hostdrivers/google.go b/pkg/compute/hostdrivers/google.go index d85df35990..3d790eb2eb 100644 --- a/pkg/compute/hostdrivers/google.go +++ b/pkg/compute/hostdrivers/google.go @@ -48,7 +48,7 @@ func (self *SGoogleHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb minGB := 10 maxGB := -1 switch storage.StorageType { - case api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD: + case api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_PD_STANDARD, api.STORAGE_GOOGLE_PD_BALANCED: maxGB = 65536 default: return fmt.Errorf("Not support resize %s disk", storage.StorageType) diff --git a/pkg/multicloud/google/instance.go b/pkg/multicloud/google/instance.go index bd7162c929..388189f48c 100644 --- a/pkg/multicloud/google/instance.go +++ b/pkg/multicloud/google/instance.go @@ -529,7 +529,7 @@ func getDiskInfo(disk string) (cloudprovider.SDiskInfo, error) { result := cloudprovider.SDiskInfo{} diskInfo := strings.Split(disk, ":") for _, d := range diskInfo { - if utils.IsInStringArray(d, []string{api.STORAGE_GOOGLE_PD_STANDARD, api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_LOCAL_SSD}) { + if utils.IsInStringArray(d, []string{api.STORAGE_GOOGLE_PD_STANDARD, api.STORAGE_GOOGLE_PD_SSD, api.STORAGE_GOOGLE_LOCAL_SSD, api.STORAGE_GOOGLE_PD_BALANCED}) { result.StorageType = d } else if memSize, err := fileutils.GetSizeMb(d, 'M', 1024); err == nil { result.SizeGB = memSize >> 10