Automatic merge from release/2.1.0 -> release/2.2.0

* commit '7c3dd189ba31928e3cfbd4242baab562690d6442':
  rbd类型disk需要path路径
This commit is contained in:
邱剑
2018-09-12 20:23:28 +08:00
2 changed files with 5 additions and 16 deletions
+3 -15
View File
@@ -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 ""
}
+2 -1
View File
@@ -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 {