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