Merge branch 'release/2.2.0' of ssh://git.yunion.io/~qiujian/onecloud into hotfix/qj-resolve-conflict-20181115-2.3.0

Conflicts:
	pkg/compute/hostdrivers/base.go
This commit is contained in:
Qiu Jian
2018-11-15 11:12:07 +08:00
4 changed files with 32 additions and 0 deletions
+8
View File
@@ -13,6 +13,7 @@ import (
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
)
type SAzureHostDriver struct {
@@ -28,6 +29,13 @@ func (self *SAzureHostDriver) GetHostType() string {
return models.HOST_TYPE_AZURE
}
func (self *SAzureHostDriver) ValidateUpdateDisk(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
if data.Contains("name") {
return nil, httperrors.NewInputParameterError("cannot support change azure disk name")
}
return data, nil
}
func (self *SAzureHostDriver) CheckAndSetCacheImage(ctx context.Context, host *models.SHost, storageCache *models.SStoragecache, task taskman.ITask) error {
params := task.GetParams()
imageId, err := params.GetString("image_id")
+4
View File
@@ -16,6 +16,10 @@ import (
type SBaseHostDriver struct {
}
func (self *SBaseHostDriver) ValidateUpdateDisk(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
return data, nil
}
func (self *SBaseHostDriver) RequestDeleteSnapshotsWithStorage(ctx context.Context, host *models.SHost, snapshot *models.SSnapshot, task taskman.ITask) error {
return fmt.Errorf("Not Implement")
}
+19
View File
@@ -235,6 +235,25 @@ func (self *SDisk) CustomizeCreate(ctx context.Context, userCred mcclient.TokenC
return self.SSharableVirtualResourceBase.CustomizeCreate(ctx, userCred, ownerProjId, query, data)
}
func (self *SDisk) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
storage := self.GetStorage()
if storage == nil {
return nil, httperrors.NewNotFoundError("failed to find storage for disk %s", self.Name)
}
host := storage.GetMasterHost()
if host == nil {
return nil, httperrors.NewNotFoundError("failed to find host for storage %s with disk %s", storage.Name, self.Name)
}
data, err := host.GetHostDriver().ValidateUpdateDisk(ctx, userCred, data)
if err != nil {
return nil, err
}
return self.SVirtualResourceBase.ValidateUpdateData(ctx, userCred, query, data)
}
func (manager *SDiskManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerProjId string, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
disk, err := data.Get("disk")
if err != nil {
+1
View File
@@ -13,6 +13,7 @@ import (
type IHostDriver interface {
GetHostType() string
CheckAndSetCacheImage(ctx context.Context, host *SHost, storagecache *SStoragecache, task taskman.ITask) error
ValidateUpdateDisk(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error)
RequestPrepareSaveDiskOnHost(ctx context.Context, host *SHost, disk *SDisk, imageId string, task taskman.ITask) error
RequestSaveUploadImageOnHost(ctx context.Context, host *SHost, disk *SDisk, imageId string, task taskman.ITask, data jsonutils.JSONObject) error
RequestAllocateDiskOnStorage(ctx context.Context, host *SHost, storage *SStorage, disk *SDisk, task taskman.ITask, content *jsonutils.JSONDict) error