Set mapped device path while detaching rbd disk

This commit is contained in:
Kishan Kavala 2014-07-22 17:50:16 +05:30 committed by Kishan Kavala
parent 4bf321bd03
commit 7d3f381d94
3 changed files with 20 additions and 1 deletions

View File

@ -108,7 +108,9 @@ public class LibvirtDomainXMLParser {
def.defBlockBasedDisk(diskDev, diskLabel,
DiskDef.diskBus.valueOf(bus.toUpperCase()));
}
def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode.toUpperCase()));
if (diskCacheMode != null) {
def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode.toUpperCase()));
}
}
NodeList iotune = disk.getElementsByTagName("iotune");

View File

@ -91,4 +91,9 @@ public class KVMPhysicalDisk {
public KVMStoragePool getPool() {
return this.pool;
}
public void setPath(String path) {
this.path = path;
}
}

View File

@ -941,6 +941,18 @@ public class KVMStorageProcessor implements StorageProcessor {
parser.parseDomainXML(xml);
disks = parser.getDisks();
if (attachingPool.getType() == StoragePoolType.RBD) {
if (resource.getHypervisorType() == Hypervisor.HypervisorType.LXC) {
String[] splitPoolImage = attachingDisk.getPath().split("/");
//ToDo: rbd showmapped supports json and xml output. Use json/xml to get device
String device = Script.runSimpleBashScript("rbd showmapped | grep \""+splitPoolImage[0]+" "+splitPoolImage[1]+"\" | cut -d \" \" -f10");
if (device != null) {
s_logger.debug("RBD device on host is: "+device);
attachingDisk.setPath(device);
}
}
}
for (DiskDef disk : disks) {
String file = disk.getDiskPath();
if (file != null && file.equalsIgnoreCase(attachingDisk.getPath())) {