Search in sources :

Example 81 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project cloudstack by apache.

the class VirtualRouterElement method configureDhcpSupport.

protected boolean configureDhcpSupport(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, Service service) throws ResourceUnavailableException {
    if (canHandle(network, service)) {
        if (vm.getType() != VirtualMachine.Type.User) {
            return false;
        }
        final VirtualMachineProfile uservm = vm;
        final List<DomainRouterVO> routers = getRouters(network, dest);
        if (routers == null || routers.size() == 0) {
            throw new ResourceUnavailableException("Can't find at least one router!", DataCenter.class, network.getDataCenterId());
        }
        final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
        return networkTopology.configDhcpForSubnet(network, nic, uservm, dest, routers);
    }
    return false;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkTopology(org.apache.cloudstack.network.topology.NetworkTopology) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 82 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project cloudstack by apache.

the class VirtualRouterElement method completeAggregatedExecution.

@Override
public boolean completeAggregatedExecution(final Network network, final DeployDestination dest) throws ResourceUnavailableException {
    final List<DomainRouterVO> routers = getRouters(network, dest);
    if (routers == null || routers.size() == 0) {
        throw new ResourceUnavailableException("Can't find at least one router!", DataCenter.class, network.getDataCenterId());
    }
    NetworkDetailVO networkDetail = _networkDetailsDao.findDetail(network.getId(), Network.updatingInSequence);
    boolean updateInSequence = "true".equalsIgnoreCase((networkDetail != null ? networkDetail.getValue() : null));
    if (updateInSequence) {
        DomainRouterVO router = routers.get(0);
        router.setUpdateState(VirtualRouter.UpdateState.UPDATE_COMPLETE);
        _routerDao.persist(router);
    }
    boolean result = false;
    try {
        result = _routerMgr.completeAggregatedExecution(network, routers);
    } finally {
        if (!result && updateInSequence) {
            // fail the network update. even if one router fails we fail the network update.
            updateToFailedState(network);
        }
    }
    return result;
}
Also used : ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) NetworkDetailVO(com.cloud.network.dao.NetworkDetailVO) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 83 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project cloudstack by apache.

the class VirtualRouterElement method addPasswordAndUserdata.

@Override
public boolean addPasswordAndUserdata(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
    boolean result = true;
    if (canHandle(network, Service.UserData)) {
        if (vm.getType() != VirtualMachine.Type.User) {
            return false;
        }
        final VirtualMachineProfile uservm = vm;
        List<java.lang.String[]> vmData = uservm.getVmData();
        uservm.setVmData(vmData);
        final List<DomainRouterVO> routers = getRouters(network, dest);
        if (routers == null || routers.size() == 0) {
            throw new ResourceUnavailableException("Can't find at least one router!", DataCenter.class, network.getDataCenterId());
        }
        final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
        for (final DomainRouterVO domainRouterVO : routers) {
            result = result && networkTopology.applyUserData(network, nic, uservm, dest, domainRouterVO);
        }
    }
    return result;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkTopology(org.apache.cloudstack.network.topology.NetworkTopology) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 84 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project cloudstack by apache.

the class VirtualRouterElement method removeDhcpEntry.

@Override
public boolean removeDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vmProfile) throws ResourceUnavailableException {
    boolean result = true;
    if (canHandle(network, Service.Dhcp)) {
        if (vmProfile.getType() != VirtualMachine.Type.User) {
            return false;
        }
        final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), VirtualRouter.Role.VIRTUAL_ROUTER);
        if (CollectionUtils.isEmpty(routers)) {
            throw new ResourceUnavailableException("Can't find at least one router!", DataCenter.class, network.getDataCenterId());
        }
        final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
        for (final DomainRouterVO domainRouterVO : routers) {
            if (domainRouterVO.getState() != VirtualMachine.State.Running) {
                continue;
            }
            result = result && networkTopology.removeDhcpEntry(network, nic, vmProfile, domainRouterVO);
        }
    }
    return result;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkTopology(org.apache.cloudstack.network.topology.NetworkTopology) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 85 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project cloudstack by apache.

the class VirtualRouterElement method prepare.

@Override
public boolean prepare(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
    if (vm.getType() != VirtualMachine.Type.User || vm.getHypervisorType() == HypervisorType.BareMetal) {
        return false;
    }
    if (!canHandle(network, null)) {
        return false;
    }
    final NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
    if (offering.isSystemOnly()) {
        return false;
    }
    if (!_networkMdl.isProviderEnabledInPhysicalNetwork(_networkMdl.getPhysicalNetworkId(network), getProvider().getName())) {
        return false;
    }
    final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create().setGuestNetwork(network).setDeployDestination(dest).setAccountOwner(_accountMgr.getAccount(network.getAccountId())).setParams(vm.getParameters()).build();
    final List<DomainRouterVO> routers = routerDeploymentDefinition.deployVirtualRouter();
    if (routers == null || routers.size() == 0) {
        throw new ResourceUnavailableException("Can't find at least one running router!", DataCenter.class, network.getDataCenterId());
    }
    return true;
}
Also used : RouterDeploymentDefinition(org.cloud.network.router.deployment.RouterDeploymentDefinition) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Aggregations

ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)446 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)191 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)175 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)153 ArrayList (java.util.ArrayList)99 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)91 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)74 Account (com.cloud.user.Account)62 DomainRouterVO (com.cloud.vm.DomainRouterVO)60 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)59 ConfigurationException (javax.naming.ConfigurationException)53 DB (com.cloud.utils.db.DB)52 ServerApiException (org.apache.cloudstack.api.ServerApiException)51 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)47 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)47 ActionEvent (com.cloud.event.ActionEvent)46 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)46 DataCenter (com.cloud.dc.DataCenter)45 ServerApiException (com.cloud.api.ServerApiException)43 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)42