mirror of https://github.com/apache/cloudstack.git
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).
This commit is contained in:
parent
06f7e495dc
commit
7e6fddb7ab
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue