Search in sources :

Example 1 with VcsNodes

use of com.cloud.network.schema.showvcs.VcsNodes 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 VcsNodes

use of com.cloud.network.schema.showvcs.VcsNodes 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)

Aggregations

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