Source:
public Answer copyDiagnosticsFileToSecondaryStorage(Connection conn, CopyToSecondaryStorageCommand cmd) { String secondaryStorageUrl = cmd.getSecondaryStorageUrl(); String vmIP = cmd.getSystemVmIp(); String diagnosticsZipFile = cmd.getFileName(); String localDir = null; boolean success; String secondaryStorageMountPath = null; try { URI uri = new URI(secondaryStorageUrl); secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath(); localDir = "/var/cloud_mount/" + UUID.nameUUIDFromBytes(secondaryStorageMountPath.getBytes()); String mountPoint = mountNfs(conn, secondaryStorageMountPath, localDir); if (org.apache.commons.lang.StringUtils.isBlank(mountPoint)) { return new CopyToSecondaryStorageAnswer(cmd, false, "Could not mount secondary storage " + secondaryStorageMountPath + " on host " + localDir); } String dataDirectoryInSecondaryStore = localDir + "/" + DiagnosticsService.DIAGNOSTICS_DIRECTORY; final CopyToSecondaryStorageAnswer answer; final String scpResult = callHostPlugin(conn, "vmops", "secureCopyToHost", "hostfilepath", dataDirectoryInSecondaryStore, "srcip", vmIP, "srcfilepath", cmd.getFileName()).toLowerCase(); if (scpResult.contains("success")) { answer = new CopyToSecondaryStorageAnswer(cmd, true, "File copied to secondary storage successfully."); } else { answer = new CopyToSecondaryStorageAnswer(cmd, false, "Zip file " + diagnosticsZipFile.replace("/root/", "") + "could not be copied to secondary storage due to " + scpResult); } umountNfs(conn, secondaryStorageMountPath, localDir); localDir = null; return answer; } catch (Exception e) { String msg = "Exception caught zip file copy to secondary storage URI: " + secondaryStorageUrl + "Exception : " + e; s_logger.error(msg); return new CopyToSecondaryStorageAnswer(cmd, false, msg); } finally { if (localDir != null) umountNfs(conn, secondaryStorageMountPath, localDir); } }

Target:
public Answer copyDiagnosticsFileToSecondaryStorage(Connection conn, CopyToSecondaryStorageCommand cmd) { String secondaryStorageUrl = cmd.getSecondaryStorageUrl(); String vmIP = cmd.getSystemVmIp(); String diagnosticsZipFile = cmd.getFileName(); String localDir = null; boolean success; String secondaryStorageMountPath = null; try { URI uri = new URI(secondaryStorageUrl); secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath(); localDir = BASE_MOUNT_POINT_ON_REMOTE + UUID.nameUUIDFromBytes(secondaryStorageMountPath.getBytes()); String mountPoint = mountNfs(conn, secondaryStorageMountPath, localDir); if (org.apache.commons.lang.StringUtils.isBlank(mountPoint)) { return new CopyToSecondaryStorageAnswer(cmd, false, "Could not mount secondary storage " + secondaryStorageMountPath + " on host " + localDir); } String dataDirectoryInSecondaryStore = localDir + File.separator + DiagnosticsService.DIAGNOSTICS_DIRECTORY; final CopyToSecondaryStorageAnswer answer; final String scpResult = callHostPlugin(conn, "vmops", "secureCopyToHost", "hostfilepath", dataDirectoryInSecondaryStore, "srcip", vmIP, "srcfilepath", cmd.getFileName()).toLowerCase(); if (scpResult.contains("success")) { answer = new CopyToSecondaryStorageAnswer(cmd, true, "File copied to secondary storage successfully."); } else { answer = new CopyToSecondaryStorageAnswer(cmd, false, "Zip file " + diagnosticsZipFile.replace("/root/", "") + "could not be copied to secondary storage due to " + scpResult); } umountNfs(conn, secondaryStorageMountPath, localDir); localDir = null; return answer; } catch (Exception e) { String msg = "Exception caught zip file copy to secondary storage URI: " + secondaryStorageUrl + "Exception : " + e; s_logger.error(msg, e); return new CopyToSecondaryStorageAnswer(cmd, false, msg); } finally { if (localDir != null) umountNfs(conn, secondaryStorageMountPath, localDir); } }