Search in sources :

Example 76 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class ExistingPoolModelBehavior method postInitStorageDomains.

@Override
protected void postInitStorageDomains() {
    ArrayList<DiskModel> disks = (ArrayList<DiskModel>) getModel().getDisks();
    if (disks == null) {
        return;
    }
    ActionGroup actionGroup = getModel().isCreateInstanceOnly() ? ActionGroup.CREATE_INSTANCE : ActionGroup.CREATE_VM;
    StoragePool dataCenter = getModel().getSelectedDataCenter();
    AsyncDataProvider.getInstance().getPermittedStorageDomainsByStoragePoolId(asyncQuery(storageDomains -> {
        ArrayList<DiskModel> disks1 = (ArrayList<DiskModel>) getModel().getDisks();
        ArrayList<StorageDomain> activeStorageDomains = filterStorageDomains(storageDomains);
        DisksAllocationModel disksAllocationModel = getModel().getDisksAllocationModel();
        disksAllocationModel.setActiveStorageDomains(activeStorageDomains);
        getModel().getStorageDomain().setItems(activeStorageDomains);
        for (DiskModel diskModel : disks1) {
            // Setting Quota
            diskModel.getQuota().setItems(getModel().getQuota().getItems());
            diskModel.getQuota().setIsChangeable(false);
            List<Guid> storageIds = ((DiskImage) diskModel.getDisk()).getStorageIds();
            for (DiskImage disk : pool.getDiskList()) {
                if (diskModel.getDisk() instanceof DiskImage && ((DiskImage) diskModel.getDisk()).getImageId().equals(disk.getImageTemplateId())) {
                    storageIds = new ArrayList<>(disk.getStorageIds());
                    break;
                }
            }
            if (storageIds == null || storageIds.size() == 0) {
                continue;
            }
            Guid storageId = storageIds.get(0);
            StorageDomain storageDomain = activeStorageDomains.stream().filter(new Linq.IdPredicate<>(storageId)).findFirst().orElse(null);
            List<StorageDomain> diskStorageDomains = new ArrayList<>();
            diskStorageDomains.add(storageDomain);
            diskModel.getStorageDomain().setItems(diskStorageDomains);
            diskModel.getStorageDomain().setIsChangeable(false);
        }
    }), dataCenter.getId(), actionGroup);
    getModel().getDisksAllocationModel().initializeAutoSelectTarget(false, actualPool.isAutoStorageSelect());
}
Also used : VmPool(org.ovirt.engine.core.common.businessentities.VmPool) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Guid(org.ovirt.engine.core.compat.Guid) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StringHelper(org.ovirt.engine.core.compat.StringHelper) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) ExistingPoolInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.ExistingPoolInstanceTypeManager) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) ExistingPoolNameLengthValidation(org.ovirt.engine.ui.uicommonweb.validation.ExistingPoolNameLengthValidation) LatestVmTemplate(org.ovirt.engine.ui.uicommonweb.models.templates.LatestVmTemplate) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisksAllocationModel(org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) DisksAllocationModel(org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) ArrayList(java.util.ArrayList) List(java.util.List) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 77 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class ExistingVmModelBehavior method loadDataCenter.

private void loadDataCenter() {
    // Preinitialize the VM compatibility version because it's needed during init
    Version newCustomCompatibilityVersion = ((ExistingVmModelBehavior) getModel().getBehavior()).getVm().getStaticData().getCustomCompatibilityVersion();
    if (newCustomCompatibilityVersion != null) {
        getModel().getCustomCompatibilityVersion().setItems(Collections.singletonList(newCustomCompatibilityVersion), newCustomCompatibilityVersion);
    }
    AsyncDataProvider.getInstance().getDataCenterById(asyncQuery(dataCenter -> {
        if (dataCenter != null) {
            final List<StoragePool> dataCenters = new ArrayList<>(Arrays.asList(new StoragePool[] { dataCenter }));
            initClusters(dataCenters);
        } else {
            ExistingVmModelBehavior behavior = (ExistingVmModelBehavior) getModel().getBehavior();
            VM currentVm = behavior.vm;
            Cluster cluster = new Cluster();
            cluster.setId(currentVm.getClusterId());
            cluster.setName(currentVm.getClusterName());
            cluster.setCompatibilityVersion(currentVm.getClusterCompatibilityVersion());
            cluster.setStoragePoolId(currentVm.getStoragePoolId());
            DataCenterWithCluster dataCenterWithCluster = new DataCenterWithCluster(null, cluster);
            getModel().getDataCenterWithClustersList().setItems(Arrays.asList(dataCenterWithCluster));
            getModel().getDataCenterWithClustersList().setSelectedItem(dataCenterWithCluster);
            behavior.initTemplate();
            behavior.updateCdImage();
        }
    }), vm.getStoragePoolId());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) Guid(org.ovirt.engine.core.compat.Guid) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) CommentVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommentVmBaseToUnitBuilder) Map(java.util.Map) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Version(org.ovirt.engine.core.compat.Version) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) EnumSet(java.util.EnumSet) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmActionByVmOriginTypeValidator(org.ovirt.engine.core.common.validation.VmActionByVmOriginTypeValidator) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) CommonCompatibilityVersionUtils(org.ovirt.engine.core.common.utils.CommonCompatibilityVersionUtils) ExistingVmInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.ExistingVmInstanceTypeManager) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ArrayList(java.util.ArrayList) List(java.util.List)

Example 78 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class TemplateVmModelBehavior method initialize.

@Override
public void initialize() {
    super.initialize();
    getModel().getTemplateWithVersion().setIsChangeable(false);
    getModel().getBaseTemplate().setIsChangeable(false);
    getModel().getTemplateWithVersion().setIsChangeable(false);
    getModel().getProvisioning().setIsChangeable(false);
    getModel().getStorageDomain().setIsChangeable(false);
    getModel().getIsSoundcardEnabled().setIsChangeable(true);
    getModel().getVmType().setIsChangeable(true);
    getModel().getTemplateVersionName().setIsChangeable(!template.isBaseTemplate());
    getModel().getName().setIsChangeable(template.isBaseTemplate());
    if (template.getStoragePoolId() != null && !template.getStoragePoolId().equals(Guid.Empty)) {
        AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(dataCenter -> AsyncDataProvider.getInstance().getClusterListByService(new AsyncQuery<>(clusters -> {
            ArrayList<Cluster> clustersSupportingVirt = new ArrayList<>();
            // filter clusters supporting virt service only
            for (Cluster cluster : clusters) {
                if (cluster.supportsVirtService()) {
                    clustersSupportingVirt.add(cluster);
                }
            }
            List<Cluster> filteredClusters = AsyncDataProvider.getInstance().filterByArchitecture(clustersSupportingVirt, template.getClusterArch());
            getModel().setDataCentersAndClusters(getModel(), new ArrayList<>(Arrays.asList(new StoragePool[] { dataCenter })), filteredClusters, template.getClusterId());
            updateRngDevice(template.getId());
            AsyncDataProvider.getInstance().isSoundcardEnabled(new AsyncQuery<>(returnValue -> {
                getModel().getIsSoundcardEnabled().setEntity(returnValue);
                initTemplate();
                initCdImage();
            }), template.getId());
            Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(template.getId()), new AsyncQuery<>((QueryReturnValue returnValue) -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
            AsyncDataProvider.getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), template.getId());
        }), true, false)), template.getStoragePoolId());
    }
    AsyncDataProvider.getInstance().getWatchdogByVmId(new AsyncQuery<>((AsyncCallback<QueryReturnValue>) returnValue -> {
        UnitVmModel model = getModel();
        @SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
        for (VmWatchdog watchdog : watchdogs) {
            model.getWatchdogAction().setSelectedItem(watchdog.getAction());
            model.getWatchdogModel().setSelectedItem(watchdog.getModel());
        }
    }), template.getId());
    getModel().getMigrationMode().setSelectedItem(template.getMigrationSupport());
    setupBaseTemplate(template.getBaseTemplateId());
}
Also used : DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) CommentVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommentVmBaseToUnitBuilder) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Collections(java.util.Collections) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) ArrayList(java.util.ArrayList) List(java.util.List)

Example 79 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class UpdateClusterCommand method validate.

@Override
protected boolean validate() {
    boolean result = true;
    boolean hasVms = false;
    boolean hasVmOrHost = false;
    boolean sameCpuNames = false;
    boolean allVdssInMaintenance = false;
    List<VM> vmList = null;
    if (oldCluster == null) {
        addValidationMessage(EngineMessage.VDS_CLUSTER_IS_NOT_VALID);
        result = false;
    }
    // if the name was changed then make sure the new name is unique
    if (result && !StringUtils.equals(oldCluster.getName(), getCluster().getName())) {
        if (!isClusterUnique(getCluster().getName())) {
            addValidationMessage(EngineMessage.CLUSTER_CANNOT_DO_ACTION_NAME_IN_USE);
            result = false;
        }
    }
    if (result && !VersionSupport.checkVersionSupported(getCluster().getCompatibilityVersion())) {
        addValidationMessage(VersionSupport.getUnsupportedVersionMessage());
        result = false;
    }
    if (result) {
        allForCluster = vdsDao.getAllForCluster(oldCluster.getId());
    }
    // decreasing of compatibility version is only allowed when no hosts exists, and not beneath the DC version
    if (result && getCluster().getCompatibilityVersion().compareTo(oldCluster.getCompatibilityVersion()) < 0) {
        if (!allForCluster.isEmpty()) {
            result = false;
            addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_CANNOT_DECREASE_CLUSTER_WITH_HOSTS_COMPATIBILITY_VERSION);
        }
        if (oldCluster.getStoragePoolId() != null) {
            ClusterValidator validator = new ClusterValidator(dbFacade, oldCluster, getCpuFlagsManagerHandler());
            if (!validate(validator.dataCenterVersionMismatch())) {
                result = false;
                addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION_UNDER_DC);
            }
        }
    }
    if (result && oldCluster.getStoragePoolId() != null && !oldCluster.getStoragePoolId().equals(getCluster().getStoragePoolId())) {
        addValidationMessage(EngineMessage.CLUSTER_CANNOT_CHANGE_STORAGE_POOL);
        result = false;
    }
    // If both original Cpu and new Cpu are null, don't check Cpu validity
    if (result) {
        allVdssInMaintenance = areAllVdssInMaintenance(allForCluster);
    }
    // Validate the cpu only if the cluster supports Virt
    if (result && getCluster().supportsVirtService() && (oldCluster.getCpuName() != null || getCluster().getCpuName() != null)) {
        // Check that cpu exist
        if (!checkIfCpusExist()) {
            addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_CPU_NOT_FOUND);
            addValidationMessage(EngineMessage.VAR__TYPE__CLUSTER);
            result = false;
        } else {
            // vds in this cluster, cannot update
            if (!StringUtils.isEmpty(oldCluster.getCpuName()) && !checkIfCpusSameManufacture(oldCluster) && !allVdssInMaintenance) {
                addValidationMessage(EngineMessage.CLUSTER_CANNOT_UPDATE_CPU_ILLEGAL);
                result = false;
            }
        }
    }
    if (result) {
        vmList = vmDao.getAllForCluster(oldCluster.getId());
        hasVmOrHost = !vmList.isEmpty() || !allForCluster.isEmpty();
    }
    // cannot change the processor architecture while there are attached hosts or VMs to the cluster
    if (result && getCluster().supportsVirtService() && !isArchitectureUpdatable() && hasVmOrHost) {
        addValidationMessage(EngineMessage.CLUSTER_CANNOT_UPDATE_CPU_ARCHITECTURE_ILLEGAL);
        result = false;
    }
    if (result) {
        sameCpuNames = StringUtils.equals(oldCluster.getCpuName(), getCluster().getCpuName());
    }
    if (result) {
        boolean isOldCPUEmpty = StringUtils.isEmpty(oldCluster.getCpuName());
        if (!isOldCPUEmpty && !sameCpuNames && !isCpuUpdatable(oldCluster) && hasVmOrHost) {
            addValidationMessage(EngineMessage.CLUSTER_CPU_IS_NOT_UPDATABLE);
            result = false;
        }
    }
    if (result && !oldCluster.getCompatibilityVersion().equals(getCluster().getCompatibilityVersion())) {
        for (VM vm : vmList) {
            if (vm.isPreviewSnapshot()) {
                // can't change cluster version when a VM is in preview
                if (result) {
                    addValidationMessage(EngineMessage.CLUSTER_VERSION_CHANGE_VM_PREVIEW);
                    // and continue with adding validation messages
                    result = false;
                }
                addValidationMessage(vm.getName());
            }
        }
    }
    if (result) {
        List<VDS> vdss = new ArrayList<>();
        isAddedToStoragePool = oldCluster.getStoragePoolId() == null && getCluster().getStoragePoolId() != null;
        if (isAddedToStoragePool && !validateManagementNetwork()) {
            return false;
        }
        for (VDS vds : allForCluster) {
            if (vds.getStatus() == VDSStatus.Up) {
                if (isAddedToStoragePool) {
                    addValidationMessage(EngineMessage.CLUSTER_CANNOT_UPDATE_VDS_UP);
                    return false;
                } else {
                    vdss.add(vds);
                }
            }
        }
        for (VDS vds : vdss) {
            if (!VersionSupport.checkClusterVersionSupported(getCluster().getCompatibilityVersion(), vds)) {
                result = false;
                addValidationMessage(EngineMessage.CLUSTER_CANNOT_UPDATE_COMPATIBILITY_VERSION_WITH_LOWER_HOSTS);
                break;
            } else if (getCluster().supportsVirtService() && missingServerCpuFlags(vds) != null) {
                addValidationMessage(EngineMessage.CLUSTER_CANNOT_UPDATE_CPU_WITH_LOWER_HOSTS);
                result = false;
                break;
            }
            if (!isSupportedEmulatedMachinesMatchClusterLevel(vds)) {
                return failValidation(EngineMessage.CLUSTER_CANNOT_UPDATE_COMPATIBILITY_VERSION_WITH_INCOMPATIBLE_EMULATED_MACHINE);
            }
        }
        if (result) {
            Set<SupportedAdditionalClusterFeature> additionalClusterFeaturesAdded = getAdditionalClusterFeaturesAdded();
            // New Features cannot be enabled if all up hosts are not supporting the selected feature
            if (CollectionUtils.isNotEmpty(additionalClusterFeaturesAdded) && !checkClusterFeaturesSupported(vdss, additionalClusterFeaturesAdded)) {
                addValidationMessage(EngineMessage.CLUSTER_CANNOT_UPDATE_SUPPORTED_FEATURES_WITH_LOWER_HOSTS);
                result = false;
            }
        }
        if (result) {
            boolean notDownVms = false;
            boolean suspendedVms = false;
            hasVms = vmList.size() > 0;
            if (!sameCpuNames) {
                for (VM vm : vmList) {
                    if (vm.getStatus() == VMStatus.Suspended) {
                        suspendedVms = true;
                        break;
                    } else if (vm.getStatus() != VMStatus.Down) {
                        notDownVms = true;
                        break;
                    }
                }
                if (suspendedVms) {
                    addValidationMessage(EngineMessage.CLUSTER_CANNOT_UPDATE_CPU_WITH_SUSPENDED_VMS);
                    result = false;
                } else if (notDownVms) {
                    int compareResult = compareCpuLevels(oldCluster);
                    if (compareResult > 0) {
                        // Upgrade of CPU in same compability level is allowed if
                        // there
                        // are running VMs - but we should warn they
                        // cannot not be hibernated
                        addCustomValue("Cluster", getParameters().getCluster().getName());
                        auditLogDirector.log(this, AuditLogType.CANNOT_HIBERNATE_RUNNING_VMS_AFTER_CLUSTER_CPU_UPGRADE);
                    }
                }
            }
        }
    }
    if (result && getCluster().getStoragePoolId() != null) {
        StoragePool storagePool = storagePoolDao.get(getCluster().getStoragePoolId());
        if (oldCluster.getStoragePoolId() == null && storagePool.isLocal()) {
            // we allow only one cluster in localfs data center
            if (!clusterDao.getAllForStoragePool(getCluster().getStoragePoolId()).isEmpty()) {
                getReturnValue().getValidationMessages().add(EngineMessage.CLUSTER_CANNOT_ADD_MORE_THEN_ONE_HOST_TO_LOCAL_STORAGE.toString());
                result = false;
            } else if (Config.getValue(ConfigValues.AutoRegistrationDefaultClusterID).equals(getCluster().getId())) {
                addValidationMessage(EngineMessage.DEFAULT_CLUSTER_CANNOT_BE_ON_LOCALFS);
                result = false;
            }
        }
    }
    if (result) {
        if (!(getCluster().supportsGlusterService() || getCluster().supportsVirtService())) {
            addValidationMessage(EngineMessage.CLUSTER_AT_LEAST_ONE_SERVICE_MUST_BE_ENABLED);
            result = false;
        } else if (getCluster().supportsGlusterService() && getCluster().supportsVirtService() && !isAllowClusterWithVirtGluster()) {
            addValidationMessage(EngineMessage.CLUSTER_ENABLING_BOTH_VIRT_AND_GLUSTER_SERVICES_NOT_ALLOWED);
            result = false;
        }
    }
    if (result && hasVms && !getCluster().supportsVirtService()) {
        addValidationMessage(EngineMessage.CLUSTER_CANNOT_DISABLE_VIRT_WHEN_CLUSTER_CONTAINS_VMS);
        result = false;
    }
    if (result && !getCluster().supportsGlusterService()) {
        List<GlusterVolumeEntity> volumes = glusterVolumeDao.getByClusterId(getCluster().getId());
        if (volumes != null && volumes.size() > 0) {
            addValidationMessage(EngineMessage.CLUSTER_CANNOT_DISABLE_GLUSTER_WHEN_CLUSTER_CONTAINS_VOLUMES);
            result = false;
        }
    }
    if (result && getCluster().supportsTrustedService() && Config.<String>getValue(ConfigValues.AttestationServer).equals("")) {
        addValidationMessage(EngineMessage.CLUSTER_CANNOT_SET_TRUSTED_ATTESTATION_SERVER_NOT_CONFIGURED);
        result = false;
    }
    if (result && !FeatureSupported.isMigrationSupported(getArchitecture(), getCluster().getCompatibilityVersion()) && getCluster().getMigrateOnError() != MigrateOnErrorOptions.NO) {
        return failValidation(EngineMessage.MIGRATION_ON_ERROR_IS_NOT_SUPPORTED);
    }
    if (result) {
        result = validateClusterPolicy(oldCluster);
    }
    if (result && getParameters().isForceResetEmulatedMachine()) {
        for (VDS vds : allForCluster) {
            if (vds.getStatus() == VDSStatus.Up) {
                addValidationMessage(EngineMessage.CLUSTER_HOSTS_MUST_BE_DOWN);
                result = false;
                break;
            }
        }
    }
    ClusterValidator clusterValidator = new ClusterValidator(dbFacade, getCluster(), cpuFlagsManagerHandler);
    result = result && validate(clusterValidator.rngSourcesAllowed()) && validate(clusterValidator.memoryOptimizationConfiguration()) && validate(moveMacs.canMigrateMacsToAnotherMacPool(oldCluster, getNewMacPoolId())) && validateDefaultNetworkProvider() && validate(clusterValidator.supportedFirewallTypeForClusterVersion());
    return result;
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) ClusterValidator(org.ovirt.engine.core.bll.validator.ClusterValidator) ArrayList(java.util.ArrayList) SupportedAdditionalClusterFeature(org.ovirt.engine.core.common.businessentities.SupportedAdditionalClusterFeature) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 80 with StoragePool

use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.

the class RemoveVdsCommand method validate.

@Override
protected boolean validate() {
    boolean returnValue = canRemoveVds(getVdsId(), getReturnValue().getValidationMessages());
    StoragePool storagePool = storagePoolDao.getForVds(getParameters().getVdsId());
    if (returnValue && storagePool != null && storagePool.isLocal()) {
        if (!storageDomainDao.getAllForStoragePool(storagePool.getId()).isEmpty()) {
            returnValue = failValidation(EngineMessage.VDS_CANNOT_REMOVE_HOST_WITH_LOCAL_STORAGE);
        }
    }
    // Perform volume bricks on server and up server null check
    if (returnValue && isGlusterEnabled()) {
        upServer = glusterUtil.getUpServer(getClusterId());
        if (!getParameters().isForceAction()) {
            // fail if host has bricks on a volume
            if (hasVolumeBricksOnServer()) {
                returnValue = failValidation(EngineMessage.VDS_CANNOT_REMOVE_HOST_HAVING_GLUSTER_VOLUME);
            } else if (upServer == null && clusterHasMultipleHosts()) {
                // fail if there is no up server in cluster, and if host being removed is not
                // the last server in cluster
                addValidationMessageVariable("clusterName", getCluster().getName());
                returnValue = failValidation(EngineMessage.ACTION_TYPE_FAILED_NO_UP_SERVER_FOUND);
            }
        } else {
            // if force, cannot remove only if there are bricks on server and there is an up server.
            if (hasVolumeBricksOnServer() && upServer != null) {
                returnValue = failValidation(EngineMessage.VDS_CANNOT_REMOVE_HOST_HAVING_GLUSTER_VOLUME);
            }
        }
    }
    return returnValue;
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool)

Aggregations

StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)239 Guid (org.ovirt.engine.core.compat.Guid)83 ArrayList (java.util.ArrayList)78 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)60 Test (org.junit.Test)59 List (java.util.List)46 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)35 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)34 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)33 VDS (org.ovirt.engine.core.common.businessentities.VDS)31 QueryType (org.ovirt.engine.core.common.queries.QueryType)31 Frontend (org.ovirt.engine.ui.frontend.Frontend)31 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)28 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)28 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)27 Linq (org.ovirt.engine.ui.uicommonweb.Linq)26 Arrays (java.util.Arrays)25 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)25