mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Automatic merge from release/2.1.0 -> release/2.2.0
* commit '7c3dd189ba31928e3cfbd4242baab562690d6442': rbd类型disk需要path路径
This commit is contained in:
@@ -526,21 +526,9 @@ func (self *SDisk) GetCloudprovider() *SCloudprovider {
|
||||
}
|
||||
|
||||
func (self *SDisk) GetPathAtHost(host *SHost) string {
|
||||
storage := self.GetStorage()
|
||||
if storage.StorageType == STORAGE_RBD {
|
||||
pool, _ := storage.StorageConf.GetString("pool")
|
||||
monHost, _ := storage.StorageConf.GetString("mon_host")
|
||||
key, _ := storage.StorageConf.GetString("key")
|
||||
for _, keyword := range []string{"@", ":", "="} {
|
||||
monHost = strings.Replace(monHost, keyword, fmt.Sprintf("\\%s", keyword), -1)
|
||||
key = strings.Replace(key, keyword, fmt.Sprintf("\\%s", keyword), -1)
|
||||
}
|
||||
return fmt.Sprintf("rbd:%s/%s:mon_host=%s:key=%s", pool, self.Id, monHost, key)
|
||||
} else if storage.StorageType == STORAGE_LOCAL || storage.StorageType == STORAGE_NAS {
|
||||
hostStorage := host.GetHoststorageOfId(self.StorageId)
|
||||
if hostStorage != nil {
|
||||
return path.Join(hostStorage.MountPoint, self.Id)
|
||||
}
|
||||
hostStorage := host.GetHoststorageOfId(self.StorageId)
|
||||
if hostStorage != nil {
|
||||
return path.Join(hostStorage.MountPoint, self.Id)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -136,7 +136,8 @@ func (self *SGuestdisk) GetJsonDescAtHost(host *SHost) jsonutils.JSONObject {
|
||||
desc.Add(jsonutils.NewString(storagecacheimg.Path), "image_path")
|
||||
}
|
||||
}
|
||||
if host.HostType == HOST_TYPE_HYPERVISOR && disk.IsLocal() {
|
||||
storage := disk.GetStorage()
|
||||
if host.HostType == HOST_TYPE_HYPERVISOR && disk.IsLocal() || (storage != nil && storage.StorageType == STORAGE_RBD) {
|
||||
desc.Add(jsonutils.NewString(disk.StorageId), "storage_id")
|
||||
localpath := disk.GetPathAtHost(host)
|
||||
if len(localpath) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user