Search in sources :

Example 1 with VcsNodeInfo

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);
}
Also used : VcsNodes(com.cloud.network.schema.showvcs.VcsNodes) Output(com.cloud.network.schema.showvcs.Output) VcsNodeInfo(com.cloud.network.schema.showvcs.VcsNodeInfo) ArrayList(java.util.ArrayList) PingCommand(com.cloud.agent.api.PingCommand) Test(org.junit.Test)

Example 2 with VcsNodeInfo

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);
}
Also used : VcsNodes(com.cloud.network.schema.showvcs.VcsNodes) Output(com.cloud.network.schema.showvcs.Output) VcsNodeInfo(com.cloud.network.schema.showvcs.VcsNodeInfo) ArrayList(java.util.ArrayList) PingCommand(com.cloud.agent.api.PingCommand) Test(org.junit.Test)

Example 3 with VcsNodeInfo

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);
}
Also used : Output(com.cloud.network.schema.showvcs.Output) VcsNodeInfo(com.cloud.network.schema.showvcs.VcsNodeInfo) BrocadeVcsApiException(com.cloud.network.brocade.BrocadeVcsApiException) PingCommand(com.cloud.agent.api.PingCommand)

Aggregations

PingCommand (com.cloud.agent.api.PingCommand)3 Output (com.cloud.network.schema.showvcs.Output)3 VcsNodeInfo (com.cloud.network.schema.showvcs.VcsNodeInfo)3 VcsNodes (com.cloud.network.schema.showvcs.VcsNodes)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 BrocadeVcsApiException (com.cloud.network.brocade.BrocadeVcsApiException)1