use of com.cloud.legacymodel.communication.command.GetGPUStatsCommand in project cosmic by MissionCriticalCloud.
the class ResourceManagerImpl method getGPUStatistics.
@Override
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGPUStatistics(final HostVO host) {
final Answer answer = this._agentMgr.easySend(host.getId(), new GetGPUStatsCommand(host.getGuid(), host.getName()));
if (answer != null && answer instanceof UnsupportedAnswer) {
return null;
}
if (answer == null || !answer.getResult()) {
final String msg = "Unable to obtain GPU stats for host " + host.getName();
s_logger.warn(msg);
return null;
} else {
// now construct the result object
if (answer instanceof GetGPUStatsAnswer) {
return ((GetGPUStatsAnswer) answer).getGroupDetails();
}
}
return null;
}
use of com.cloud.legacymodel.communication.command.GetGPUStatsCommand in project cosmic by MissionCriticalCloud.
the class XenServer620SP1WrapperTest method testGetGPUStatsCommandFailure.
@Test
public void testGetGPUStatsCommandFailure() {
final String guuid = "246a5b75-05ed-4bbc-a171-2d1fe94a1b0e";
final Connection conn = Mockito.mock(Connection.class);
final GetGPUStatsCommand gpuStats = new GetGPUStatsCommand(guuid, "xen");
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(xenServer620SP1Resource.getConnection()).thenReturn(conn);
try {
when(xenServer620SP1Resource.getGPUGroupDetails(conn)).thenThrow(new CloudRuntimeException("Failed!"));
} catch (final XenAPIException e) {
fail(e.getMessage());
} catch (final XmlRpcException e) {
fail(e.getMessage());
}
final Answer answer = wrapper.execute(gpuStats, xenServer620SP1Resource);
verify(xenServer620SP1Resource, times(1)).getConnection();
try {
verify(xenServer620SP1Resource, times(1)).getGPUGroupDetails(conn);
} catch (final XenAPIException e) {
fail(e.getMessage());
} catch (final XmlRpcException e) {
fail(e.getMessage());
}
assertFalse(answer.getResult());
}
use of com.cloud.legacymodel.communication.command.GetGPUStatsCommand in project cosmic by MissionCriticalCloud.
the class XenServer620SP1WrapperTest method testGetGPUStatsCommand.
@Test
public void testGetGPUStatsCommand() {
final String guuid = "246a5b75-05ed-4bbc-a171-2d1fe94a1b0e";
final Connection conn = Mockito.mock(Connection.class);
final GetGPUStatsCommand gpuStats = new GetGPUStatsCommand(guuid, "xen");
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(xenServer620SP1Resource.getConnection()).thenReturn(conn);
try {
when(xenServer620SP1Resource.getGPUGroupDetails(conn)).thenReturn(new HashMap<>());
} catch (final XenAPIException e) {
fail(e.getMessage());
} catch (final XmlRpcException e) {
fail(e.getMessage());
}
final Answer answer = wrapper.execute(gpuStats, xenServer620SP1Resource);
verify(xenServer620SP1Resource, times(1)).getConnection();
try {
verify(xenServer620SP1Resource, times(1)).getGPUGroupDetails(conn);
} catch (final XenAPIException e) {
fail(e.getMessage());
} catch (final XmlRpcException e) {
fail(e.getMessage());
}
assertTrue(answer.getResult());
}
Aggregations