Search in sources :

Example 1 with CinderDisk

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

the class VmModelBehaviorBase method initTemplateDisks.

protected void initTemplateDisks(List<DiskImage> disks) {
    disks.sort(new DiskByDiskAliasComparator());
    ArrayList<DiskModel> list = new ArrayList<>();
    for (DiskImage disk : disks) {
        DiskModel diskModel = new DiskModel();
        diskModel.getAlias().setEntity(disk.getDiskAlias());
        diskModel.getVolumeType().setIsAvailable(false);
        switch(disk.getDiskStorageType()) {
            case IMAGE:
                diskModel.setSize(new EntityModel<>((int) disk.getSizeInGigabytes()));
                ListModel volumes = new ListModel();
                volumes.setItems(disk.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Collections.singletonList(VolumeType.Preallocated)) : AsyncDataProvider.getInstance().getVolumeTypeList(), disk.getVolumeType());
                diskModel.setVolumeType(volumes);
                break;
            case CINDER:
                CinderDisk cinderDisk = (CinderDisk) disk;
                diskModel.setSize(new EntityModel<>((int) cinderDisk.getSizeInGigabytes()));
                ListModel volumeTypes = new ListModel();
                volumeTypes.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeType())), cinderDisk.getVolumeType());
                diskModel.setVolumeType(volumeTypes);
                ListModel volumeFormats = new ListModel();
                volumeFormats.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeFormat())), cinderDisk.getVolumeFormat());
                diskModel.setVolumeFormat(volumeFormats);
                break;
        }
        diskModel.setDisk(disk);
        list.add(diskModel);
    }
    getModel().setDisks(list);
    updateIsDisksAvailable();
    initStorageDomains();
}
Also used : ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 2 with CinderDisk

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

the class AddVmCommand method addVmCinderDisks.

protected void addVmCinderDisks(Collection<DiskImage> templateDisks) {
    List<CinderDisk> cinderDisks = DisksFilter.filterCinderDisks(templateDisks);
    if (cinderDisks.isEmpty()) {
        return;
    }
    Map<Guid, Guid> diskImageMap = new HashMap<>();
    for (CinderDisk cinderDisk : cinderDisks) {
        ImagesContainterParametersBase params = buildCloneCinderDiskCommandParameters(cinderDisk);
        ActionReturnValue actionReturnValue = runInternalAction(ActionType.CloneSingleCinderDisk, params, cloneContext().withoutExecutionContext().withoutLock());
        if (!actionReturnValue.getSucceeded()) {
            log.error("Error cloning Cinder disk '{}': {}", cinderDisk.getDiskAlias());
            getReturnValue().setFault(actionReturnValue.getFault());
            return;
        }
        Guid imageId = actionReturnValue.getActionReturnValue();
        diskImageMap.put(cinderDisk.getId(), imageId);
    }
    srcDiskIdToTargetDiskIdMapping.putAll(diskImageMap);
}
Also used : HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 3 with CinderDisk

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

the class AddVmCommand method validate.

@Override
protected boolean validate() {
    if (getCluster() == null) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_CLUSTER_CAN_NOT_BE_EMPTY);
    }
    if (getVmTemplate() == null) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST);
    }
    if (getVmTemplate().isDisabled()) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED);
    }
    StoragePoolValidator spValidator = new StoragePoolValidator(getStoragePool());
    if (!validate(spValidator.exists())) {
        return false;
    }
    if (!isExternalVM() && !validate(spValidator.isInStatus(StoragePoolStatus.Up))) {
        return false;
    }
    if (!isTemplateInValidDc()) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_TEMPLATE_NOT_EXISTS_IN_CURRENT_DC);
    }
    if (!isDisksVolumeFormatValid()) {
        return false;
    }
    Version customCompatibilityVersionFromParams = getParameters().getVmStaticData().getCustomCompatibilityVersion();
    if (customCompatibilityVersionFromParams != null && !isCompatibilityVersionSupportedByCluster(customCompatibilityVersionFromParams)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_CUSTOM_COMPATIBILITY_VERSION_NOT_SUPPORTED, String.format("$Ccv %s", customCompatibilityVersionFromParams));
    }
    // A VM cannot be added in a cluster without a defined architecture
    if (getCluster().getArchitecture() == ArchitectureType.undefined) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_CLUSTER_UNDEFINED_ARCHITECTURE);
    }
    if (verifySourceDomains() && buildAndCheckDestStorageDomains()) {
        chooseDisksSourceDomains();
    } else {
        return false;
    }
    if (getParameters().getVmStaticData().getVmType() == VmType.HighPerformance && !FeatureSupported.isHighPerformanceTypeSupported(getEffectiveCompatibilityVersion())) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_HIGH_PERFORMANCE_IS_NOT_SUPPORTED, String.format("$Version %s", getEffectiveCompatibilityVersion()));
    }
    if (isBalloonEnabled() && !osRepository.isBalloonEnabled(getParameters().getVmStaticData().getOsId(), getEffectiveCompatibilityVersion())) {
        addValidationMessageVariable("clusterArch", getCluster().getArchitecture());
        return failValidation(EngineMessage.BALLOON_REQUESTED_ON_NOT_SUPPORTED_ARCH);
    }
    if (isSoundDeviceEnabled() && !osRepository.isSoundDeviceEnabled(getParameters().getVmStaticData().getOsId(), getEffectiveCompatibilityVersion())) {
        addValidationMessageVariable("clusterArch", getCluster().getArchitecture());
        return failValidation(EngineMessage.SOUND_DEVICE_REQUESTED_ON_NOT_SUPPORTED_ARCH);
    }
    if (!validateQuota(getParameters().getVmStaticData().getQuotaId())) {
        return false;
    }
    // otherwise..
    storageToDisksMap = ImagesHandler.buildStorageToDiskMap(getImagesToCheckDestinationStorageDomains(), diskInfoDestinationMap);
    if (!validateAddVmCommand()) {
        return false;
    }
    VM vmFromParams = getParameters().getVm();
    // check if the selected template is compatible with Cluster architecture.
    if (!getVmTemplate().getId().equals(VmTemplateHandler.BLANK_VM_TEMPLATE_ID) && getCluster().getArchitecture() != getVmTemplate().getClusterArch()) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_TEMPLATE_IS_INCOMPATIBLE);
    }
    if (StringUtils.isEmpty(vmFromParams.getName())) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_NAME_MAY_NOT_BE_EMPTY);
    }
    // check that VM name is not too long
    if (!isVmNameValidLength(vmFromParams)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_NAME_LENGTH_IS_TOO_LONG);
    }
    // check for Vm Payload
    if (getParameters().getVmPayload() != null) {
        if (!checkPayload(getParameters().getVmPayload())) {
            return false;
        }
        // otherwise, we save the content in base64 string
        for (Map.Entry<String, String> entry : getParameters().getVmPayload().getFiles().entrySet()) {
            entry.setValue(new String(BASE_64.encode(entry.getValue().getBytes()), StandardCharsets.UTF_8));
        }
    }
    // check for Vm Watchdog Model
    if (getParameters().getWatchdog() != null) {
        if (!validate(new VmWatchdogValidator(vmFromParams.getOs(), getParameters().getWatchdog(), getEffectiveCompatibilityVersion()).isValid())) {
            return false;
        }
    }
    // check if the OS type is supported
    if (!validate(vmHandler.isOsTypeSupported(vmFromParams.getOs(), getCluster().getArchitecture()))) {
        return false;
    }
    if (!validate(vmHandler.isCpuSupported(vmFromParams.getVmOsId(), getEffectiveCompatibilityVersion(), getCluster().getCpuName()))) {
        return false;
    }
    // Check if the graphics and display from parameters are supported
    if (!validate(vmHandler.isGraphicsAndDisplaySupported(getParameters().getVmStaticData().getOsId(), vmHandler.getResultingVmGraphics(getVmDeviceUtils().getGraphicsTypesOfEntity(getVmTemplateId()), getParameters().getGraphicsDevices()), vmFromParams.getDefaultDisplayType(), getEffectiveCompatibilityVersion()))) {
        return false;
    }
    if (!validate(vmHandler.validateSmartCardDevice(getParameters().getVmStaticData()))) {
        return false;
    }
    if (!FeatureSupported.isMigrationSupported(getCluster().getArchitecture(), getEffectiveCompatibilityVersion()) && vmFromParams.getMigrationSupport() != MigrationSupport.PINNED_TO_HOST) {
        return failValidation(EngineMessage.VM_MIGRATION_IS_NOT_SUPPORTED);
    }
    // check cpuPinning if the check haven't failed yet
    if (!validate(isCpuPinningValid(vmFromParams.getCpuPinning(), vmFromParams.getStaticData()))) {
        return false;
    }
    if (vmFromParams.isUseHostCpuFlags() && vmFromParams.getMigrationSupport() != MigrationSupport.PINNED_TO_HOST) {
        return failValidation(EngineMessage.VM_HOSTCPU_MUST_BE_PINNED_TO_HOST);
    }
    if (vmFromParams.isUseHostCpuFlags() && (ArchitectureType.ppc == getCluster().getArchitecture().getFamily())) {
        return failValidation(EngineMessage.USE_HOST_CPU_REQUESTED_ON_UNSUPPORTED_ARCH);
    }
    if (!validateMemoryAlignment(getParameters().getVmStaticData())) {
        return false;
    }
    if (getInstanceTypeId() != null && getInstanceType() == null) {
        // invalid instance type
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_INSTANCE_TYPE_DOES_NOT_EXIST);
    }
    if (imageTypeId != null && getImageType() == null) {
        // invalid image type
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_IMAGE_TYPE_DOES_NOT_EXIST);
    }
    if (!validate(VmValidator.validateCpuSockets(getParameters().getVmStaticData(), getEffectiveCompatibilityVersion()))) {
        return false;
    }
    if (!isCpuSharesValid(vmFromParams)) {
        return failValidation(EngineMessage.QOS_CPU_SHARES_OUT_OF_RANGE);
    }
    if (!VmCpuCountHelper.validateCpuCounts(vmFromParams)) {
        return failValidation(EngineMessage.TOO_MANY_CPU_COMPONENTS);
    }
    if (Boolean.TRUE.equals(getParameters().isVirtioScsiEnabled())) {
        // Verify OS compatibility
        if (!validate(vmHandler.isOsTypeSupportedForVirtioScsi(vmFromParams.getOs(), getEffectiveCompatibilityVersion()))) {
            return false;
        }
    }
    if (vmFromParams.getMinAllocatedMem() > vmFromParams.getMemSizeMb()) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_MIN_MEMORY_CANNOT_EXCEED_MEMORY_SIZE);
    }
    if (!setAndValidateDiskProfiles()) {
        return false;
    }
    if (!setAndValidateCpuProfile()) {
        return false;
    }
    if (getVmId() != null && vmStaticDao.get(getVmId()) != null) {
        return failValidation(EngineMessage.VM_ID_EXISTS);
    }
    List<CinderDisk> cinderDisks = DisksFilter.filterCinderDisks(diskInfoDestinationMap.values());
    CinderDisksValidator cinderDisksValidator = new CinderDisksValidator(cinderDisks);
    if (!validate(cinderDisksValidator.validateCinderDiskLimits())) {
        return false;
    }
    if (getParameters().getVmLargeIcon() != null && !validate(IconValidator.validate(IconValidator.DimensionsType.LARGE_CUSTOM_ICON, getParameters().getVmLargeIcon()))) {
        return false;
    }
    if (getSmallIconId() != null && // icon id is ignored if large icon is sent
    getParameters().getVmLargeIcon() == null && !validate(IconValidator.validateIconId(getSmallIconId(), "Small"))) {
        return false;
    }
    if (getLargeIconId() != null && // icon id is ignored if large icon is sent
    getParameters().getVmLargeIcon() == null && !validate(IconValidator.validateIconId(getLargeIconId(), "Large"))) {
        return false;
    }
    if (!validate(getNumaValidator().checkVmNumaNodesIntegrity(getParameters().getVm(), getParameters().getVm().getvNumaNodeList()))) {
        return false;
    }
    if (getCluster().isInUpgradeMode()) {
        getParameters().getVm().setClusterCompatibilityVersion(getCluster().getCompatibilityVersion());
        if (!validate(getClusterUpgradeValidator().isVmReadyForUpgrade(getParameters().getVm()))) {
            return false;
        }
    }
    if (!validate(vmHandler.validateMaxMemorySize(getParameters().getVmStaticData(), getEffectiveCompatibilityVersion()))) {
        return false;
    }
    if (shouldAddLease(getParameters().getVmStaticData()) && !canAddLease()) {
        return false;
    }
    List<EngineMessage> msgs = openStackMetadataAdapter.validate(getParameters().getVmStaticData().getVmInit());
    if (!CollectionUtils.isEmpty(msgs)) {
        return failValidation(msgs);
    }
    return true;
}
Also used : StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) VmWatchdogValidator(org.ovirt.engine.core.bll.validator.VmWatchdogValidator) Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) CinderDisksValidator(org.ovirt.engine.core.bll.validator.storage.CinderDisksValidator) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Map(java.util.Map) HashMap(java.util.HashMap) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 4 with CinderDisk

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

the class DiskVmElementDiscardSupportValidatorTest method data.

@Parameters
public static Object[][] data() {
    ValidationResult passDiscardNotSupportedByDiskInterface = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_INTERFACE, getDiskAliasVarReplacement());
    ValidationResult passDiscardNotSupportedForDirectLunByUnderlyingStorage = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_FOR_DIRECT_LUN_BY_UNDERLYING_STORAGE, getDiskAliasVarReplacement());
    ValidationResult passDiscardNotSupportedForDiskImageByUnderlyingStorage = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_FOR_DISK_IMAGE_BY_UNDERLYING_STORAGE, getDiskAliasVarReplacement(), getStorageDomainNameVarReplacement());
    ValidationResult passDiscardNotSupportedByCinder = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_STORAGE_TYPE, getDiskAliasVarReplacement(), String.format("$diskStorageType %s", DiskStorageType.CINDER));
    // sdSupportsDiscard, diskWipeAfterDelete, expectedResult.
    return new Object[][] { // isPassDiscard == false
    { new DiskImage(), false, null, null, null, null, null, ValidationResult.VALID }, // Unsupported interface
    { new DiskImage(), true, DiskInterface.VirtIO, null, null, null, null, passDiscardNotSupportedByDiskInterface }, { new DiskImage(), true, DiskInterface.SPAPR_VSCSI, null, null, null, null, passDiscardNotSupportedByDiskInterface }, // Direct lun without support from underlying storage (different interfaces)
    { new LunDisk(), true, DiskInterface.VirtIO_SCSI, 0L, null, null, null, passDiscardNotSupportedForDirectLunByUnderlyingStorage }, { new LunDisk(), true, DiskInterface.IDE, 0L, null, null, null, passDiscardNotSupportedForDirectLunByUnderlyingStorage }, // Direct lun with support from underlying storage (different interfaces)
    { new LunDisk(), true, DiskInterface.VirtIO_SCSI, 1024L, null, null, null, ValidationResult.VALID }, { new LunDisk(), true, DiskInterface.IDE, 1024L, null, null, null, ValidationResult.VALID }, /*
                Image on file storage domain:
                - with/without support from underlying storage
                - different interfaces
                - different file storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.NFS, true, null, ValidationResult.VALID }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.POSIXFS, false, null, ValidationResult.VALID }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.POSIXFS, null, null, ValidationResult.VALID }, /*
                Image on block storage domain without support from underlying storage:
                - different interfaces
                - different block storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.ISCSI, false, null, passDiscardNotSupportedForDiskImageByUnderlyingStorage }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.FCP, false, null, passDiscardNotSupportedForDiskImageByUnderlyingStorage }, /*
                Image on block storage domain with support from underlying storage:
                - different interfaces
                - different block storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.ISCSI, true, null, ValidationResult.VALID }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.FCP, true, null, ValidationResult.VALID }, /*
                Image on block storage domain with support from underlying storage and WAD enabled:
                - different interfaces
                - different block storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.ISCSI, true, true, new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_UNDERLYING_STORAGE_WHEN_WAD_IS_ENABLED, getStorageDomainNameVarReplacement(), getDiskAliasVarReplacement()) }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.FCP, true, true, new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_UNDERLYING_STORAGE_WHEN_WAD_IS_ENABLED, getStorageDomainNameVarReplacement(), getDiskAliasVarReplacement()) }, /*
                Image on non file or block storage domain:
                - different interfaces
                - different non file or block storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.UNKNOWN, null, null, createPassDiscardNotSupportedByStorageTypeValResult(StorageType.UNKNOWN) }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.CINDER, null, null, createPassDiscardNotSupportedByStorageTypeValResult(StorageType.CINDER) }, // Unsupported disk storage type (different interfaces)
    { new CinderDisk(), true, DiskInterface.VirtIO_SCSI, null, null, null, null, passDiscardNotSupportedByCinder }, { new CinderDisk(), true, DiskInterface.IDE, null, null, null, null, passDiscardNotSupportedByCinder } };
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Parameters(org.junit.runners.Parameterized.Parameters)

Example 5 with CinderDisk

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

the class StorageRegisterDiskListModel method register.

private void register() {
    if (getWindow() != null) {
        return;
    }
    ArrayList<ActionParametersBase> parametersList = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        CinderDisk disk = (CinderDisk) item;
        RegisterCinderDiskParameters parameters = new RegisterCinderDiskParameters(disk, getEntity().getId());
        parametersList.add(parameters);
    }
    Frontend.getInstance().runMultipleAction(ActionType.RegisterCinderDisk, parametersList, result -> {
    }, this);
}
Also used : ArrayList(java.util.ArrayList) RegisterCinderDiskParameters(org.ovirt.engine.core.common.action.RegisterCinderDiskParameters) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)74 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)28 Guid (org.ovirt.engine.core.compat.Guid)19 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)15 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)14 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)13 ArrayList (java.util.ArrayList)12 ImagesContainterParametersBase (org.ovirt.engine.core.common.action.ImagesContainterParametersBase)9 ExecutionException (java.util.concurrent.ExecutionException)7 VM (org.ovirt.engine.core.common.businessentities.VM)6 HashMap (java.util.HashMap)5 List (java.util.List)5 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)5 Map (java.util.Map)4 Test (org.junit.Test)4 StoragePoolValidator (org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator)4 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3