int index = srcPath.lastIndexOf("/");
String srcDir = srcPath.substring(0, index);
String destDir = destObj.getPath();
SR srcSr = null;
SR destSr = null;
VDI destVdi = null;
boolean result = false;
try {
srcSr = createFileSr(conn, srcUri.getHost() + ":" + srcUri.getPath(), srcDir);
String destNfsPath = destUri.getHost() + ":" + destUri.getPath();
String localDir = "/var/cloud_mount/" + UUID.nameUUIDFromBytes(destNfsPath.getBytes());
mountNfs(conn, destUri.getHost() + ":" + destUri.getPath(), localDir);
makeDirectory(conn, localDir + "/" + destDir);
destSr = createFileSR(conn, localDir + "/" + destDir);
String nameLabel = "cloud-" + UUID.randomUUID().toString();
String[] parents = srcObj.getParents();
List<VDI> snapshotChains = new ArrayList<VDI>();
if (parents != null) {
for(int i = 0; i < parents.length; i++) {
String snChainPath = parents[i];
String uuid = getSnapshotUuid(snChainPath);
VDI chain = VDI.getByUuid(conn, uuid);
snapshotChains.add(chain);
}
}
String snapshotUuid = getSnapshotUuid(srcPath);
VDI snapshotVdi = VDI.getByUuid(conn, snapshotUuid);
snapshotChains.add(snapshotVdi);
long templateVirtualSize = snapshotChains.get(0).getVirtualSize(conn);
destVdi = createVdi(conn, nameLabel, destSr, templateVirtualSize);
String destVdiUuid = destVdi.getUuid(conn);