fix(region): incloudsphere resize disk

This commit is contained in:
ioito
2022-08-11 11:34:59 +08:00
parent 61263ce585
commit 45f05bdfa3
2 changed files with 34 additions and 1 deletions
+24
View File
@@ -16,6 +16,9 @@ package guestdrivers
import (
"context"
"fmt"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
@@ -80,6 +83,13 @@ func (self *SInCloudSphereGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbac
return keys
}
func (self *SInCloudSphereGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
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)
}
return nil
}
func (self *SInCloudSphereGuestDriver) GetDefaultSysDiskBackend() string {
return api.STORAGE_LOCAL
}
@@ -117,6 +127,20 @@ func (self *SInCloudSphereGuestDriver) GetDeployStatus() ([]string, error) {
return []string{api.VM_RUNNING}, nil
}
func (self *SInCloudSphereGuestDriver) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, input *api.ServerCreateInput) (*api.ServerCreateInput, error) {
input, err := self.SManagedVirtualizedGuestDriver.ValidateCreateData(ctx, userCred, input)
if err != nil {
return nil, err
}
if len(input.Networks) > 2 {
return nil, httperrors.NewInputParameterError("cannot support more than 1 nic")
}
if len(input.Eip) > 0 || input.EipBw > 0 {
return nil, httperrors.NewUnsupportOperationError("%s not support create virtual machine with eip", self.GetHypervisor())
}
return input, nil
}
func (self *SInCloudSphereGuestDriver) ValidateCreateEip(ctx context.Context, userCred mcclient.TokenCredential, input api.ServerCreateEipInput) error {
return httperrors.NewInputParameterError("%s not support create eip", self.GetHypervisor())
}
+10 -1
View File
@@ -15,8 +15,13 @@
package hostdrivers
import (
"context"
"yunion.io/x/jsonutils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/mcclient"
)
type SInCloudSphereHostDriver struct {
@@ -40,6 +45,10 @@ func (self *SInCloudSphereHostDriver) ValidateDiskSize(storage *models.SStorage,
return nil
}
func (driver *SInCloudSphereHostDriver) GetStoragecacheQuota(host *models.SHost) int {
func (self *SInCloudSphereHostDriver) GetStoragecacheQuota(host *models.SHost) int {
return 100
}
func (self *SInCloudSphereHostDriver) ValidateResetDisk(ctx context.Context, userCred mcclient.TokenCredential, disk *models.SDisk, snapshot *models.SSnapshot, guests []models.SGuest, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
return data, nil
}