fix attach able storage

This commit is contained in:
wanyaoqi
2019-06-12 13:52:00 +08:00
parent cb4b789d14
commit 32302b262d
2 changed files with 4 additions and 5 deletions
+1 -2
View File
@@ -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}
)
+3 -3
View File
@@ -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())