Search in sources :

Example 1 with GetGPUStatsCommand

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;
}
Also used : GetGPUStatsCommand(com.cloud.legacymodel.communication.command.GetGPUStatsCommand) UnsupportedAnswer(com.cloud.legacymodel.communication.answer.UnsupportedAnswer) GetHostStatsAnswer(com.cloud.legacymodel.communication.answer.GetHostStatsAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) GetGPUStatsAnswer(com.cloud.legacymodel.communication.answer.GetGPUStatsAnswer) MaintainAnswer(com.cloud.legacymodel.communication.answer.MaintainAnswer) UnsupportedAnswer(com.cloud.legacymodel.communication.answer.UnsupportedAnswer) GetGPUStatsAnswer(com.cloud.legacymodel.communication.answer.GetGPUStatsAnswer)

Example 2 with GetGPUStatsCommand

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());
}
Also used : GetGPUStatsCommand(com.cloud.legacymodel.communication.command.GetGPUStatsCommand) Answer(com.cloud.legacymodel.communication.answer.Answer) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) Connection(com.xensource.xenapi.Connection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) Test(org.junit.Test)

Example 3 with GetGPUStatsCommand

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());
}
Also used : GetGPUStatsCommand(com.cloud.legacymodel.communication.command.GetGPUStatsCommand) Answer(com.cloud.legacymodel.communication.answer.Answer) Connection(com.xensource.xenapi.Connection) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) Test(org.junit.Test)

Aggregations

Answer (com.cloud.legacymodel.communication.answer.Answer)3 GetGPUStatsCommand (com.cloud.legacymodel.communication.command.GetGPUStatsCommand)3 Connection (com.xensource.xenapi.Connection)2 XenAPIException (com.xensource.xenapi.Types.XenAPIException)2 XmlRpcException (org.apache.xmlrpc.XmlRpcException)2 Test (org.junit.Test)2 GetGPUStatsAnswer (com.cloud.legacymodel.communication.answer.GetGPUStatsAnswer)1 GetHostStatsAnswer (com.cloud.legacymodel.communication.answer.GetHostStatsAnswer)1 MaintainAnswer (com.cloud.legacymodel.communication.answer.MaintainAnswer)1 UnsupportedAnswer (com.cloud.legacymodel.communication.answer.UnsupportedAnswer)1 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)1