forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 7
Retrieve diagnostics (for review purpose) #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
DaanHoogland
wants to merge
72
commits into
shapeblue:master
from
charles-phiri:retrieve-diagnostics
Closed
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
1ee9980
Initial commit
charles-phiri 9f7eff1
some code to enhance the configure method in the Service Layer
charles-phiri 987534e
refactored Service interface
charles-phiri 4ef4c2f
refactored Service interface
charles-phiri 6256e91
refactored Service interface
charles-phiri c7e5572
refactored Service interface
charles-phiri 74822ce
refactored Service interface
charles-phiri e017c1c
refactored Service interface
charles-phiri 9438236
refactored Service interface
charles-phiri 99bb448
refactored Service interface
charles-phiri 3cdb059
refactored Service interface
charles-phiri be2d1b3
refactored Service interface
charles-phiri 6c76aa9
refactored Service interface
charles-phiri 1e24faa
refactored Service interface
charles-phiri ee7907c
refactored Service interface
charles-phiri 65b7d38
refactored Service interface
charles-phiri 182dea9
Removed unused imports
charles-phiri 395b246
refactored Service interface
charles-phiri aae408c
refactored Service interface
charles-phiri a4c6d5d
This is a compiled version of the work I have been doing so far. I am…
charles-phiri e8aa68b
Changed the schema script which was having errors when deploying the DB.
charles-phiri a10c798
Minor fixes on SQL schema file
charles-phiri e0292b5
Changed the schema script which was having errors when deploying the DB.
charles-phiri 64a6185
Refactored some code in the API (Cmd) class.
charles-phiri 135383d
Added some more functionality in the Service Layer class.
charles-phiri 2be2e9d
Removed the code that was using generics in the class DiagnosticsKey.
charles-phiri 943626e
Corrected code in my DiagnosticsConfigDepotImpl class that was using …
charles-phiri e187bc1
Corrected code in my RetrieveDiagnosticsVO class that was using the g…
charles-phiri 98e2aa5
Yet still, removed some code using generics code.
charles-phiri 3b97954
Added more code in the Service Layer class and refactored code in the…
charles-phiri 987b6f7
Refactored code in Service Impl class.
charles-phiri 2ff8287
Added code in spring xml file.
charles-phiri 351f721
Created my own interface class for DiagnosticsConfigDepotImpl as I co…
charles-phiri 94a2fb5
Changed most of the code in the DaO and VO classes including its usag…
charles-phiri 8b57ee6
Refactored code in the Dao and VO, and also added one more method to …
charles-phiri 8995e4f
Cleaned up the code and refactored code so that it has some of the ch…
charles-phiri e6c1029
Refactored code in the Service Layer impl.
charles-phiri 974de4a
Made some code logic changes to the Service Layer when populating the…
charles-phiri fc5ef6f
Addressed comments on the code.
charles-phiri ca4dd82
Refactored code in the Service Layer for retrieving recodes from the …
charles-phiri ca5c308
Added unit test file to test the functionality in the Service Layer i…
charles-phiri fa129fa
Added unit test file to test the functionality in the Service Layer i…
charles-phiri e97895f
Removed the duplicated licence information.
charles-phiri f525aa9
1. Cleaned up code as per Daan's comments.
charles-phiri 3e62161
Mgt-server could be running in a vm that does not have diskOffering. …
charles-phiri cc880d4
Added code to check capacity of the disk space and compare it to the …
charles-phiri 91514d4
Added code to check capacity of the disk space and compare it to the …
charles-phiri 141ab51
Added code to check capacity of the disk space and compare it to the …
charles-phiri 2e55ec2
Added code to check capacity of the disk space and compare it to the …
charles-phiri d2b2d62
Added code to check capacity of the disk space and compare it to the …
charles-phiri 45bd812
Added code to parse for a default value which is in square brackets, …
charles-phiri c9d7ad2
Inserted getters/setters for the script filename variables
charles-phiri dd5579d
Added skeleton scripts (still adding code) to retrieve files and run …
charles-phiri 46098bc
Added code for the two command classes (ExecuteScriptCommand and Retr…
charles-phiri 5d22c03
Added code for the two command classes (ExecuteScriptCommand and Retr…
charles-phiri 5086e34
Added code for the two command classes (ExecuteScriptCommand and Retr…
charles-phiri 555cc86
Add method to check disk space
charles-phiri 94b414d
Minor changes in unit test
charles-phiri 0f19d46
Still working on unit test
charles-phiri 956a434
Added more unit tests.
charles-phiri 76e5545
Skeleton implementation of the Garbage Collector.
charles-phiri c458261
Refactored code while testing, mostly in the Service Layer. Added a c…
charles-phiri 9a6c5cf
Got rid of the cyclic dependencies that I was encountering when compi…
charles-phiri 24f123a
Merge branch 'master' of https://github.com/apache/cloudstack into re…
charles-phiri f66c840
Refactored code in the Service Layer and the python scripts for retri…
charles-phiri 1e4a426
Marvin tests for the RetrieveDiagnostics API
charles-phiri 63f6b9b
Full complete code after refactoring. Addition of copyFileFromSystemV…
charles-phiri 3acbfe4
Code cleanup and refactoring
charles-phiri d08cc7b
Complete RerieveDiagnostics API implementation for testing.
charles-phiri 3c12e07
Complete RerieveDiagnostics API .
charles-phiri f88bde0
Minor bug fixes.
charles-phiri 720da4c
Code for the RetrieveDiagnostics API.
charles-phiri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Refactored code while testing, mostly in the Service Layer. Added a c…
…opyFileFromSystemVm method in the Service Layer to copy files from System VM using the SshHelper class
- Loading branch information
commit c45826118a87655a6d75ae2a96f3c40a2703adae
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,12 +22,13 @@ | |
| import com.cloud.agent.api.Command; | ||
| import com.cloud.agent.api.ExecuteScriptCommand; | ||
| import com.cloud.agent.api.RetrieveDiagnosticsAnswer; | ||
| import com.cloud.agent.api.RetrieveFilesCommand; | ||
| import com.cloud.agent.api.routing.NetworkElementCommand; | ||
| import com.cloud.agent.manager.Commands; | ||
| import com.cloud.capacity.Capacity; | ||
| import com.cloud.capacity.dao.CapacityDao; | ||
| import com.cloud.capacity.dao.CapacityDaoImpl; | ||
| import com.cloud.cluster.ManagementServerHostVO; | ||
| import com.cloud.cluster.dao.ManagementServerHostDao; | ||
| import com.cloud.exception.ConcurrentOperationException; | ||
| import com.cloud.exception.InvalidParameterValueException; | ||
| import com.cloud.exception.OperationTimedoutException; | ||
|
|
@@ -47,6 +48,7 @@ | |
| import com.cloud.storage.dao.DiskOfferingDao; | ||
| import com.cloud.storage.dao.VolumeDao; | ||
| import com.cloud.user.AccountManager; | ||
| import com.cloud.utils.ExecutionResult; | ||
| import com.cloud.utils.NumbersUtil; | ||
| import com.cloud.utils.Pair; | ||
| import com.cloud.utils.component.ManagerBase; | ||
|
|
@@ -55,6 +57,7 @@ | |
| import com.cloud.utils.db.SearchBuilder; | ||
| import com.cloud.utils.db.SearchCriteria; | ||
| import com.cloud.utils.exception.CloudRuntimeException; | ||
| import com.cloud.utils.ssh.SshHelper; | ||
| import com.cloud.vm.DiskProfile; | ||
| import com.cloud.vm.SecondaryStorageVmVO; | ||
| import com.cloud.vm.VMInstanceVO; | ||
|
|
@@ -65,6 +68,7 @@ | |
| import com.cloud.vm.dao.SecondaryStorageVmDao; | ||
| import com.cloud.vm.dao.VMInstanceDao; | ||
| import com.google.common.base.Strings; | ||
| import com.jcraft.jsch.JSchException; | ||
| import org.apache.cloudstack.api.ApiErrorCode; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.command.admin.diagnostics.RetrieveDiagnosticsCmd; | ||
|
|
@@ -83,11 +87,13 @@ | |
| import org.apache.cloudstack.framework.config.impl.RetrieveDiagnosticsDao; | ||
| import org.apache.cloudstack.framework.config.impl.RetrieveDiagnosticsVO; | ||
| import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; | ||
| import org.apache.commons.lang.ArrayUtils; | ||
| import org.apache.log4j.Logger; | ||
|
|
||
| import javax.inject.Inject; | ||
| import javax.naming.ConfigurationException; | ||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
|
|
@@ -107,15 +113,18 @@ public class RetrieveDiagnosticsServiceImpl extends ManagerBase implements Retri | |
| protected Map<String, Object> configParams = new HashMap<String, Object>(); | ||
| private Map<String, String> _configs; | ||
|
|
||
| private String scriptNameRetrieve = null; | ||
|
|
||
| private String scriptNameRemove = null; | ||
| private String scriptName = null; | ||
|
|
||
| ScheduledExecutorService _executor = null; | ||
|
|
||
| HashMap<String, List<DiagnosticsKey>> allDefaultDiagnosticsTypeKeys = new HashMap<String, List<DiagnosticsKey>>(); | ||
|
|
||
| private Boolean gcEnabled; | ||
| private Long interval; | ||
|
|
||
| private Float disableThreshold; | ||
| private String filePath; | ||
| private Long fileAge; | ||
|
|
||
| @Inject | ||
| private HostDao _hostDao; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove the _ from this field and all those below |
||
|
|
@@ -129,6 +138,9 @@ public class RetrieveDiagnosticsServiceImpl extends ManagerBase implements Retri | |
| @Inject | ||
| private AgentManager _agentMgr; | ||
|
|
||
| @Inject | ||
| private ManagementServerHostDao managementServerHostDao; | ||
|
|
||
| @Inject | ||
| public AccountManager _accountMgr; | ||
|
|
||
|
|
@@ -186,6 +198,16 @@ public class RetrieveDiagnosticsServiceImpl extends ManagerBase implements Retri | |
|
|
||
| ConfigKey<Long> RetrieveDiagnosticsTimeOut = new ConfigKey<Long>("Advanced", Long.class, "retrieveDiagnostics.retrieval.timeout", "3600", | ||
| "The timeout setting in seconds for the overall API call", true, ConfigKey.Scope.Global); | ||
| ConfigKey<Boolean> RetrieveDiagnosticsGCEnable = new ConfigKey<Boolean>("Advanced", Boolean.class, "retrieveDiagnostics.gc.enabled", "true", | ||
| "Garbage collection on/off switch", true, ConfigKey.Scope.Global); | ||
| ConfigKey<Long> RetrieveDiagnosticsInterval = new ConfigKey<Long>("Advanced", Long.class, "retrieveDiagnostics.gc.interval", "86400", | ||
| "Interval between garbage collection execution", true, ConfigKey.Scope.Global); | ||
| ConfigKey<Float> RetrieveDiagnosticsDisableThreshold = new ConfigKey<Float>("Advanced", Float.class, "retrieveDiagnostics.disablethreshold", "0.95", | ||
| "Percentage disk space cut-off before API will fail", true, ConfigKey.Scope.Global); | ||
| ConfigKey<String> RetrieveDiagnosticsFilePath = new ConfigKey<String>("Advanced", String.class, "retrieveDiagnostics.filepath", "/tmp", | ||
| "The path to use on the management server for all temporary data", true, ConfigKey.Scope.Global); | ||
| ConfigKey<Long> RetrieveDiagnosticsFileAge = new ConfigKey<Long>("Advanced", Long.class, "retrieveDiagnostics.max.fileage", "86400", | ||
| "The Diagnostics file age in seconds before considered for garbage collection", true, ConfigKey.Scope.Global); | ||
|
|
||
| public RetrieveDiagnosticsServiceImpl() { | ||
| } | ||
|
|
@@ -198,8 +220,20 @@ public boolean configure(final String name, final Map<String, Object> params) th | |
| _configs = _configDao.getConfiguration(); | ||
|
|
||
| _timeOut = RetrieveDiagnosticsTimeOut.value(); | ||
| gcEnabled = RetrieveDiagnosticsGCEnable.value(); | ||
| interval = RetrieveDiagnosticsInterval.value(); | ||
| disableThreshold = RetrieveDiagnosticsDisableThreshold.value(); | ||
| filePath = RetrieveDiagnosticsFilePath.value(); | ||
| fileAge = RetrieveDiagnosticsFileAge.value(); | ||
|
|
||
| if (params != null) { | ||
| params.put(RetrieveDiagnosticsTimeOut.key(), (Long)RetrieveDiagnosticsTimeOut.value()); | ||
| params.put(RetrieveDiagnosticsGCEnable.key(), (Boolean)RetrieveDiagnosticsGCEnable.value()); | ||
| params.put(RetrieveDiagnosticsInterval.key(), (Long)RetrieveDiagnosticsInterval.value()); | ||
| params.put(RetrieveDiagnosticsDisableThreshold.key(), (Float)RetrieveDiagnosticsDisableThreshold.value()); | ||
| params.put(RetrieveDiagnosticsFilePath.key(), (String)RetrieveDiagnosticsFilePath.value()); | ||
| params.put(RetrieveDiagnosticsFileAge.key(), (Long)RetrieveDiagnosticsFileAge.value()); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -276,8 +310,7 @@ public Map<String, String> getDiagnosticsFiles(final RetrieveDiagnosticsCmd cmd) | |
| String systemVmType = null; | ||
| String diagnosticsType = null; | ||
| String fileDetails = null; | ||
| String[] filesToRetrieve = null; | ||
| String[] listOfDiagnosticsFiles = null; | ||
| String listOfDiagnosticsFiles = null; | ||
| List<String> diagnosticsFiles = new ArrayList<>(); | ||
| if (configParams == null) { | ||
| configParams = new HashMap<>(); | ||
|
|
@@ -305,30 +338,29 @@ public Map<String, String> getDiagnosticsFiles(final RetrieveDiagnosticsCmd cmd) | |
| } | ||
| if (diagnosticsType == null) { | ||
| listOfDiagnosticsFiles = getAllDefaultFilesForEachSystemVm(diagnosticsType); | ||
| for (String entry : filesToRetrieve ) { | ||
| diagnosticsFiles.add(entry); | ||
| } | ||
| } else { | ||
| fileDetails = cmd.getOptionalListOfFiles(); | ||
| if (fileDetails != null) { | ||
| filesToRetrieve = fileDetails.split(","); | ||
| StringBuilder filesToRetrieve = new StringBuilder(); | ||
| filesToRetrieve.append(fileDetails); | ||
| listOfDiagnosticsFiles = getDefaultFilesForVm(diagnosticsType, systemVmType); | ||
| for (String entry : filesToRetrieve ) { | ||
| diagnosticsFiles.add(entry); | ||
| } | ||
| for (String defaultFileList : listOfDiagnosticsFiles) { | ||
| diagnosticsFiles.add(defaultFileList); | ||
| if (listOfDiagnosticsFiles != null) { | ||
| filesToRetrieve.append("," + listOfDiagnosticsFiles); | ||
| } | ||
| listOfDiagnosticsFiles = filesToRetrieve.toString(); | ||
| } else { | ||
| //retrieve default files from diagnostics data class for the system vm | ||
| listOfDiagnosticsFiles = getDefaultFilesForVm(diagnosticsType, systemVmType); | ||
| for (String key : listOfDiagnosticsFiles) { | ||
| diagnosticsFiles.add(key); | ||
| } | ||
|
|
||
| } | ||
| } | ||
| Map<String, String> response = retrieveDiagnosticsFiles(cmd.getId(), diagnosticsFiles, vmInstance, RetrieveDiagnosticsTimeOut.value()); | ||
| Map<String, String> response = null; | ||
| try { | ||
| response = retrieveDiagnosticsFiles(vmId, listOfDiagnosticsFiles, vmInstance, RetrieveDiagnosticsTimeOut.value()); | ||
| } catch(JSchException ex) { | ||
| System.exit(1); | ||
| } catch (IOException e) { | ||
| System.exit(1); | ||
| } | ||
| if (response != null) | ||
| return response; | ||
| } | ||
|
|
@@ -337,108 +369,98 @@ public Map<String, String> getDiagnosticsFiles(final RetrieveDiagnosticsCmd cmd) | |
|
|
||
| } | ||
|
|
||
| protected String[] getAllDefaultFilesForEachSystemVm(String diagnosticsType) { | ||
| protected String getAllDefaultFilesForEachSystemVm(String diagnosticsType) { | ||
| StringBuilder listDefaultFilesForEachVm = new StringBuilder(); | ||
| List<DiagnosticsKey> diagnosticsKey = get(diagnosticsType); | ||
| for (DiagnosticsKey key : diagnosticsKey) { | ||
| listDefaultFilesForEachVm.append(key.getDetail()); | ||
| } | ||
| return listDefaultFilesForEachVm.toString().split(","); | ||
| return listDefaultFilesForEachVm.toString(); | ||
| } | ||
|
|
||
| protected String[] getDefaultFilesForVm(String diagnosticsType, String systemVmType) { | ||
| protected String getDefaultFilesForVm(String diagnosticsType, String systemVmType) { | ||
| String listDefaultFilesForVm = null; | ||
| List<DiagnosticsKey> diagnosticsKey = allDefaultDiagnosticsTypeKeys.get(diagnosticsType); | ||
| for (DiagnosticsKey key : diagnosticsKey) { | ||
| if (key.getRole().equalsIgnoreCase(systemVmType)) { | ||
| listDefaultFilesForVm = key.getDetail(); | ||
| return listDefaultFilesForVm; | ||
| } | ||
| return listDefaultFilesForVm.split(","); | ||
|
|
||
| } | ||
| return null; | ||
| } | ||
|
|
||
| public ExecutionResult copyFileFromSystemVm(final String ip, final String filename) { | ||
|
|
||
| protected Map<String, String> retrieveDiagnosticsFiles(Long ssHostId, List<String> diagnosticsFiles, final VMInstanceVO systemVmId, Long timeout) | ||
| throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { | ||
| if (LOGGER.isInfoEnabled()) { | ||
| LOGGER.info("Retrieving diagnostics files : " + getConfigComponentName()); | ||
| final File permKey = new File("/root/.ssh/id_rsa.cloud"); | ||
| boolean success = true; | ||
| String details = "Copying file in System VM, with ip: " + ip + ", file: " + filename; | ||
| LOGGER.debug(details); | ||
|
|
||
| try { | ||
| SshHelper.scpTo(ip, 22, "root", permKey, null, null, filename.getBytes(), filename, null); | ||
| } catch (final Exception e) { | ||
| LOGGER.warn("Fail to copy file " + filename + " in System VM " + ip, e); | ||
| details = e.getMessage(); | ||
| success = false; | ||
| } | ||
| return new ExecutionResult(success, details); | ||
| } | ||
|
|
||
| Float disableThreshold = Float.parseFloat(_configs.get("retrieveDiagnostics.disablethreshold")); | ||
| String filePath = _configs.get("retrieveDiagnostics.filepath"); | ||
| Long fileAge = Long.parseLong(_configs.get("retrieveDiagnostics.max.fileage")); | ||
| Long timeIntervalGCexecution = Long.parseLong(_configs.get("retrieveDiagnostics.gc.interval")); | ||
| gcEnabled = Boolean.parseBoolean("retrieveDiagnostics.gc.enabled"); | ||
| Long wait = Long.parseLong(_configDao.getValue(RetrieveDiagnosticsTimeOut.key()), 3600); | ||
| String tempStr = null; | ||
|
|
||
| if (ssHostId == null) { | ||
| LOGGER.info("No host selected." + getConfigComponentName()); | ||
| } | ||
| if (wait <= 0) { | ||
| timeout = RetrieveDiagnosticsTimeOut.value(); | ||
| } | ||
| if (filePath == null) { | ||
| filePath = "\\tmp"; | ||
| } | ||
| if (fileAge == null) { | ||
| fileAge = 86400L; | ||
| } | ||
| if (disableThreshold == null) { | ||
| disableThreshold = 0.95F; | ||
| } | ||
| if (timeIntervalGCexecution == null) { | ||
| timeIntervalGCexecution = 86400L; | ||
| } | ||
| if (!gcEnabled) { | ||
| gcEnabled = true; | ||
| protected Map<String, String> retrieveDiagnosticsFiles(Long ssHostId, String diagnosticsFiles, final VMInstanceVO systemVmId, Long timeout) | ||
| throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException, JSchException, IOException { | ||
| if (LOGGER.isInfoEnabled()) { | ||
| LOGGER.info("Retrieving diagnostics files : " + getConfigComponentName()); | ||
| } | ||
| String tempStr = null; | ||
| final Hypervisor.HypervisorType hypervisorType = systemVmId.getHypervisorType(); | ||
| List<String> deleteSquareBracketedEntries = new ArrayList<>(); | ||
| List<String> scripts = new ArrayList<>(); | ||
| boolean isSquareBracketed = false; | ||
| Commands cmds = null; | ||
| for (String squareBracketsString : diagnosticsFiles) { | ||
| if (squareBracketsString.contains("[]")) { | ||
| isSquareBracketed = true; | ||
| deleteSquareBracketedEntries.add(squareBracketsString); | ||
| tempStr = squareBracketsString.trim().replaceAll("(^\\[(.*?)\\].*)", ("$2").trim()); | ||
| if (!tempStr.equalsIgnoreCase("IPTABLES") || !tempStr.equalsIgnoreCase("IFCONFIG")) { | ||
| throw new InvalidParameterValueException("CloudStack does not support " + squareBracketsString); | ||
| } | ||
| scriptNameRetrieve = tempStr.toLowerCase().concat(".py"); | ||
| scripts.add(scriptNameRetrieve); | ||
| String[] files = diagnosticsFiles.split(","); | ||
| for (int i = files.length - 1; i >= 0; i--) { | ||
| if (files[i].contains("[") || files[i].contains("]")) { | ||
| tempStr = files[i].trim().replaceAll("(^\\[(.*?)\\].*?)", ("$2").trim()); | ||
| scriptName = tempStr.toLowerCase().concat(".py"); | ||
| scripts.add(scriptName); | ||
| files = (String[])ArrayUtils.removeElement(files, files[i]); | ||
| } | ||
| } | ||
| if (isSquareBracketed) { | ||
| for (String deleteSquareBracketed : deleteSquareBracketedEntries) { | ||
| diagnosticsFiles.remove(deleteSquareBracketed); | ||
| } | ||
| ManagementServerHostVO managementServerHostVO = managementServerHostDao.findById(systemVmId.getHostId()); | ||
| String ipHostAddress = managementServerHostVO.getServiceIP(); | ||
| StringBuilder filesSpaceDelimited = new StringBuilder(); | ||
| for (String file : files) { | ||
| filesSpaceDelimited.append(file); | ||
| copyFileFromSystemVm(ipHostAddress, file); | ||
| filesSpaceDelimited.append(" "); | ||
| } | ||
| String filesToRetrieveCommaSeparated = filesSpaceDelimited.toString(); | ||
| cmds = new Commands(Command.OnError.Stop); | ||
| ExecuteScriptCommand execCmd = null; | ||
| final Map<String, String> accessDetails = networkManager.getSystemVMAccessDetails(systemVmId); | ||
| if (!scripts.isEmpty()) { | ||
| for (String script : scripts) { | ||
| execCmd = new ExecuteScriptCommand(script, vmManager.getExecuteInSequence(hypervisorType)); | ||
| execCmd.setAccessDetail(accessDetails); | ||
| cmds.addCommand(execCmd); | ||
| } | ||
| } | ||
| final Map<String, String> accessDetails = networkManager.getSystemVMAccessDetails(systemVmId); | ||
| execCmd.setAccessDetail(accessDetails); | ||
| String filesToRetrieveCommaSeparated = String.join(",", diagnosticsFiles); | ||
| RetrieveFilesCommand retrieveFilesCommand = new RetrieveFilesCommand(filesToRetrieveCommaSeparated, vmManager.getExecuteInSequence(hypervisorType)); | ||
| retrieveFilesCommand.setAccessDetail(accessDetails); | ||
| cmds.addCommand(retrieveFilesCommand); | ||
|
|
||
| //RetrieveFilesCommand retrieveFilesCommand = new RetrieveFilesCommand(filesToRetrieveCommaSeparated, vmManager.getExecuteInSequence(hypervisorType)); | ||
| //retrieveFilesCommand.setAccessDetail(accessDetails); | ||
| //cmds.addCommand(retrieveFilesCommand); | ||
|
|
||
| if (Strings.isNullOrEmpty(accessDetails.get(NetworkElementCommand.ROUTER_IP))) { | ||
| throw new CloudRuntimeException("Unable to set system vm ControlIP for the system vm with ID -> " + systemVmId); | ||
| } | ||
| Map<String, String> resultsMap; | ||
| final Long hostId = systemVmId.getHostId(); | ||
| _agentMgr.send(hostId, cmds); | ||
| Answer[] answers = _agentMgr.send(hostId, cmds); | ||
|
|
||
| if (!cmds.isSuccessful()) { | ||
| for (final Answer answer : cmds.getAnswers()) { | ||
| copyFileFromSystemVm(ipHostAddress, scriptName + ".log"); | ||
| for (final Answer answer : answers) { | ||
| if (!answer.getResult()) { | ||
| LOGGER.warn("Failed to retrieve results due to: " + answer.getDetails()); | ||
|
|
||
|
|
@@ -594,7 +616,9 @@ public void cleanupDiagnostics() { | |
| @Override | ||
| public boolean start() { | ||
| gcEnabled = Boolean.parseBoolean("retrieveDiagnostics.gc.enabled"); | ||
| Long interval = Long.parseLong(_configs.get("retrieveDiagnostics.gc.interval")); | ||
| if (interval == null) { | ||
| interval = 86400L; | ||
| } | ||
| Integer cleanupInterval = (int)(long) interval; | ||
| if (!super.start()) { | ||
| return false; | ||
|
|
@@ -618,21 +642,14 @@ public boolean stop() { | |
| return true; | ||
| } | ||
|
|
||
| public String getScriptNameRetrieve() { | ||
| return scriptNameRetrieve; | ||
| } | ||
|
|
||
| public void setScriptNameRetrieve(String scriptNameRetrieve) { | ||
| this.scriptNameRetrieve = scriptNameRetrieve; | ||
| public String getScriptName() { | ||
| return scriptName; | ||
| } | ||
|
|
||
| public String getScriptNameRemove() { | ||
| return scriptNameRemove; | ||
| public void setScriptName(String scriptName) { | ||
| this.scriptName = scriptName; | ||
| } | ||
|
|
||
| public void setScriptNameRemove(String scriptNameRemove) { | ||
| this.scriptNameRemove = scriptNameRemove; | ||
| } | ||
|
|
||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the underscore from the names, here and below