cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cloudstack] DaanHoogland commented on a change in pull request #3350: Retrieve diagnostics data rebase
Date Fri, 24 May 2019 12:36:47 GMT
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<String> optionalFilesList = cmd.getFilesList();
+        VMInstanceVO vmInstance = getSystemVMInstance(vmId);
+        long zoneId = vmInstance.getDataCenterId();
+
+        List<String> 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<Boolean, String> 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

Mime
View raw message