Search in sources :

Example 1 with BrocadeVcsApiException

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

the class BrocadeVcsResource method executeRequest.

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

Example 2 with BrocadeVcsApiException

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

the class BrocadeVcsResourceTest method testAssociateMacToNetworkApiException.

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

Example 3 with BrocadeVcsApiException

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

the class BrocadeVcsResourceTest method testCreateNetworkApiException.

@Test
public void testCreateNetworkApiException() throws ConfigurationException, BrocadeVcsApiException {
    resource.configure("BrocadeVcsResource", parameters);
    when(api.createNetwork(VLAN_ID, NETWORK_ID)).thenThrow(new BrocadeVcsApiException());
    final CreateNetworkCommand cmd = new CreateNetworkCommand(VLAN_ID, NETWORK_ID, "owner");
    final CreateNetworkAnswer answer = (CreateNetworkAnswer) resource.executeRequest(cmd);
    assertFalse(answer.getResult());
}
Also used : CreateNetworkAnswer(com.cloud.agent.api.CreateNetworkAnswer) CreateNetworkCommand(com.cloud.agent.api.CreateNetworkCommand) BrocadeVcsApiException(com.cloud.network.brocade.BrocadeVcsApiException) Test(org.junit.Test)

Example 4 with BrocadeVcsApiException

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

the class BrocadeVcsResourceTest method testRetries.

@Test
public void testRetries() throws ConfigurationException, BrocadeVcsApiException {
    resource.configure("BrocadeVcsResource", parameters);
    when(api.createNetwork(VLAN_ID, NETWORK_ID)).thenThrow(new BrocadeVcsApiException()).thenThrow(new BrocadeVcsApiException()).thenReturn(true);
    final CreateNetworkCommand cmd = new CreateNetworkCommand(VLAN_ID, NETWORK_ID, "owner");
    final CreateNetworkAnswer answer = (CreateNetworkAnswer) resource.executeRequest(cmd);
    assertTrue(answer.getResult());
}
Also used : CreateNetworkAnswer(com.cloud.agent.api.CreateNetworkAnswer) CreateNetworkCommand(com.cloud.agent.api.CreateNetworkCommand) BrocadeVcsApiException(com.cloud.network.brocade.BrocadeVcsApiException) Test(org.junit.Test)

Example 5 with BrocadeVcsApiException

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

the class BrocadeVcsResourceTest method testDeleteNetworkApiException.

@Test
public void testDeleteNetworkApiException() throws ConfigurationException, BrocadeVcsApiException {
    resource.configure("BrocadeVcsResource", parameters);
    when(api.deleteNetwork(VLAN_ID, NETWORK_ID)).thenThrow(new BrocadeVcsApiException());
    final DeleteNetworkCommand cmd = new DeleteNetworkCommand(VLAN_ID, NETWORK_ID);
    final DeleteNetworkAnswer answer = (DeleteNetworkAnswer) resource.executeRequest(cmd);
    assertFalse(answer.getResult());
}
Also used : DeleteNetworkAnswer(com.cloud.agent.api.DeleteNetworkAnswer) DeleteNetworkCommand(com.cloud.agent.api.DeleteNetworkCommand) BrocadeVcsApiException(com.cloud.network.brocade.BrocadeVcsApiException) Test(org.junit.Test)

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