From 32302b262d26f03386ac692e149127f25c60c392 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Wed, 12 Jun 2019 13:52:00 +0800 Subject: [PATCH] fix attach able storage --- pkg/apis/compute/storage_const.go | 3 +-- pkg/compute/hostdrivers/kvm.go | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/apis/compute/storage_const.go b/pkg/apis/compute/storage_const.go index 4842b7553b..4f7a247b4b 100644 --- a/pkg/apis/compute/storage_const.go +++ b/pkg/apis/compute/storage_const.go @@ -107,6 +107,5 @@ var ( SHARED_FILE_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS} // 目前来说只支持这些 - SHARED_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS, STORAGE_RBD} - ATTACHABLE_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS, STORAGE_RBD, STORAGE_LOCAL} + SHARED_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS, STORAGE_RBD} ) diff --git a/pkg/compute/hostdrivers/kvm.go b/pkg/compute/hostdrivers/kvm.go index 6edaf05a95..2adbbe3bb8 100644 --- a/pkg/compute/hostdrivers/kvm.go +++ b/pkg/compute/hostdrivers/kvm.go @@ -52,7 +52,7 @@ func (self *SKVMHostDriver) GetHypervisor() string { } func (self *SKVMHostDriver) ValidateAttachStorage(host *models.SHost, storage *models.SStorage, data *jsonutils.JSONDict) error { - if !utils.IsInStringArray(storage.StorageType, api.ATTACHABLE_STORAGE) { + if !utils.IsInStringArray(storage.StorageType, append([]string{api.STORAGE_LOCAL}, api.SHARED_STORAGE...)) { return httperrors.NewUnsupportOperationError("Unsupport attach %s storage for %s host", storage.StorageType, host.HostType) } if storage.StorageType == api.STORAGE_RBD { @@ -71,7 +71,7 @@ func (self *SKVMHostDriver) ValidateAttachStorage(host *models.SHost, storage *m func (self *SKVMHostDriver) RequestAttachStorage(ctx context.Context, hoststorage *models.SHoststorage, host *models.SHost, storage *models.SStorage, task taskman.ITask) error { taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { - if utils.IsInStringArray(storage.StorageType, api.ATTACHABLE_STORAGE) { + if utils.IsInStringArray(storage.StorageType, api.SHARED_STORAGE) { log.Infof("Attach SharedStorage[%s] on host %s ...", storage.Name, host.Name) url := fmt.Sprintf("%s/storages/attach", host.ManagerUri) headers := mcclient.GetTokenHeaders(task.GetUserCred()) @@ -99,7 +99,7 @@ func (self *SKVMHostDriver) RequestAttachStorage(ctx context.Context, hoststorag func (self *SKVMHostDriver) RequestDetachStorage(ctx context.Context, host *models.SHost, storage *models.SStorage, task taskman.ITask) error { taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { - if utils.IsInStringArray(storage.StorageType, api.ATTACHABLE_STORAGE) && host.HostStatus == api.HOST_ONLINE { + if utils.IsInStringArray(storage.StorageType, api.SHARED_STORAGE) && host.HostStatus == api.HOST_ONLINE { log.Infof("Detach SharedStorage[%s] on host %s ...", storage.Name, host.Name) url := fmt.Sprintf("%s/storages/detach", host.ManagerUri) headers := mcclient.GetTokenHeaders(task.GetUserCred())