Search in sources :

Example 1 with DeleteLogicalSwitchPortAnswer

use of com.cloud.agent.api.DeleteLogicalSwitchPortAnswer in project cloudstack by apache.

the class NiciraNvpElement method release.

@Override
public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
    if (!canHandle(network, Service.Connectivity)) {
        return false;
    }
    if (network.getBroadcastUri() == null) {
        s_logger.error("Nic has no broadcast Uri with the LSwitch Uuid");
        return false;
    }
    NicVO nicVO = nicDao.findById(nic.getId());
    List<NiciraNvpDeviceVO> devices = niciraNvpDao.listByPhysicalNetwork(network.getPhysicalNetworkId());
    if (devices.isEmpty()) {
        s_logger.error("No NiciraNvp Controller on physical network " + network.getPhysicalNetworkId());
        return false;
    }
    NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
    HostVO niciraNvpHost = hostDao.findById(niciraNvpDevice.getHostId());
    NiciraNvpNicMappingVO nicMap = niciraNvpNicMappingDao.findByNicUuid(nicVO.getUuid());
    if (nicMap == null) {
        s_logger.error("No mapping for nic " + nic.getName());
        return false;
    }
    DeleteLogicalSwitchPortCommand cmd = new DeleteLogicalSwitchPortCommand(nicMap.getLogicalSwitchUuid(), nicMap.getLogicalSwitchPortUuid());
    DeleteLogicalSwitchPortAnswer answer = (DeleteLogicalSwitchPortAnswer) agentMgr.easySend(niciraNvpHost.getId(), cmd);
    if (answer == null || !answer.getResult()) {
        s_logger.error("DeleteLogicalSwitchPortCommand failed");
        return false;
    }
    niciraNvpNicMappingDao.remove(nicMap.getId());
    return true;
}
Also used : NiciraNvpNicMappingVO(com.cloud.network.NiciraNvpNicMappingVO) DeleteLogicalSwitchPortCommand(com.cloud.agent.api.DeleteLogicalSwitchPortCommand) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) DeleteLogicalSwitchPortAnswer(com.cloud.agent.api.DeleteLogicalSwitchPortAnswer) NicVO(com.cloud.vm.NicVO) HostVO(com.cloud.host.HostVO)

Example 2 with DeleteLogicalSwitchPortAnswer

use of com.cloud.agent.api.DeleteLogicalSwitchPortAnswer in project cloudstack by apache.

the class NiciraNvpResourceTest method testDeleteLogicalSwitchPortException.

@Test
public void testDeleteLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    doThrow(new NiciraNvpApiException()).when(nvpApi).deleteLogicalSwitchPort((String) any(), (String) any());
    final DeleteLogicalSwitchPortAnswer dlspa = (DeleteLogicalSwitchPortAnswer) resource.executeRequest(new DeleteLogicalSwitchPortCommand("aaaa", "bbbb"));
    assertFalse(dlspa.getResult());
}
Also used : DeleteLogicalSwitchPortCommand(com.cloud.agent.api.DeleteLogicalSwitchPortCommand) DeleteLogicalSwitchPortAnswer(com.cloud.agent.api.DeleteLogicalSwitchPortAnswer) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) Test(org.junit.Test)

Aggregations

DeleteLogicalSwitchPortAnswer (com.cloud.agent.api.DeleteLogicalSwitchPortAnswer)2 DeleteLogicalSwitchPortCommand (com.cloud.agent.api.DeleteLogicalSwitchPortCommand)2 HostVO (com.cloud.host.HostVO)1 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)1 NiciraNvpNicMappingVO (com.cloud.network.NiciraNvpNicMappingVO)1 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)1 NicVO (com.cloud.vm.NicVO)1 Test (org.junit.Test)1