You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2018/05/21 07:24:45 UTC

[cloudstack] branch 4.11 updated: managed-storage: Handle Ceph (#2655)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch 4.11
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.11 by this push:
     new 7e6fddb  managed-storage: Handle Ceph (#2655)
7e6fddb is described below

commit 7e6fddb7ab04e16023fa263839067d92576ee948
Author: Mike Tutkowski <mi...@netapp.com>
AuthorDate: Mon May 21 01:24:42 2018 -0600

    managed-storage: Handle Ceph (#2655)
    
    In 4.11.0, I added the ability to online migrate volumes from NFS to managed storage. This actually works for Ceph to managed storage in a private 4.8 branch, as well. I thought I had brought along all of the necessary code from that private 4.8 branch to make Ceph to managed storage functional in 4.11.0, but missed one piece (which is fixed by this PR).
---
 .../wrapper/LibvirtMigrateCommandWrapper.java      | 27 +++++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
index 67ec1b7..067e77d 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
@@ -45,6 +45,7 @@ import javax.xml.transform.stream.StreamResult;
 
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.libvirt.Connect;
 import org.libvirt.Domain;
@@ -332,9 +333,9 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
                     if ("disk".equals(deviceChildNode.getNodeName())) {
                         Node diskNode = deviceChildNode;
 
-                        String sourceFileDevText = getSourceFileDevText(diskNode);
+                        String sourceText = getSourceText(diskNode);
 
-                        String path = getPathFromSourceFileDevText(migrateStorage.keySet(), sourceFileDevText);
+                        String path = getPathFromSourceText(migrateStorage.keySet(), sourceText);
 
                         if (path != null) {
                             MigrateCommand.MigrateDiskInfo migrateDiskInfo = migrateStorage.remove(path);
@@ -383,10 +384,10 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
         return getXml(doc);
     }
 
-    private String getPathFromSourceFileDevText(Set<String> paths, String sourceFileDevText) {
-        if (paths != null && sourceFileDevText != null) {
+    private String getPathFromSourceText(Set<String> paths, String sourceText) {
+        if (paths != null && !StringUtils.isBlank(sourceText)) {
             for (String path : paths) {
-                if (sourceFileDevText.contains(path)) {
+                if (sourceText.contains(path)) {
                     return path;
                 }
             }
@@ -395,7 +396,7 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
         return null;
     }
 
-    private String getSourceFileDevText(Node diskNode) {
+    private String getSourceText(Node diskNode) {
         NodeList diskChildNodes = diskNode.getChildNodes();
 
         for (int i = 0; i < diskChildNodes.getLength(); i++) {
@@ -415,6 +416,20 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
                 if (diskNodeAttribute != null) {
                     return diskNodeAttribute.getTextContent();
                 }
+
+                diskNodeAttribute = diskNodeAttributes.getNamedItem("protocol");
+
+                if (diskNodeAttribute != null) {
+                    String textContent = diskNodeAttribute.getTextContent();
+
+                    if ("rbd".equalsIgnoreCase(textContent)) {
+                        diskNodeAttribute = diskNodeAttributes.getNamedItem("name");
+
+                        if (diskNodeAttribute != null) {
+                            return diskNodeAttribute.getTextContent();
+                        }
+                    }
+                }
             }
         }
 

-- 
To stop receiving notification emails like this one, please contact
rohit@apache.org.