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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations