Search in sources :

Example 1 with CleanupPersistentNetworkResourceAnswer

use of com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer 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)

Example 2 with CleanupPersistentNetworkResourceAnswer

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

the class CitrixCleanupPersistentNetworkResourceCommandWrapper method execute.

@Override
public Answer execute(CleanupPersistentNetworkResourceCommand command, CitrixResourceBase citrixResourceBase) {
    final Connection conn = citrixResourceBase.getConnection();
    final XsHost host = citrixResourceBase.getHost();
    NicTO nic = command.getNicTO();
    try {
        Network network = citrixResourceBase.getNetwork(conn, nic);
        if (network == null) {
            return new CleanupPersistentNetworkResourceAnswer(command, false, "Failed to find network on host " + host.getIp() + " to cleanup");
        }
        citrixResourceBase.disableVlanNetwork(conn, network, true);
        return new CleanupPersistentNetworkResourceAnswer(command, true, "Successfully deleted network VLAN on host: " + host.getIp());
    } catch (final Exception e) {
        final String msg = " Failed to cleanup network VLAN on host: " + host.getIp() + " due to: " + e.toString();
        s_logger.error(msg, e);
        return new CleanupPersistentNetworkResourceAnswer(command, false, msg);
    }
}
Also used : XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) CleanupPersistentNetworkResourceAnswer(com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer) Network(com.xensource.xenapi.Network) Connection(com.xensource.xenapi.Connection) NicTO(com.cloud.agent.api.to.NicTO)

Example 3 with CleanupPersistentNetworkResourceAnswer

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

the class LibvirtCleanupPersistentNetworkResourceCommandWrapper method execute.

@Override
public Answer execute(CleanupPersistentNetworkResourceCommand command, LibvirtComputingResource serverResource) {
    NicTO nic = command.getNicTO();
    VifDriver driver = serverResource.getVifDriver(nic.getType());
    if (driver instanceof BridgeVifDriver) {
        driver.deleteBr(nic);
    }
    return new CleanupPersistentNetworkResourceAnswer(command, true, "Successfully deleted bridge");
}
Also used : CleanupPersistentNetworkResourceAnswer(com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer) BridgeVifDriver(com.cloud.hypervisor.kvm.resource.BridgeVifDriver) BridgeVifDriver(com.cloud.hypervisor.kvm.resource.BridgeVifDriver) VifDriver(com.cloud.hypervisor.kvm.resource.VifDriver) NicTO(com.cloud.agent.api.to.NicTO)

Aggregations

CleanupPersistentNetworkResourceAnswer (com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer)3 NicTO (com.cloud.agent.api.to.NicTO)3 CleanupPersistentNetworkResourceCommand (com.cloud.agent.api.CleanupPersistentNetworkResourceCommand)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 BridgeVifDriver (com.cloud.hypervisor.kvm.resource.BridgeVifDriver)1 VifDriver (com.cloud.hypervisor.kvm.resource.VifDriver)1 XsHost (com.cloud.hypervisor.xenserver.resource.XsHost)1 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1