protected VDI mount(Connection conn, String vmName, DiskTO volume) throws XmlRpcException, XenAPIException {
DataTO data = volume.getData();
Volume.Type type = volume.getType();
if (type == Volume.Type.ISO) {
TemplateObjectTO iso = (TemplateObjectTO)data;
DataStoreTO store = iso.getDataStore();
if (store == null) {
//It's a fake iso
return null;
}
//corer case, xenserver pv driver iso
String templateName = iso.getName();
if (templateName.startsWith("xs-tools")) {
try {
Set<VDI> vdis = VDI.getByNameLabel(conn, templateName);
if (vdis.isEmpty()) {
throw new CloudRuntimeException("Could not find ISO with URL: " + templateName);
}
return vdis.iterator().next();
} catch (XenAPIException e) {
throw new CloudRuntimeException("Unable to get pv iso: " + templateName + " due to " + e.toString());
} catch (Exception e) {
throw new CloudRuntimeException("Unable to get pv iso: " + templateName + " due to " + e.toString());
}
}
if (!(store instanceof NfsTO)) {
throw new CloudRuntimeException("only support mount iso on nfs");
}
NfsTO nfsStore = (NfsTO)store;
String isoPath = nfsStore.getUrl() + File.separator + iso.getPath();
int index = isoPath.lastIndexOf("/");
String mountpoint = isoPath.substring(0, index);
URI uri;
try {