Source:
public Map<String, String> runDiagnosticsCommand(final RunDiagnosticsCmd cmd) { final Long vmId = cmd.getId(); final String cmdType = cmd.getType().getValue(); final String ipAddress = cmd.getAddress(); final String optionalArguments = cmd.getOptionalArguments(); final VMInstanceVO vmInstance = instanceDao.findByIdTypes(vmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.DomainRouter, VirtualMachine.Type.SecondaryStorageVm); if (vmInstance == null) { throw new InvalidParameterValueException("Unable to find a system vm with id " + vmId); } final Long hostId = vmInstance.getHostId(); if (hostId == null) { throw new CloudRuntimeException("Unable to find host for virtual machine instance: " + vmInstance.getInstanceName()); } final String shellCmd = prepareShellCmd(cmdType, ipAddress, optionalArguments); if (Strings.isNullOrEmpty(shellCmd)) { throw new IllegalArgumentException("Optional parameters contain unwanted characters: " + optionalArguments); } final Hypervisor.HypervisorType hypervisorType = vmInstance.getHypervisorType(); final DiagnosticsCommand command = new DiagnosticsCommand(shellCmd, vmManager.getExecuteInSequence(hypervisorType)); final Map<String, String> accessDetails = networkManager.getSystemVMAccessDetails(vmInstance); if (Strings.isNullOrEmpty(accessDetails.get(NetworkElementCommand.ROUTER_IP))) { throw new CloudRuntimeException("Unable to set system vm ControlIP for system vm with ID: " + vmId); } command.setAccessDetail(accessDetails); Map<String, String> detailsMap; Answer answer = agentManager.easySend(hostId, command); if (answer != null) { detailsMap = ((DiagnosticsAnswer) answer).getExecutionDetails(); return detailsMap; } else { throw new CloudRuntimeException("Failed to execute diagnostics command on remote host: " + vmInstance.getHostName()); } }

Target:
public Map<String, String> runDiagnosticsCommand(final RunDiagnosticsCmd cmd) { final Long vmId = cmd.getId(); final String cmdType = cmd.getType().getValue(); final String ipAddress = cmd.getAddress(); final String optionalArguments = cmd.getOptionalArguments(); final VMInstanceVO vmInstance = instanceDao.findByIdTypes(vmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.DomainRouter, VirtualMachine.Type.SecondaryStorageVm); if (vmInstance == null) { throw new InvalidParameterValueException("Unable to find a system vm with id " + vmId); } final Long hostId = vmInstance.getHostId(); if (hostId == null) { throw new CloudRuntimeException("Unable to find host for virtual machine instance: " + vmInstance.getInstanceName()); } final String shellCmd = prepareShellCmd(cmdType, ipAddress, optionalArguments); if (Strings.isNullOrEmpty(shellCmd)) { throw new IllegalArgumentException("Optional parameters contain unwanted characters: " + optionalArguments); } final Hypervisor.HypervisorType hypervisorType = vmInstance.getHypervisorType(); final DiagnosticsCommand command = new DiagnosticsCommand(shellCmd, vmManager.getExecuteInSequence(hypervisorType)); final Map<String, String> accessDetails = networkManager.getSystemVMAccessDetails(vmInstance); if (Strings.isNullOrEmpty(accessDetails.get(NetworkElementCommand.ROUTER_IP))) { throw new CloudRuntimeException("Unable to set system vm ControlIP for system vm with ID: " + vmId); } command.setAccessDetail(accessDetails); Map<String, String> detailsMap; Answer answer = agentManager.easySend(hostId, command); if (answer != null) { detailsMap = ((DiagnosticsAnswer) answer).getExecutionDetails(); return detailsMap; } else { throw new CloudRuntimeException("Failed to execute diagnostics command for system vm: " + vmInstance + ", on remote host: " + vmInstance.getHostName()); } }