Search in sources :

Example 1 with DestroyPortCommand

use of org.apache.cloudstack.network.opendaylight.agent.commands.DestroyPortCommand in project cloudstack by apache.

the class OpendaylightGuestNetworkGuru method release.

@Override
public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) {
    boolean success = super.release(nic, vm, reservationId);
    if (success) {
        //get physical network id
        NetworkVO network = _networkDao.findById(nic.getNetworkId());
        Long physicalNetworkId = network.getPhysicalNetworkId();
        List<OpenDaylightControllerVO> devices = openDaylightControllerMappingDao.listByPhysicalNetwork(physicalNetworkId);
        if (devices.isEmpty()) {
            s_logger.error("No Controller on physical network " + physicalNetworkId);
            throw new CloudRuntimeException("No OpenDaylight controller on this physical network");
        }
        OpenDaylightControllerVO controller = devices.get(0);
        DestroyPortCommand cmd = new DestroyPortCommand(UUID.fromString(nic.getUuid()));
        DestroyPortAnswer answer = (DestroyPortAnswer) agentManager.easySend(controller.getHostId(), cmd);
        if (answer == null || !answer.getResult()) {
            s_logger.error("DestroyPortCommand failed");
            success = false;
        }
    }
    return success;
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DestroyPortCommand(org.apache.cloudstack.network.opendaylight.agent.commands.DestroyPortCommand) DestroyPortAnswer(org.apache.cloudstack.network.opendaylight.agent.responses.DestroyPortAnswer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) OpenDaylightControllerVO(org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO)

Aggregations

NetworkVO (com.cloud.network.dao.NetworkVO)1 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 DestroyPortCommand (org.apache.cloudstack.network.opendaylight.agent.commands.DestroyPortCommand)1 DestroyPortAnswer (org.apache.cloudstack.network.opendaylight.agent.responses.DestroyPortAnswer)1 OpenDaylightControllerVO (org.apache.cloudstack.network.opendaylight.dao.OpenDaylightControllerVO)1