Skip to content

Commit 7e6fddb

Browse files
Mike Tutkowskiyadvr
authored andcommitted
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).
1 parent 06f7e49 commit 7e6fddb

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
import org.apache.commons.collections.MapUtils;
4747
import org.apache.commons.io.IOUtils;
48+
import org.apache.commons.lang.StringUtils;
4849
import org.apache.log4j.Logger;
4950
import org.libvirt.Connect;
5051
import org.libvirt.Domain;
@@ -332,9 +333,9 @@ private String replaceStorage(String xmlDesc, Map<String, MigrateCommand.Migrate
332333
if ("disk".equals(deviceChildNode.getNodeName())) {
333334
Node diskNode = deviceChildNode;
334335

335-
String sourceFileDevText = getSourceFileDevText(diskNode);
336+
String sourceText = getSourceText(diskNode);
336337

337-
String path = getPathFromSourceFileDevText(migrateStorage.keySet(), sourceFileDevText);
338+
String path = getPathFromSourceText(migrateStorage.keySet(), sourceText);
338339

339340
if (path != null) {
340341
MigrateCommand.MigrateDiskInfo migrateDiskInfo = migrateStorage.remove(path);
@@ -383,10 +384,10 @@ private String replaceStorage(String xmlDesc, Map<String, MigrateCommand.Migrate
383384
return getXml(doc);
384385
}
385386

386-
private String getPathFromSourceFileDevText(Set<String> paths, String sourceFileDevText) {
387-
if (paths != null && sourceFileDevText != null) {
387+
private String getPathFromSourceText(Set<String> paths, String sourceText) {
388+
if (paths != null && !StringUtils.isBlank(sourceText)) {
388389
for (String path : paths) {
389-
if (sourceFileDevText.contains(path)) {
390+
if (sourceText.contains(path)) {
390391
return path;
391392
}
392393
}
@@ -395,7 +396,7 @@ private String getPathFromSourceFileDevText(Set<String> paths, String sourceFile
395396
return null;
396397
}
397398

398-
private String getSourceFileDevText(Node diskNode) {
399+
private String getSourceText(Node diskNode) {
399400
NodeList diskChildNodes = diskNode.getChildNodes();
400401

401402
for (int i = 0; i < diskChildNodes.getLength(); i++) {
@@ -415,6 +416,20 @@ private String getSourceFileDevText(Node diskNode) {
415416
if (diskNodeAttribute != null) {
416417
return diskNodeAttribute.getTextContent();
417418
}
419+
420+
diskNodeAttribute = diskNodeAttributes.getNamedItem("protocol");
421+
422+
if (diskNodeAttribute != null) {
423+
String textContent = diskNodeAttribute.getTextContent();
424+
425+
if ("rbd".equalsIgnoreCase(textContent)) {
426+
diskNodeAttribute = diskNodeAttributes.getNamedItem("name");
427+
428+
if (diskNodeAttribute != null) {
429+
return diskNodeAttribute.getTextContent();
430+
}
431+
}
432+
}
418433
}
419434
}
420435

0 commit comments

Comments
 (0)