Search in sources :

Example 6 with BrocadeVcsApiException

use of com.cloud.network.brocade.BrocadeVcsApiException in project cloudstack by apache.

the class BrocadeVcsResource method executeRequest.

private Answer executeRequest(DisassociateMacFromNetworkCommand cmd, int numRetries) {
    try {
        String mac = macReformat64To32(cmd.getInterfaceMac());
        boolean result = _brocadeVcsApi.disassociateMacFromNetwork(cmd.getNetworkId(), mac);
        return new DisassociateMacFromNetworkAnswer(cmd, result, "Disassociation of mac " + cmd.getInterfaceMac() + " from network " + cmd.getNetworkId() + " done");
    } catch (BrocadeVcsApiException e) {
        if (numRetries > 0) {
            return retry(cmd, --numRetries);
        } else {
            return new DisassociateMacFromNetworkAnswer(cmd, e);
        }
    }
}
Also used : BrocadeVcsApiException(com.cloud.network.brocade.BrocadeVcsApiException) DisassociateMacFromNetworkAnswer(com.cloud.agent.api.DisassociateMacFromNetworkAnswer)

Example 7 with BrocadeVcsApiException

use of com.cloud.network.brocade.BrocadeVcsApiException in project cloudstack by apache.

the class BrocadeVcsResourceTest method testPingCommandStatusApiException.

@Test
public void testPingCommandStatusApiException() throws ConfigurationException, BrocadeVcsApiException {
    resource.configure("BrocadeVcsResource", parameters);
    when(api.getSwitchStatus()).thenThrow(new BrocadeVcsApiException());
    final PingCommand ping = resource.getCurrentStatus(42);
    assertTrue(ping == null);
}
Also used : BrocadeVcsApiException(com.cloud.network.brocade.BrocadeVcsApiException) PingCommand(com.cloud.agent.api.PingCommand) Test(org.junit.Test)

Example 8 with BrocadeVcsApiException

use of com.cloud.network.brocade.BrocadeVcsApiException in project cloudstack by apache.

the class BrocadeVcsResourceTest method testDisassociateMacFromNetworkApiException.

@Test
public void testDisassociateMacFromNetworkApiException() throws ConfigurationException, BrocadeVcsApiException {
    resource.configure("BrocadeVcsResource", parameters);
    when(api.disassociateMacFromNetwork(NETWORK_ID, MAC_ADDRESS_32)).thenThrow(new BrocadeVcsApiException());
    final DisassociateMacFromNetworkCommand cmd = new DisassociateMacFromNetworkCommand(NETWORK_ID, MAC_ADDRESS_64);
    final DisassociateMacFromNetworkAnswer answer = (DisassociateMacFromNetworkAnswer) resource.executeRequest(cmd);
    assertFalse(answer.getResult());
}
Also used : DisassociateMacFromNetworkCommand(com.cloud.agent.api.DisassociateMacFromNetworkCommand) BrocadeVcsApiException(com.cloud.network.brocade.BrocadeVcsApiException) DisassociateMacFromNetworkAnswer(com.cloud.agent.api.DisassociateMacFromNetworkAnswer) Test(org.junit.Test)

Example 9 with BrocadeVcsApiException

use of com.cloud.network.brocade.BrocadeVcsApiException 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

BrocadeVcsApiException (com.cloud.network.brocade.BrocadeVcsApiException)9 Test (org.junit.Test)6 AssociateMacToNetworkAnswer (com.cloud.agent.api.AssociateMacToNetworkAnswer)2 CreateNetworkAnswer (com.cloud.agent.api.CreateNetworkAnswer)2 CreateNetworkCommand (com.cloud.agent.api.CreateNetworkCommand)2 DisassociateMacFromNetworkAnswer (com.cloud.agent.api.DisassociateMacFromNetworkAnswer)2 PingCommand (com.cloud.agent.api.PingCommand)2 AssociateMacToNetworkCommand (com.cloud.agent.api.AssociateMacToNetworkCommand)1 DeleteNetworkAnswer (com.cloud.agent.api.DeleteNetworkAnswer)1 DeleteNetworkCommand (com.cloud.agent.api.DeleteNetworkCommand)1 DisassociateMacFromNetworkCommand (com.cloud.agent.api.DisassociateMacFromNetworkCommand)1 Output (com.cloud.network.schema.showvcs.Output)1 VcsNodeInfo (com.cloud.network.schema.showvcs.VcsNodeInfo)1