Merge pull request #195 in YUNIONIO/onecloud from ~QUXUAN/onecloud:hotfix/qx-disk to release/2.0.0

* commit '2bd249be264fd828b09924ffd630c6717edb9ffa':
  rbd类型disk需要path路径
This commit is contained in:
邱剑
2018-09-12 20:23:27 +08:00
2 changed files with 5 additions and 16 deletions
+3 -15
View File
@@ -207,21 +207,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
@@ -115,7 +115,8 @@ func (self *SGuestdisk) GetJsonDescAtHost(host *SHost) jsonutils.JSONObject {
// if hostcachedimg is not None:
// desc['image_path'] = hostcachedimg.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 {