package hostdrivers
import (
"context"
"fmt"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
)
type SJDcloudHostDriver struct {
SManagedVirtualizationHostDriver
}
func init() {
driver := SJDcloudHostDriver{}
models.RegisterHostDriver(&driver)
}
func (self *SJDcloudHostDriver) GetHostType() string {
return api.HOST_TYPE_JDCLOUD
}
func (self *SJDcloudHostDriver) GetHypervisor() string {
return api.HYPERVISOR_JDCLOUD
}
func (self *SJDcloudHostDriver) GetProvider() string {
return api.CLOUD_PROVIDER_JDCLOUD
}
func (self *SJDcloudHostDriver) ValidateResetDisk(ctx context.Context, userCred mcclient.TokenCredential, disk *models.SDisk, snapshot *models.SSnapshot, guests []models.SGuest, input *api.DiskResetInput) (*api.DiskResetInput, error) {
return nil, httperrors.NewNotSupportedError("not supported resize disk")
}
func (self *SJDcloudHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb int) error {
switch storage.StorageType {
case api.STORAGE_JDCLOUD_GP1, api.STORAGE_JDCLOUD_IO1, api.STORAGE_JDCLOUD_STD:
if sizeGb < 20 || sizeGb > 16000 {
return fmt.Errorf("The %s disk size must be in the range of 20G ~ 16000GB", storage.StorageType)
}
default:
return fmt.Errorf("Not support create %s disk", storage.StorageType)
}
return nil
}