Search in sources :

Example 1 with ControlClusterStatus

use of com.cloud.network.nicira.ControlClusterStatus in project cloudstack by apache.

the class NiciraCheckHealthCommandWrapperTest method tetsExecuteWhenClusterIsStable.

@Test
public void tetsExecuteWhenClusterIsStable() throws Exception {
    final ControlClusterStatus statusValue = mock(ControlClusterStatus.class);
    when(statusValue.getClusterStatus()).thenReturn("stable");
    when(niciraApi.getControlClusterStatus()).thenReturn(statusValue);
    final NiciraCheckHealthCommandWrapper commandWrapper = new NiciraCheckHealthCommandWrapper();
    final Answer answer = commandWrapper.execute(new CheckHealthCommand(), niciraResource);
    assertThat(answer.getResult(), equalTo(true));
}
Also used : ControlClusterStatus(com.cloud.network.nicira.ControlClusterStatus) Answer(com.cloud.agent.api.Answer) CheckHealthCommand(com.cloud.agent.api.CheckHealthCommand) Test(org.junit.Test)

Example 2 with ControlClusterStatus

use of com.cloud.network.nicira.ControlClusterStatus 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 3 with ControlClusterStatus

use of com.cloud.network.nicira.ControlClusterStatus in project cloudstack by apache.

the class NiciraCheckHealthCommandWrapper method execute.

@Override
public Answer execute(final CheckHealthCommand command, final NiciraNvpResource serverResource) {
    final NiciraNvpApi niciraNvpApi = serverResource.getNiciraNvpApi();
    boolean healthy = true;
    try {
        final ControlClusterStatus clusterStatus = niciraNvpApi.getControlClusterStatus();
        final String status = clusterStatus.getClusterStatus();
        if (clusterIsUnstable(status)) {
            s_logger.warn("Control cluster is not stable. Current status is " + status);
            healthy = false;
        }
    } catch (final NiciraNvpApiException e) {
        s_logger.error("Exception caught while checking control cluster status during health check", e);
        healthy = false;
    }
    return new CheckHealthAnswer(command, healthy);
}
Also used : ControlClusterStatus(com.cloud.network.nicira.ControlClusterStatus) CheckHealthAnswer(com.cloud.agent.api.CheckHealthAnswer) NiciraNvpApi(com.cloud.network.nicira.NiciraNvpApi) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException)

Example 4 with ControlClusterStatus

use of com.cloud.network.nicira.ControlClusterStatus 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)

Example 5 with ControlClusterStatus

use of com.cloud.network.nicira.ControlClusterStatus in project cloudstack by apache.

the class NiciraNvpResourceTest method testPingCommandStatusFail.

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

Aggregations

ControlClusterStatus (com.cloud.network.nicira.ControlClusterStatus)7 Test (org.junit.Test)5 PingCommand (com.cloud.agent.api.PingCommand)4 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)3 Answer (com.cloud.agent.api.Answer)2 CheckHealthCommand (com.cloud.agent.api.CheckHealthCommand)2 CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)1 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)1