-
Notifications
You must be signed in to change notification settings - Fork 7
Remote Diagnostics API #13
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
Changes from 1 commit
0658e24
bbe380d
836bcb1
67669db
95e8e57
17dc1e1
8cf67d3
c9d4458
259a459
cd5e623
bf01218
448fb44
1e60bdc
9b9cb89
72f7023
05483de
1df8855
1ff1298
6a09386
0c45874
289a4ed
e3f2bef
7645c07
9801b9f
149f422
97e560d
50d152f
93a3cfb
5571123
6a11767
2ddb21b
11a818b
2f5767c
80058c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,6 +138,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE | |
| response.setStdout(answerMap.get("STDOUT")); | ||
| response.setStderr(answerMap.get("STDERR")); | ||
| response.setExitCode(answerMap.get("EXITCODE")); | ||
| response.setResult(answerMap.get("SUCCESS")); | ||
|
Member
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. as discussed: considder not returning success but only exitcode.
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. Removed success return |
||
| response.setObjectName("diagnostics"); | ||
|
Member
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. should the name contain some noun or verb indicating that it contains the resiult of a test/diagnostic command-run?
Member
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. maybe involve Paul in that discussion
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. Changed it to diagnostics results |
||
| response.setResponseName(getCommandName()); | ||
| this.setResponseObject(response); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,8 +53,6 @@ | |
| import com.cloud.utils.Pair; | ||
| import com.cloud.utils.component.Manager; | ||
| import com.cloud.vm.VirtualMachine.PowerState; | ||
| import org.apache.cloudstack.diagnostics.DiagnosticsAnswer; | ||
| import org.apache.cloudstack.diagnostics.DiagnosticsCommand; | ||
|
|
||
| import java.util.HashMap; | ||
|
Member
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. if only the order of imports has changed you better revert this
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. Done |
||
| import java.util.Map; | ||
|
|
@@ -99,8 +97,6 @@ public interface MockVmManager extends Manager { | |
|
|
||
| CheckRouterAnswer checkRouter(CheckRouterCommand cmd); | ||
|
|
||
| DiagnosticsAnswer executeDiagnostics(DiagnosticsCommand cmd); | ||
|
|
||
| Answer cleanupNetworkRules(CleanupNetworkRulesCmd cmd, SimulatorInfo info); | ||
|
|
||
| Answer scaleVm(ScaleVmCommand cmd); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,8 +76,6 @@ | |
| import com.cloud.utils.db.TransactionLegacy; | ||
| import com.cloud.utils.exception.CloudRuntimeException; | ||
| import com.cloud.vm.VirtualMachine.PowerState; | ||
| import org.apache.cloudstack.diagnostics.DiagnosticsAnswer; | ||
| import org.apache.cloudstack.diagnostics.DiagnosticsCommand; | ||
| import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; | ||
|
Member
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. if only the order of imports has changed you better revert this
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. Done |
||
| import org.apache.log4j.Logger; | ||
| import org.springframework.stereotype.Component; | ||
|
|
@@ -273,14 +271,6 @@ public CheckRouterAnswer checkRouter(final CheckRouterCommand cmd) { | |
| } | ||
| } | ||
|
|
||
| @Override | ||
| public DiagnosticsAnswer executeDiagnostics(final DiagnosticsCommand cmd) { | ||
| final String router_name = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); | ||
| final MockVm vm = _mockVmDao.findByVmName(router_name); | ||
|
|
||
| return new DiagnosticsAnswer(cmd, true, null); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String, PowerState> getVmStates(final String hostGuid) { | ||
| TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,6 @@ | |
| // under the License. | ||
| package com.cloud.agent.manager; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| import com.cloud.agent.api.Answer; | ||
| import com.cloud.agent.api.Command; | ||
| import com.cloud.agent.api.StoragePoolInfo; | ||
|
|
@@ -29,6 +26,9 @@ | |
| import com.cloud.utils.component.Manager; | ||
| import com.cloud.vm.VirtualMachine.PowerState; | ||
|
|
||
| import java.util.HashMap; | ||
|
Member
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. if only the order of imports has changed you better revert this
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. Done |
||
| import java.util.Map; | ||
|
|
||
| public interface SimulatorManager extends Manager { | ||
| public static final String Name = "simulator manager"; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,46 +16,24 @@ | |
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // | ||
|
|
||
| package org.apache.cloudstack.diagnostics; | ||
|
|
||
| import com.cloud.exception.InvalidParameterValueException; | ||
| import com.cloud.vm.VirtualMachine; | ||
| import com.cloud.vm.dao.VMInstanceDao; | ||
| import junit.framework.TestCase; | ||
| import org.apache.cloudstack.api.command.admin.diagnostics.ExecuteDiagnosticsCmd; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.mockito.InjectMocks; | ||
| import org.mockito.Mock; | ||
| import org.mockito.Mockito; | ||
| import org.mockito.MockitoAnnotations; | ||
| import org.mockito.runners.MockitoJUnitRunner; | ||
|
|
||
| @RunWith(MockitoJUnitRunner.class) | ||
| public class DiagnosticsServiceImplTest extends TestCase { | ||
|
|
||
| @Mock | ||
| private VMInstanceDao vmInstanceDao; | ||
| @Mock | ||
| private ExecuteDiagnosticsCmd executeDiagnosticsCmd; | ||
| @InjectMocks | ||
| private DiagnosticsServiceImpl diagnosticsService = new DiagnosticsServiceImpl(); | ||
| public class DiagnosticsServiceImplTest { | ||
|
|
||
|
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. Remove extra newline.
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. Done |
||
| @Before | ||
| public void setUp() throws Exception { | ||
| MockitoAnnotations.initMocks(this); | ||
| executeDiagnosticsCmd = Mockito.mock(ExecuteDiagnosticsCmd.class); | ||
| Mockito.when(executeDiagnosticsCmd.getId()).thenReturn(1L); | ||
| Mockito.when(executeDiagnosticsCmd.getAddress()).thenReturn("8.8.8.8"); | ||
| Mockito.when(executeDiagnosticsCmd.getType().getValue()).thenReturn("ping"); | ||
| Mockito.when(executeDiagnosticsCmd.getOptionalArguments()).thenReturn("-c"); | ||
| } | ||
|
|
||
| @Test(expected = InvalidParameterValueException.class) | ||
| public void testExecuteDiagnosticsToolInSystemVmThrowsException() throws Exception { | ||
| Mockito.when(vmInstanceDao.findByIdTypes(executeDiagnosticsCmd.getId(), VirtualMachine.Type.ConsoleProxy, | ||
| VirtualMachine.Type.DomainRouter, VirtualMachine.Type.SecondaryStorageVm)).thenReturn(null); | ||
| diagnosticsService.runDiagnosticsCommand(executeDiagnosticsCmd); | ||
| @After | ||
| public void tearDown() throws Exception { | ||
| } | ||
|
|
||
| @Test | ||
| public void runDiagnosticsCommand() { | ||
| } | ||
| } | ||
| } | ||
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.
Change the
.get()to get based on a known constant than a hardcoded string likeSTDOUT, STDERR and EXITCODE.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.
Done