Search in sources :

Example 1 with PingCommand

use of com.cloud.agent.api.PingCommand in project cloudstack by apache.

the class NuageVspResourceTest method testPingCommandStatus.

@Test
public void testPingCommandStatus() throws Exception {
    _resource.configure("NuageVspResource", _hostDetails);
    PingCommand ping = _resource.getCurrentStatus(42);
    assertNotNull(ping);
    assertEquals(42, ping.getHostId());
    assertEquals(Host.Type.L2Networking, ping.getHostType());
}
Also used : PingCommand(com.cloud.agent.api.PingCommand) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 2 with PingCommand

use of com.cloud.agent.api.PingCommand in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testPingCommandStatusApiException.

@Test
public void testPingCommandStatusApiException() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    ControlClusterStatus ccs = mock(ControlClusterStatus.class);
    when(ccs.getStatus()).thenReturn(false);
    when(_bigswitchBcfApi.getControlClusterStatus()).thenThrow(new BigSwitchBcfApiException());
    PingCommand ping = _resource.getCurrentStatus(42);
    assertTrue(ping == null);
}
Also used : ControlClusterStatus(com.cloud.network.bigswitch.ControlClusterStatus) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) PingCommand(com.cloud.agent.api.PingCommand) Test(org.junit.Test)

Example 3 with PingCommand

use of com.cloud.agent.api.PingCommand in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testPingCommandStatusOk.

@Test
public void testPingCommandStatusOk() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    ControlClusterStatus ccs = mock(ControlClusterStatus.class);
    when(ccs.getStatus()).thenReturn(true);
    when(_bigswitchBcfApi.getControlClusterStatus()).thenReturn(ccs);
    Capabilities cap = mock(Capabilities.class);
    when(_bigswitchBcfApi.getCapabilities()).thenReturn(cap);
    PingCommand ping = _resource.getCurrentStatus(42);
    assertTrue(ping != null);
    assertTrue(ping.getHostId() == 42);
    assertTrue(ping.getHostType() == Host.Type.L2Networking);
}
Also used : ControlClusterStatus(com.cloud.network.bigswitch.ControlClusterStatus) Capabilities(com.cloud.network.bigswitch.Capabilities) PingCommand(com.cloud.agent.api.PingCommand) Test(org.junit.Test)

Example 4 with PingCommand

use of com.cloud.agent.api.PingCommand in project cloudstack by apache.

the class NiciraNvpResourceTest method testPingCommandStatusApiException.

@Test
public void testPingCommandStatusApiException() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    final ControlClusterStatus ccs = mock(ControlClusterStatus.class);
    when(ccs.getClusterStatus()).thenReturn("unstable");
    when(nvpApi.getControlClusterStatus()).thenThrow(new NiciraNvpApiException());
    final PingCommand ping = resource.getCurrentStatus(42);
    assertTrue(ping == null);
}
Also used : ControlClusterStatus(com.cloud.network.nicira.ControlClusterStatus) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) PingCommand(com.cloud.agent.api.PingCommand) Test(org.junit.Test)

Example 5 with PingCommand

use of com.cloud.agent.api.PingCommand in project cloudstack by apache.

the class NiciraNvpResource method getCurrentStatus.

@Override
public PingCommand getCurrentStatus(final long id) {
    try {
        final ControlClusterStatus ccs = niciraNvpApi.getControlClusterStatus();
        getApiProviderMajorityVersion(ccs);
        if (!"stable".equals(ccs.getClusterStatus())) {
            s_logger.error("ControlCluster state is not stable: " + ccs.getClusterStatus());
            return null;
        }
    } catch (final NiciraNvpApiException e) {
        s_logger.error("getControlClusterStatus failed", e);
        return null;
    }
    return new PingCommand(Host.Type.L2Networking, id);
}
Also used : ControlClusterStatus(com.cloud.network.nicira.ControlClusterStatus) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) PingCommand(com.cloud.agent.api.PingCommand)

Aggregations

PingCommand (com.cloud.agent.api.PingCommand)23 Test (org.junit.Test)15 ControlClusterStatus (com.cloud.network.nicira.ControlClusterStatus)8 Answer (com.cloud.agent.api.Answer)4 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)4 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)3 AgentControlCommand (com.cloud.agent.api.AgentControlCommand)3 Command (com.cloud.agent.api.Command)3 CronCommand (com.cloud.agent.api.CronCommand)3 MaintainAnswer (com.cloud.agent.api.MaintainAnswer)3 MaintainCommand (com.cloud.agent.api.MaintainCommand)3 ShutdownCommand (com.cloud.agent.api.ShutdownCommand)3 StartupAnswer (com.cloud.agent.api.StartupAnswer)3 StartupCommand (com.cloud.agent.api.StartupCommand)3 Request (com.cloud.agent.transport.Request)3 Response (com.cloud.agent.transport.Response)3 Output (com.cloud.network.schema.showvcs.Output)3 VcsNodeInfo (com.cloud.network.schema.showvcs.VcsNodeInfo)3 ClosedChannelException (java.nio.channels.ClosedChannelException)3 ReadyCommand (com.cloud.agent.api.ReadyCommand)2