Search in sources :

Example 1 with DisassociateMacFromNetworkCommand

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());
}
Also used : DisassociateMacFromNetworkCommand(com.cloud.agent.api.DisassociateMacFromNetworkCommand) DisassociateMacFromNetworkAnswer(com.cloud.agent.api.DisassociateMacFromNetworkAnswer) Test(org.junit.Test)

Example 2 with DisassociateMacFromNetworkCommand

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);
}
Also used : DisassociateMacFromNetworkCommand(com.cloud.agent.api.DisassociateMacFromNetworkCommand) DisassociateMacFromNetworkAnswer(com.cloud.agent.api.DisassociateMacFromNetworkAnswer) HostVO(com.cloud.host.HostVO) BrocadeVcsDeviceVO(com.cloud.network.BrocadeVcsDeviceVO)

Example 3 with DisassociateMacFromNetworkCommand

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());
}
Also used : DisassociateMacFromNetworkCommand(com.cloud.agent.api.DisassociateMacFromNetworkCommand) BrocadeVcsApiException(com.cloud.network.brocade.BrocadeVcsApiException) DisassociateMacFromNetworkAnswer(com.cloud.agent.api.DisassociateMacFromNetworkAnswer) Test(org.junit.Test)

Aggregations

DisassociateMacFromNetworkAnswer (com.cloud.agent.api.DisassociateMacFromNetworkAnswer)3 DisassociateMacFromNetworkCommand (com.cloud.agent.api.DisassociateMacFromNetworkCommand)3 Test (org.junit.Test)2 HostVO (com.cloud.host.HostVO)1 BrocadeVcsDeviceVO (com.cloud.network.BrocadeVcsDeviceVO)1 BrocadeVcsApiException (com.cloud.network.brocade.BrocadeVcsApiException)1