use of com.cloud.agent.api.DisassociateMacFromNetworkCommand in project cloudstack by apache.
the class BrocadeVcsResourceTest method testDisassociateMacFromNetworkApi.
@Test
public void testDisassociateMacFromNetworkApi() throws ConfigurationException, BrocadeVcsApiException {
resource.configure("BrocadeVcsResource", parameters);
when(api.disassociateMacFromNetwork(NETWORK_ID, MAC_ADDRESS_32)).thenReturn(true);
final DisassociateMacFromNetworkCommand cmd = new DisassociateMacFromNetworkCommand(NETWORK_ID, MAC_ADDRESS_64);
final DisassociateMacFromNetworkAnswer answer = (DisassociateMacFromNetworkAnswer) resource.executeRequest(cmd);
assertTrue(answer.getResult());
}
use of com.cloud.agent.api.DisassociateMacFromNetworkCommand in project cloudstack by apache.
the class BrocadeVcsGuestNetworkGuru method deallocate.
@Override
public void deallocate(Network network, NicProfile nic, VirtualMachineProfile vm) {
String interfaceMac = nic.getMacAddress();
List<BrocadeVcsDeviceVO> devices = _brocadeVcsDao.listByPhysicalNetwork(network.getPhysicalNetworkId());
if (devices.isEmpty()) {
s_logger.error("No Brocade VCS Switch on physical network " + network.getPhysicalNetworkId());
return;
}
for (BrocadeVcsDeviceVO brocadeVcsDevice : devices) {
HostVO brocadeVcsHost = _hostDao.findById(brocadeVcsDevice.getHostId());
// create DisassociateMacFromNetworkCmd instance and agentMgr execute it.
DisassociateMacFromNetworkCommand cmd = new DisassociateMacFromNetworkCommand(network.getId(), interfaceMac);
DisassociateMacFromNetworkAnswer answer = (DisassociateMacFromNetworkAnswer) _agentMgr.easySend(brocadeVcsHost.getId(), cmd);
if (answer == null || !answer.getResult()) {
s_logger.error("DisassociateMacFromNetworkCommand failed");
s_logger.error("Unable to disassociate mac " + interfaceMac + " from network " + network.getId());
return;
}
}
super.deallocate(network, nic, vm);
}
use of com.cloud.agent.api.DisassociateMacFromNetworkCommand 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());
}
Aggregations