From commits-return-87956-archive-asf-public=cust-asf.ponee.io@cloudstack.apache.org Fri May 24 12:36:49 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id E67DD180671 for ; Fri, 24 May 2019 14:36:48 +0200 (CEST) Received: (qmail 76115 invoked by uid 500); 24 May 2019 12:36:47 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 76034 invoked by uid 99); 24 May 2019 12:36:47 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 May 2019 12:36:47 +0000 From: GitBox To: commits@cloudstack.apache.org Subject: [GitHub] [cloudstack] DaanHoogland commented on a change in pull request #3350: Retrieve diagnostics data rebase Message-ID: <155870140745.13716.642191038362011020.gitbox@gitbox.apache.org> Date: Fri, 24 May 2019 12:36:47 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit DaanHoogland commented on a change in pull request #3350: Retrieve diagnostics data rebase URL: https://github.com/apache/cloudstack/pull/3350#discussion_r287329309 ########## File path: server/src/main/java/org/apache/cloudstack/diagnostics/DiagnosticsServiceImpl.java ########## @@ -126,10 +191,333 @@ protected String prepareShellCmd(String cmdType, String ipAddress, String option } } + @Override + @ActionEvent(eventType = EventTypes.EVENT_SYSTEM_VM_DIAGNOSTICS, eventDescription = "getting diagnostics files on system vm", async = true) + public String getDiagnosticsDataCommand(GetDiagnosticsDataCmd cmd) { + Long vmId = cmd.getId(); + List optionalFilesList = cmd.getFilesList(); + VMInstanceVO vmInstance = getSystemVMInstance(vmId); + long zoneId = vmInstance.getDataCenterId(); + + List fileList = getFileListToBeRetrieved(optionalFilesList, vmInstance); + + if (CollectionUtils.isEmpty(fileList)) { + throw new CloudRuntimeException("Failed to generate diagnostics file list for retrieval."); + } + + Long vmHostId = vmInstance.getHostId(); + + // Find Secondary Storage with enough Disk Quota in the current Zone + final DataStore store = getImageStore(vmInstance.getDataCenterId()); + + Answer zipFilesAnswer = zipDiagnosticsFilesInSystemVm(vmInstance, fileList); + + if (zipFilesAnswer == null) { + throw new CloudRuntimeException(String.format("Failed to generate diagnostics zip file in VM %s", vmInstance.getUuid())); + } + + if (!zipFilesAnswer.getResult()) { + throw new CloudRuntimeException(String.format("Failed to generate diagnostics zip file file in VM %s due to %s", vmInstance.getUuid(), zipFilesAnswer.getDetails())); + } + + // Copy zip file from system VM to secondary storage + String zipFileInSystemVm = zipFilesAnswer.getDetails().replace("\n", ""); + Pair copyToSecondaryStorageResults = copyZipFileToSecondaryStorage(vmInstance, vmHostId, zipFileInSystemVm, store); + + // Send cleanup zip file cleanup command to system VM + Answer fileCleanupAnswer = deleteDiagnosticsZipFileInsystemVm(vmInstance, zipFileInSystemVm); + if (fileCleanupAnswer == null) { + LOGGER.error(String.format("Failed to cleanup diagnostics zip file on vm: %s", vmInstance.getUuid())); + } else { + if (!fileCleanupAnswer.getResult()) { + LOGGER.error(String.format("Zip file cleanup for vm %s has failed with: %s", vmInstance.getUuid(), fileCleanupAnswer.getDetails())); + } + } + + if (!copyToSecondaryStorageResults.first()) { + throw new CloudRuntimeException(String.format("Failed to copy %s to secondary storage %s due to %s.", zipFileInSystemVm, store.getUri(), copyToSecondaryStorageResults.second())); + } + + // Now we need to create the file download URL + // Find ssvm of store + VMInstanceVO ssvm = getSecondaryStorageVmInZone(zoneId); + if (ssvm == null) { + throw new CloudRuntimeException("No ssvm found in Zone with ID: " + zoneId); + } + // Secondary Storage install path = "diagnostics_data/diagnostics_files_xxxx.tar + String installPath = DIAGNOSTICS_DATA_DIRECTORY + "/" + zipFileInSystemVm.replace("/root", ""); Review comment: formality but "/" should be File.separator ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services