use of com.cloud.network.schema.showvcs.VcsNodeInfo in project cloudstack by apache.
the class BrocadeVcsResourceTest method testPingCommandStatusOk.
@Test
public void testPingCommandStatusOk() throws ConfigurationException, BrocadeVcsApiException {
resource.configure("BrocadeVcsResource", parameters);
final VcsNodeInfo nodeInfo = mock(VcsNodeInfo.class);
when(nodeInfo.getNodeState()).thenReturn("Online");
List<VcsNodeInfo> nodes = new ArrayList<VcsNodeInfo>();
nodes.add(nodeInfo);
final VcsNodes vcsNodes = mock(VcsNodes.class);
final Output output = mock(Output.class);
when(output.getVcsNodes()).thenReturn(vcsNodes);
when(vcsNodes.getVcsNodeInfo()).thenReturn(nodes);
when(api.getSwitchStatus()).thenReturn(output);
final PingCommand ping = resource.getCurrentStatus(42);
assertTrue(ping != null);
assertTrue(ping.getHostId() == 42);
assertTrue(ping.getHostType() == Host.Type.L2Networking);
}
use of com.cloud.network.schema.showvcs.VcsNodeInfo in project cloudstack by apache.
the class BrocadeVcsResourceTest method testPingCommandStatusFail.
@Test
public void testPingCommandStatusFail() throws ConfigurationException, BrocadeVcsApiException {
resource.configure("BrocadeVcsResource", parameters);
final VcsNodeInfo nodeInfo = mock(VcsNodeInfo.class);
when(nodeInfo.getNodeState()).thenReturn("Offline");
List<VcsNodeInfo> nodes = new ArrayList<VcsNodeInfo>();
nodes.add(nodeInfo);
final VcsNodes vcsNodes = mock(VcsNodes.class);
final Output output = mock(Output.class);
when(output.getVcsNodes()).thenReturn(vcsNodes);
when(vcsNodes.getVcsNodeInfo()).thenReturn(nodes);
when(api.getSwitchStatus()).thenReturn(output);
final PingCommand ping = resource.getCurrentStatus(42);
assertTrue(ping == null);
}
use of com.cloud.network.schema.showvcs.VcsNodeInfo in project cloudstack by apache.
the class BrocadeVcsResource method getCurrentStatus.
@Override
public PingCommand getCurrentStatus(long id) {
Output output;
try {
output = _brocadeVcsApi.getSwitchStatus();
} catch (BrocadeVcsApiException e) {
s_logger.error("getSwitchStatus failed", e);
return null;
}
List<VcsNodeInfo> vcsNodes = output.getVcsNodes().getVcsNodeInfo();
if (vcsNodes != null && !vcsNodes.isEmpty()) {
for (VcsNodeInfo vcsNodeInfo : vcsNodes) {
if (!"Online".equals(vcsNodeInfo.getNodeState())) {
s_logger.error("Brocade Switch is not ready: " + id);
return null;
}
}
}
return new PingCommand(Host.Type.L2Networking, id);
}
Aggregations