mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-6122: Map rbd image on host before attaching to Vm
This commit is contained in:
parent
2dc1c7bec8
commit
fe7b753b03
|
|
@ -5458,4 +5458,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
|
||||
}
|
||||
|
||||
public HypervisorType getHypervisorType(){
|
||||
return _hypervisorType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import java.util.UUID;
|
|||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libvirt.Connect;
|
||||
|
|
@ -955,8 +956,23 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
} else {
|
||||
diskdef = new DiskDef();
|
||||
if (attachingPool.getType() == StoragePoolType.RBD) {
|
||||
diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(), attachingPool.getSourcePort(), attachingPool.getAuthUserName(),
|
||||
attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD, DiskDef.diskFmtType.RAW);
|
||||
if(resource.getHypervisorType() == Hypervisor.HypervisorType.LXC){
|
||||
// For LXC, map image to host and then attach to Vm
|
||||
String mapRbd = Script.runSimpleBashScript("rbd map " + attachingDisk.getPath() + " --id "+attachingPool.getAuthUserName());
|
||||
//Split pool and image details from disk path
|
||||
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);
|
||||
diskdef.defBlockBasedDisk(device, devId, DiskDef.diskBus.VIRTIO);
|
||||
} else {
|
||||
throw new InternalErrorException("Error while mapping disk "+attachingDisk.getPath()+" on host");
|
||||
}
|
||||
} else {
|
||||
diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(), attachingPool.getSourcePort(), attachingPool.getAuthUserName(),
|
||||
attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD, DiskDef.diskFmtType.RAW);
|
||||
}
|
||||
} else if (attachingPool.getType() == StoragePoolType.Gluster) {
|
||||
String mountpoint = attachingPool.getLocalPath();
|
||||
String path = attachingDisk.getPath();
|
||||
|
|
|
|||
Loading…
Reference in New Issue