Search in sources :

Example 1 with CleanupPersistentNetworkResourceCommand

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

the class NetworkOrchestrator method cleanupPersistentnNetworkResources.

private void cleanupPersistentnNetworkResources(NetworkVO network) {
    long networkOfferingId = network.getNetworkOfferingId();
    NetworkOfferingVO offering = _networkOfferingDao.findById(networkOfferingId);
    if (offering != null) {
        if (networkMeetsPersistenceCriteria(network, offering, true) && _networksDao.getOtherPersistentNetworksCount(network.getId(), network.getBroadcastUri().toString(), offering.isPersistent()) == 0) {
            List<HostVO> hosts = resourceManager.listAllUpAndEnabledHostsInOneZoneByType(Host.Type.Routing, network.getDataCenterId());
            for (HostVO host : hosts) {
                try {
                    NicTO to = createNicTOFromNetworkAndOffering(network, offering, host);
                    CleanupPersistentNetworkResourceCommand cmd = new CleanupPersistentNetworkResourceCommand(to);
                    CleanupPersistentNetworkResourceAnswer answer = (CleanupPersistentNetworkResourceAnswer) _agentMgr.send(host.getId(), cmd);
                    if (answer == null) {
                        s_logger.warn("Unable to get an answer to the CleanupPersistentNetworkResourceCommand from agent:" + host.getId());
                        continue;
                    }
                    if (!answer.getResult()) {
                        s_logger.warn("Unable to setup agent " + host.getId() + " due to " + answer.getDetails());
                    }
                } catch (Exception e) {
                    s_logger.warn("Failed to cleanup network resources on host: " + host.getName());
                }
            }
        }
    }
}
Also used : CleanupPersistentNetworkResourceAnswer(com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) HostVO(com.cloud.host.HostVO) CleanupPersistentNetworkResourceCommand(com.cloud.agent.api.CleanupPersistentNetworkResourceCommand) ConnectionException(com.cloud.exception.ConnectionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientVirtualNetworkCapacityException(com.cloud.exception.InsufficientVirtualNetworkCapacityException) ConfigurationException(javax.naming.ConfigurationException) NicTO(com.cloud.agent.api.to.NicTO)

Aggregations

CleanupPersistentNetworkResourceAnswer (com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer)1 CleanupPersistentNetworkResourceCommand (com.cloud.agent.api.CleanupPersistentNetworkResourceCommand)1 NicTO (com.cloud.agent.api.to.NicTO)1 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 ConnectionException (com.cloud.exception.ConnectionException)1 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InsufficientVirtualNetworkCapacityException (com.cloud.exception.InsufficientVirtualNetworkCapacityException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)1 HostVO (com.cloud.host.HostVO)1 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)1 ConfigurationException (javax.naming.ConfigurationException)1