mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
fix attach able storage
This commit is contained in:
@@ -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}
|
||||
)
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user