Search in sources :

Example 41 with ExcludeList

use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cosmic by MissionCriticalCloud.

the class ManagementServerImpl method listHostsForMigrationOfVM.

@Override
public Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Host, Boolean>> listHostsForMigrationOfVM(final Long vmId, final Long startIndex, final Long pageSize, final String keyword) {
    final Account caller = getCaller();
    if (!_accountMgr.isRootAdmin(caller.getId())) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Caller is not a root admin, permission denied to migrate the VM");
        }
        throw new PermissionDeniedException("No permission to migrate VM, Only Root Admin can migrate a VM!");
    }
    final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
    if (vm == null) {
        final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the VM with given id");
        throw ex;
    }
    if (vm.getState() != State.Running) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("VM is not running, cannot migrate the vm" + vm);
        }
        final InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Running, cannot " + "migrate the vm with specified id");
        ex.addProxyObject(vm.getUuid(), "vmId");
        throw ex;
    }
    if (_serviceOfferingDetailsDao.findDetail(vm.getServiceOfferingId(), GPU.Keys.pciDevice.toString()) != null) {
        s_logger.info(" Live Migration of GPU enabled VM : " + vm.getInstanceName() + " is not supported");
        // Return empty list.
        return new Ternary<>(new Pair<>(new ArrayList<HostVO>(), new Integer(0)), new ArrayList<>(), new HashMap<>());
    }
    if (!vm.getHypervisorType().equals(HypervisorType.XenServer) && !vm.getHypervisorType().equals(HypervisorType.KVM)) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug(vm + " is not XenServer/KVM, cannot migrate this VM.");
        }
        throw new InvalidParameterValueException("Unsupported Hypervisor Type for VM migration, we support " + "XenServer/KVM only");
    }
    final long srcHostId = vm.getHostId();
    final Host srcHost = _hostDao.findById(srcHostId);
    if (srcHost == null) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Unable to find the host with id: " + srcHostId + " of this VM:" + vm);
        }
        final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the host (with specified id) of VM with specified id");
        ex.addProxyObject(String.valueOf(srcHostId), "hostId");
        ex.addProxyObject(vm.getUuid(), "vmId");
        throw ex;
    }
    // Check if the vm can be migrated with storage.
    boolean canMigrateWithStorage = false;
    if (vm.getType() == VirtualMachine.Type.User) {
        final HypervisorCapabilitiesVO capabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(srcHost.getHypervisorType(), srcHost.getHypervisorVersion());
        if (capabilities != null) {
            canMigrateWithStorage = capabilities.isStorageMotionSupported();
        }
    }
    // Check if the vm is using any disks on local storage.
    final VirtualMachineProfile vmProfile = new VirtualMachineProfileImpl(vm, null, _offeringDao.findById(vm.getId(), vm.getServiceOfferingId()), null, null);
    final List<VolumeVO> volumes = _volumeDao.findCreatedByInstance(vmProfile.getId());
    boolean usesLocal = false;
    for (final VolumeVO volume : volumes) {
        final DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
        final DiskProfile diskProfile = new DiskProfile(volume, diskOffering, vmProfile.getHypervisorType());
        if (diskProfile.useLocalStorage()) {
            usesLocal = true;
            break;
        }
    }
    if (!canMigrateWithStorage && usesLocal) {
        throw new InvalidParameterValueException("Unsupported operation, VM uses Local storage, cannot migrate");
    }
    final Type hostType = srcHost.getType();
    final Pair<List<HostVO>, Integer> allHostsPair;
    final List<HostVO> allHosts;
    final Map<Host, Boolean> requiresStorageMotion = new HashMap<>();
    final DataCenterDeployment plan;
    if (canMigrateWithStorage) {
        allHostsPair = searchForServers(startIndex, pageSize, null, hostType, null, srcHost.getDataCenterId(), null, null, null, keyword, null, null, srcHost.getHypervisorType(), srcHost.getHypervisorVersion());
        allHosts = allHostsPair.first();
        allHosts.remove(srcHost);
        for (final VolumeVO volume : volumes) {
            final Long volClusterId = _poolDao.findById(volume.getPoolId()).getClusterId();
            // only check for volume which are not in zone wide primary store, as only those may require storage motion
            if (volClusterId != null) {
                for (final Iterator<HostVO> iterator = allHosts.iterator(); iterator.hasNext(); ) {
                    final Host host = iterator.next();
                    if (!host.getClusterId().equals(volClusterId) || usesLocal) {
                        if (hasSuitablePoolsForVolume(volume, host, vmProfile)) {
                            requiresStorageMotion.put(host, true);
                        } else {
                            iterator.remove();
                        }
                    }
                }
            }
        }
        plan = new DataCenterDeployment(srcHost.getDataCenterId(), null, null, null, null, null);
    } else {
        final Long cluster = srcHost.getClusterId();
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Searching for all hosts in cluster " + cluster + " for migrating VM " + vm);
        }
        allHostsPair = searchForServers(startIndex, pageSize, null, hostType, null, null, null, cluster, null, keyword, null, null, null, null);
        // Filter out the current host.
        allHosts = allHostsPair.first();
        allHosts.remove(srcHost);
        plan = new DataCenterDeployment(srcHost.getDataCenterId(), srcHost.getPodId(), srcHost.getClusterId(), null, null, null);
    }
    final Pair<List<? extends Host>, Integer> otherHosts = new Pair<>(allHosts, new Integer(allHosts.size()));
    List<Host> suitableHosts = new ArrayList<>();
    final ExcludeList excludes = new ExcludeList();
    excludes.addHost(srcHostId);
    // call affinitygroup chain
    final long vmGroupCount = _affinityGroupVMMapDao.countAffinityGroupsForVm(vm.getId());
    if (vmGroupCount > 0) {
        for (final AffinityGroupProcessor processor : _affinityProcessors) {
            processor.process(vmProfile, plan, excludes);
        }
    }
    final Account account = vmProfile.getOwner();
    for (final HostVO host : allHosts) {
        final DedicatedResourceVO dedicatedResourceVO = dedicatedResourceDao.findByHostId(host.getId());
        if (dedicatedResourceVO != null && dedicatedResourceVO.getDomainId() != account.getDomainId()) {
            final Domain domain = _domainDao.findById(dedicatedResourceVO.getDomainId());
            if (domain != null) {
                s_logger.debug("Host " + host.getName() + " is dedicated to domain " + domain.getName() + " so not suitable for migration for VM " + vmProfile.getInstanceName());
            }
            excludes.addHost(host.getId());
        }
    }
    for (final HostAllocator allocator : hostAllocators) {
        if (canMigrateWithStorage) {
            suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, allHosts, HostAllocator.RETURN_UPTO_ALL, false);
        } else {
            suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, HostAllocator.RETURN_UPTO_ALL, false);
        }
        if (suitableHosts != null && !suitableHosts.isEmpty()) {
            break;
        }
    }
    if (s_logger.isDebugEnabled()) {
        if (suitableHosts.isEmpty()) {
            s_logger.debug("No suitable hosts found");
        } else {
            s_logger.debug("Hosts having capacity and suitable for migration: " + suitableHosts);
        }
    }
    return new Ternary<>(otherHosts, suitableHosts, requiresStorageMotion);
}
Also used : HypervisorCapabilitiesVO(com.cloud.hypervisor.HypervisorCapabilitiesVO) Account(com.cloud.user.Account) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HostAllocator(com.cloud.agent.manager.allocator.HostAllocator) VolumeVO(com.cloud.storage.VolumeVO) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) ArrayList(java.util.ArrayList) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) List(java.util.List) AffinityGroupProcessor(com.cloud.affinity.AffinityGroupProcessor) Pair(com.cloud.utils.Pair) SSHKeyPair(com.cloud.user.SSHKeyPair) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) Ternary(com.cloud.utils.Ternary) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) VMInstanceVO(com.cloud.vm.VMInstanceVO) Host(com.cloud.host.Host) DiskProfile(com.cloud.vm.DiskProfile) HostVO(com.cloud.host.HostVO) ResourceObjectType(com.cloud.server.ResourceTag.ResourceObjectType) VlanType(com.cloud.dc.Vlan.VlanType) JoinType(com.cloud.utils.db.JoinBuilder.JoinType) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) Type(com.cloud.host.Host.Type) PermissionDeniedException(com.cloud.exception.PermissionDeniedException) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO) Domain(com.cloud.domain.Domain)

Example 42 with ExcludeList

use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cosmic by MissionCriticalCloud.

the class ManagementServerImpl method listStoragePoolsForMigrationOfVolume.

@Override
public Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolume(final Long volumeId) {
    final Account caller = getCaller();
    if (!_accountMgr.isRootAdmin(caller.getId())) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Caller is not a root admin, permission denied to migrate the volume");
        }
        throw new PermissionDeniedException("No permission to migrate volume, only root admin can migrate a volume");
    }
    final VolumeVO volume = _volumeDao.findById(volumeId);
    if (volume == null) {
        final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find volume with" + " specified id.");
        ex.addProxyObject(volumeId.toString(), "volumeId");
        throw ex;
    }
    // Volume must be attached to an instance for live migration.
    final List<StoragePool> allPools = new ArrayList<>();
    final List<StoragePool> suitablePools = new ArrayList<>();
    // Volume must be in Ready state to be migrated.
    if (!Volume.State.Ready.equals(volume.getState())) {
        s_logger.info("Volume " + volume + " must be in ready state for migration.");
        return new Pair<>(allPools, suitablePools);
    }
    if (!_volumeMgr.volumeOnSharedStoragePool(volume)) {
        s_logger.info("Volume " + volume + " is on local storage. It cannot be migrated to another pool.");
        return new Pair<>(allPools, suitablePools);
    }
    final Long instanceId = volume.getInstanceId();
    VMInstanceVO vm = null;
    if (instanceId != null) {
        vm = _vmInstanceDao.findById(instanceId);
    }
    if (vm == null) {
        s_logger.info("Volume " + volume + " isn't attached to any vm. Looking for storage pools in the " + "zone to which this volumes can be migrated.");
    } else if (vm.getState() != State.Running) {
        s_logger.info("Volume " + volume + " isn't attached to any running vm. Looking for storage pools in the " + "cluster to which this volumes can be migrated.");
    } else {
        s_logger.info("Volume " + volume + " is attached to any running vm. Looking for storage pools in the " + "cluster to which this volumes can be migrated.");
        boolean storageMotionSupported = false;
        // Check if the underlying hypervisor supports storage motion.
        final Long hostId = vm.getHostId();
        if (hostId != null) {
            final HostVO host = _hostDao.findById(hostId);
            HypervisorCapabilitiesVO capabilities = null;
            if (host != null) {
                capabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(host.getHypervisorType(), host.getHypervisorVersion());
            } else {
                s_logger.error("Details of the host on which the vm " + vm + ", to which volume " + volume + " is " + "attached, couldn't be retrieved.");
            }
            if (capabilities != null) {
                storageMotionSupported = capabilities.isStorageMotionSupported();
            } else {
                s_logger.error("Capabilities for host " + host + " couldn't be retrieved.");
            }
        }
        if (!storageMotionSupported) {
            s_logger.info("Volume " + volume + " is attached to a running vm and the hypervisor doesn't support" + " storage motion.");
            return new Pair<>(allPools, suitablePools);
        }
    }
    // Source pool of the volume.
    final StoragePoolVO srcVolumePool = _poolDao.findById(volume.getPoolId());
    // Get all the pools available. Only shared pools are considered because only a volume on a shared pools
    // can be live migrated while the virtual machine stays on the same host.
    final List<StoragePoolVO> storagePools;
    if (srcVolumePool.getClusterId() == null) {
        storagePools = _poolDao.findZoneWideStoragePoolsByTags(volume.getDataCenterId(), null);
    } else {
        storagePools = _poolDao.findPoolsByTags(volume.getDataCenterId(), srcVolumePool.getPodId(), srcVolumePool.getClusterId(), null);
    }
    storagePools.remove(srcVolumePool);
    for (final StoragePoolVO pool : storagePools) {
        if (pool.isShared()) {
            allPools.add((StoragePool) dataStoreMgr.getPrimaryDataStore(pool.getId()));
        }
    }
    // Get all the suitable pools.
    // Exclude the current pool from the list of pools to which the volume can be migrated.
    final ExcludeList avoid = new ExcludeList();
    avoid.addPool(srcVolumePool.getId());
    // Volume stays in the same cluster after migration.
    final DataCenterDeployment plan = new DataCenterDeployment(volume.getDataCenterId(), srcVolumePool.getPodId(), srcVolumePool.getClusterId(), null, null, null);
    final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
    final DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
    final DiskProfile diskProfile = new DiskProfile(volume, diskOffering, profile.getHypervisorType());
    // Call the storage pool allocator to find the list of storage pools.
    for (final StoragePoolAllocator allocator : _storagePoolAllocators) {
        final List<StoragePool> pools = allocator.allocateToPool(diskProfile, profile, plan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
        if (pools != null && !pools.isEmpty()) {
            suitablePools.addAll(pools);
            break;
        }
    }
    return new Pair<>(allPools, suitablePools);
}
Also used : HypervisorCapabilitiesVO(com.cloud.hypervisor.HypervisorCapabilitiesVO) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) Account(com.cloud.user.Account) StoragePool(com.cloud.storage.StoragePool) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) ArrayList(java.util.ArrayList) VMInstanceVO(com.cloud.vm.VMInstanceVO) DiskProfile(com.cloud.vm.DiskProfile) HostVO(com.cloud.host.HostVO) VolumeVO(com.cloud.storage.VolumeVO) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) PermissionDeniedException(com.cloud.exception.PermissionDeniedException) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) StoragePoolAllocator(com.cloud.engine.subsystem.api.storage.StoragePoolAllocator) Pair(com.cloud.utils.Pair) SSHKeyPair(com.cloud.user.SSHKeyPair)

Example 43 with ExcludeList

use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cloudstack by apache.

the class DeploymentPlanningManagerImpl method findPotentialDeploymentResources.

protected Pair<Host, Map<Volume, StoragePool>> findPotentialDeploymentResources(List<Host> suitableHosts, Map<Volume, List<StoragePool>> suitableVolumeStoragePools, ExcludeList avoid, DeploymentPlanner.PlannerResourceUsage resourceUsageRequired, List<Volume> readyAndReusedVolumes) {
    s_logger.debug("Trying to find a potenial host and associated storage pools from the suitable host/pool lists for this VM");
    boolean hostCanAccessPool = false;
    boolean haveEnoughSpace = false;
    if (readyAndReusedVolumes == null) {
        readyAndReusedVolumes = new ArrayList<Volume>();
    }
    Map<Volume, StoragePool> storage = new HashMap<Volume, StoragePool>();
    TreeSet<Volume> volumesOrderBySizeDesc = new TreeSet<Volume>(new Comparator<Volume>() {

        @Override
        public int compare(Volume v1, Volume v2) {
            if (v1.getSize() < v2.getSize())
                return 1;
            else
                return -1;
        }
    });
    volumesOrderBySizeDesc.addAll(suitableVolumeStoragePools.keySet());
    boolean multipleVolume = volumesOrderBySizeDesc.size() > 1;
    for (Host potentialHost : suitableHosts) {
        Map<StoragePool, List<Volume>> volumeAllocationMap = new HashMap<StoragePool, List<Volume>>();
        for (Volume vol : volumesOrderBySizeDesc) {
            haveEnoughSpace = false;
            s_logger.debug("Checking if host: " + potentialHost.getId() + " can access any suitable storage pool for volume: " + vol.getVolumeType());
            List<StoragePool> volumePoolList = suitableVolumeStoragePools.get(vol);
            hostCanAccessPool = false;
            for (StoragePool potentialSPool : volumePoolList) {
                if (hostCanAccessSPool(potentialHost, potentialSPool)) {
                    hostCanAccessPool = true;
                    if (multipleVolume && !readyAndReusedVolumes.contains(vol)) {
                        List<Volume> requestVolumes = null;
                        if (volumeAllocationMap.containsKey(potentialSPool))
                            requestVolumes = volumeAllocationMap.get(potentialSPool);
                        else
                            requestVolumes = new ArrayList<Volume>();
                        requestVolumes.add(vol);
                        if (!_storageMgr.storagePoolHasEnoughIops(requestVolumes, potentialSPool) || !_storageMgr.storagePoolHasEnoughSpace(requestVolumes, potentialSPool, potentialHost.getClusterId()))
                            continue;
                        volumeAllocationMap.put(potentialSPool, requestVolumes);
                    }
                    storage.put(vol, potentialSPool);
                    haveEnoughSpace = true;
                    break;
                }
            }
            if (!hostCanAccessPool) {
                break;
            }
            if (!haveEnoughSpace) {
                s_logger.warn("insufficient capacity to allocate all volumes");
                break;
            }
        }
        if (hostCanAccessPool && haveEnoughSpace && checkIfHostFitsPlannerUsage(potentialHost.getId(), resourceUsageRequired)) {
            s_logger.debug("Found a potential host " + "id: " + potentialHost.getId() + " name: " + potentialHost.getName() + " and associated storage pools for this VM");
            return new Pair<Host, Map<Volume, StoragePool>>(potentialHost, storage);
        } else {
            avoid.addHost(potentialHost.getId());
        }
    }
    s_logger.debug("Could not find a potential host that has associated storage pools from the suitable host/pool lists for this VM");
    return null;
}
Also used : StoragePool(com.cloud.storage.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Host(com.cloud.host.Host) Volume(com.cloud.storage.Volume) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) List(java.util.List) Pair(com.cloud.utils.Pair)

Example 44 with ExcludeList

use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cosmic by MissionCriticalCloud.

the class ManagementServerImpl method hasSuitablePoolsForVolume.

private boolean hasSuitablePoolsForVolume(final VolumeVO volume, final Host host, final VirtualMachineProfile vmProfile) {
    final DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
    final DiskProfile diskProfile = new DiskProfile(volume, diskOffering, vmProfile.getHypervisorType());
    final DataCenterDeployment plan = new DataCenterDeployment(host.getDataCenterId(), host.getPodId(), host.getClusterId(), host.getId(), null, null);
    final ExcludeList avoid = new ExcludeList();
    for (final StoragePoolAllocator allocator : _storagePoolAllocators) {
        final List<StoragePool> poolList = allocator.allocateToPool(diskProfile, vmProfile, plan, avoid, 1);
        if (poolList != null && !poolList.isEmpty()) {
            return true;
        }
    }
    return false;
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) StoragePool(com.cloud.storage.StoragePool) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) DiskProfile(com.cloud.vm.DiskProfile) StoragePoolAllocator(com.cloud.engine.subsystem.api.storage.StoragePoolAllocator)

Example 45 with ExcludeList

use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cosmic by MissionCriticalCloud.

the class NetworkHelperImpl method startVirtualRouter.

@Override
public DomainRouterVO startVirtualRouter(final DomainRouterVO router, final User user, final Account caller, final Map<Param, Object> params) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
    logger.info("Starting Virtual Router {}", router);
    if (router.getRole() != Role.VIRTUAL_ROUTER || !router.getIsRedundantRouter()) {
        logger.debug("Will start to deploy router {} without any avoidance rules", router);
        return start(router, params, null);
    }
    if (router.getState() == State.Running) {
        logger.debug("Redundant router {} is already running!", router);
        return router;
    }
    // We will wait until VR is up or fail
    if (router.getState() == State.Starting) {
        return waitRouter(router);
    }
    final DataCenterDeployment plan = new DataCenterDeployment(0, null, null, null, null, null);
    final List<Long> networkIds = _routerDao.getRouterNetworks(router.getId());
    DomainRouterVO routerToBeAvoid = null;
    List<DomainRouterVO> routerList = null;
    if (router.getVpcId() != null) {
        routerList = _routerDao.listByVpcId(router.getVpcId());
    } else if (networkIds.size() != 0) {
        routerList = _routerDao.findByNetwork(networkIds.get(0));
    }
    if (routerList != null) {
        for (final DomainRouterVO rrouter : routerList) {
            if (rrouter.getHostId() != null && rrouter.getIsRedundantRouter() && rrouter.getState() == State.Running) {
                if (routerToBeAvoid != null) {
                    throw new ResourceUnavailableException("Try to start router " + router.getInstanceName() + "(" + router.getId() + ")" + ", but there are already two redundant routers with IP " + router.getPublicIpAddress() + ", they are " + rrouter.getInstanceName() + "(" + rrouter.getId() + ") and " + routerToBeAvoid.getInstanceName() + "(" + routerToBeAvoid.getId() + ")", DataCenter.class, rrouter.getDataCenterId());
                }
                routerToBeAvoid = rrouter;
            }
        }
    }
    if (routerToBeAvoid == null) {
        logger.debug("Will start to deploy router {} without any avoidance rules (no router to be avoided)", router);
        return start(router, params, null);
    }
    // We would try best to deploy the router to another place
    final int retryIndex = 5;
    final ExcludeList[] avoids = getExcludeLists(routerToBeAvoid, retryIndex);
    logger.debug("Will start to deploy router {} with the most strict avoidance rules first (total number of attempts = {})", router, retryIndex);
    DomainRouterVO result = null;
    for (int i = 0; i < retryIndex; i++) {
        plan.setAvoids(avoids[i]);
        try {
            logger.debug("Starting router {} while trying to {}", router, avoids[i]);
            result = start(router, params, plan);
        } catch (final CloudException | CloudRuntimeException e) {
            logger.debug("Failed to start virtual router {} while trying to {} ({} attempts to go)", avoids[i], retryIndex - i);
            result = null;
        }
        if (result != null) {
            break;
        }
    }
    return result;
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) CloudException(com.cloud.exception.CloudException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Aggregations

ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)78 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)45 ArrayList (java.util.ArrayList)32 StoragePool (com.cloud.storage.StoragePool)30 Test (org.junit.Test)30 HashMap (java.util.HashMap)23 Volume (com.cloud.storage.Volume)21 VirtualMachineProfileImpl (com.cloud.vm.VirtualMachineProfileImpl)18 List (java.util.List)18 Host (com.cloud.host.Host)16 HostVO (com.cloud.host.HostVO)16 Pair (com.cloud.utils.Pair)16 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)16 DiskProfile (com.cloud.vm.DiskProfile)15 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)15 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)14 VolumeVO (com.cloud.storage.VolumeVO)14 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)14 Account (com.cloud.user.Account)12 Map (java.util.Map)11