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);
}
}
}
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());
}
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());
}
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());
}
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());
}
Aggregations