public VolumeFormat getDiskVolumeFormat(VolumeType volumeType, StorageType storageType) { if (storageType.isFileDomain()) { return VolumeFormat.RAW; } else if (storageType.isBlockDomain()) { switch (volumeType) { case Sparse: return VolumeFormat.COW; case Preallocated: return VolumeFormat.RAW; default: return VolumeFormat.Unassigned; } } else if (storageType.isManagedBlockStorage()) { return volumeType == VolumeType.Preallocated ? VolumeFormat.RAW : VolumeFormat.Unassigned; } else { return VolumeFormat.Unassigned; } }
public boolean isShared() { return !isLocal(); }
private ArrayList<StorageType> getStorageTypesList(String storageTypesString) throws SQLException { List<String> splitTypes = split(storageTypesString); if (splitTypes == null) { return null; } ArrayList<StorageType> types = new ArrayList<>(); for (String typeStr : splitTypes) { try { types.add(StorageType.forValue(Integer.parseInt(typeStr))); } catch (NumberFormatException e) { throw new SQLException("Could not parse disk image storage domain type " + typeStr, e); } } return types; }
public boolean isInternal() { return isFileDomain() || isBlockDomain(); }
@Test public void testIsFileDomain() { assertFalse(StorageType.FCP.isFileDomain()); assertFalse(StorageType.ISCSI.isFileDomain()); assertTrue(StorageType.NFS.isFileDomain()); assertTrue(StorageType.LOCALFS.isFileDomain()); assertTrue(StorageType.POSIXFS.isFileDomain()); assertTrue(StorageType.GLUSTERFS.isFileDomain()); assertTrue(StorageType.GLANCE.isFileDomain()); assertFalse(StorageType.CINDER.isFileDomain()); assertFalse(StorageType.MANAGED_BLOCK_STORAGE.isFileDomain()); }
public boolean hasRawBlock() { if (getVolumeFormat() != VolumeFormat.RAW) { return false; } for (StorageType type : getStorageTypes()) { if (type.isBlockDomain()) { return true; } } return false; }
model.setTarget(entity.getIqn()); if (entity.getStorageType().isFileDomain()) { setPath(entity, model); if (entity.getStorageType().equals(org.ovirt.engine.core.common.businessentities.storage.StorageType.NFS)) { if (entity.getNfsVersion() != null) { model.setNfsVersion(map(entity.getNfsVersion(), null)); model.setMountOptions(entity.getMountOptions()); } else if (entity.getStorageType().equals(org.ovirt.engine.core.common.businessentities.storage.StorageType.POSIXFS) || entity.getStorageType().equals(org.ovirt.engine.core.common.businessentities.storage.StorageType.GLUSTERFS)) { model.setMountOptions(entity.getMountOptions()); model.setVfsType(entity.getVfsType());
static StorageServerConnections setUpEntityExpectations(StorageServerConnections entity, int index) { when(entity.getId()).thenReturn(GUIDS[index].toString()); when(entity.getStorageType()).thenReturn(STORAGE_TYPES_MAPPED[index]); if (STORAGE_TYPES_MAPPED[index].equals(StorageType.ISCSI)) { when(entity.getPort()).thenReturn("3260"); when(entity.getConnection()).thenReturn("1.122.10.125"); } if (STORAGE_TYPES_MAPPED[index].equals(StorageType.NFS)) { when(entity.getConnection()).thenReturn("1.122.10.125:/data1"); } return entity; }
private void updateShareableDiskEnabled() { StorageDomain storageDomain = getStorageDomain().getSelectedItem(); if (storageDomain != null && (StorageType.GLUSTERFS == storageDomain.getStorageType() || storageDomain.getStorageType().equals(StorageType.MANAGED_BLOCK_STORAGE))) { getIsShareable().setEntity(false); getIsShareable().setIsChangeable(false, constants.shareableDiskNotSupported()); } else if (getVolumeType().getSelectedItem() == VolumeType.Sparse && storageDomain != null && storageDomain.getStorageType().isBlockDomain()) { getIsShareable().setEntity(false); getIsShareable().setIsChangeable(false, constants.shareableDiskNotSupportedByConfiguration()); } else { getIsShareable().setIsChangeable(isEditEnabled(), constants.shareableDiskNotSupportedOnRunningVM()); } }
private boolean isEditAvailable(StorageDomain storageDomain) { if (storageDomain == null || (storageDomain.getStorageType().isCinderDomain() && !storageDomain.getStorageType() .isManagedBlockStorage())) { return false; } boolean isEditAvailable; boolean isActive = storageDomain.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Active || storageDomain.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Mixed; boolean isInMaintenance = storageDomain.getStatus() == StorageDomainStatus.Maintenance || storageDomain.getStatus() == StorageDomainStatus.PreparingForMaintenance; boolean isUnattached = storageDomain.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached || storageDomain.getStatus() == StorageDomainStatus.Detaching; boolean isInternalDomain = storageDomain.getStorageDomainType().isInternalDomain(); boolean isBlockStorage = storageDomain.getStorageType().isBlockDomain(); isEditAvailable = isActive || isBlockStorage || ((isInMaintenance || isUnattached) && isInternalDomain); return isEditAvailable; }
@Override protected void updateVolumeType(StorageType storageType) { // In case the user didn't select any specific allocation policy, it will be change according to the storage // domain type if (storageType.isManagedBlockStorage()) { getVolumeType().setSelectedItem(VolumeType.Preallocated); getVolumeType().setIsChangeable(false); } else if (!isUserSelectedVolumeType) { getVolumeType().setSelectedItem(storageType.isBlockDomain() ? VolumeType.Preallocated : VolumeType.Sparse); getVolumeType().setIsChangeable(true); } }
@Override public List<StorageServerConnections> getStorageConnectionsByStorageTypeAndStatus(Guid pool, StorageType storageType, Set<StorageDomainStatus> statuses) { List<String> statusesVals = statuses.stream().map(status -> Integer.toString(status.getValue())).collect(Collectors.toList()); return getCallsHandler().executeReadList("GetStorageConnectionsByStorageTypeAndStatus", mapper, getCustomMapSqlParameterSource() .addValue("storage_pool_id", pool) .addValue("storage_type", (storageType != null) ? storageType.getValue() : null) .addValue("statuses", StringUtils.join(statusesVals, ","))); }
public VolumeType getVolumeType(VolumeFormat volumeFormat, StorageType storageType, VM vm, Image diskImage) { switch (volumeFormat) { case COW: return VolumeType.Sparse; case RAW: default: boolean copyPreallocatedFileBasedDiskSupported = vm != null ? isCopyPreallocatedFileBasedDiskSupported(vm.getCompatibilityVersion()) : false; // if diskImage provided it means that we want to use the source image volume type, // otherwise we set the volume type as sparse by default for file-based storage domain VolumeType fileBasedVolumeType; if (copyPreallocatedFileBasedDiskSupported) { fileBasedVolumeType = diskImage != null ? diskImage.getVolumeType() : VolumeType.Sparse; } else { fileBasedVolumeType = VolumeType.Sparse; } return storageType.isFileDomain() ? fileBasedVolumeType : VolumeType.Preallocated; } }
private void updatePassDiscardChangeabilityForDiskImage() { if (getStorageDomain().getSelectedItem() == null) { return; } if (getStorageDomain().getSelectedItem().getStorageType().isFileDomain()) { getPassDiscard().setIsChangeable(true); } else if (getStorageDomain().getSelectedItem().getStorageType().isBlockDomain()) { if (!getStorageDomain().getSelectedItem().getSupportsDiscard()) { getPassDiscard().setIsChangeable(false, constants.discardIsNotSupportedByUnderlyingStorage()); getPassDiscard().setEntity(false); } else { getPassDiscard().setIsChangeable(!getIsWipeAfterDelete().getEntity(), constants.theUnderlyingStorageDoesNotSupportDiscardWhenWipeAfterDeleteIsEnabled()); if (!getPassDiscard().getIsChangable()) { getPassDiscard().setEntity(false); } } } }
@Test public void testIsBlockDomain() { assertTrue(StorageType.FCP.isBlockDomain()); assertTrue(StorageType.ISCSI.isBlockDomain()); assertFalse(StorageType.NFS.isBlockDomain()); assertFalse(StorageType.LOCALFS.isBlockDomain()); assertFalse(StorageType.POSIXFS.isBlockDomain()); assertFalse(StorageType.GLUSTERFS.isBlockDomain()); assertFalse(StorageType.GLANCE.isBlockDomain()); assertFalse(StorageType.CINDER.isBlockDomain()); assertFalse(StorageType.MANAGED_BLOCK_STORAGE.isBlockDomain()); }
static StorageServerConnections setUpEntityExpectations(StorageServerConnections entity, int index) { when(entity.getId()).thenReturn(GUIDS[index].toString()); when(entity.getStorageType()).thenReturn(STORAGE_TYPES_MAPPED[index]); when(entity.getConnection()).thenReturn("1.1.1.255"); if (STORAGE_TYPES_MAPPED[index].equals(StorageType.ISCSI)) { when(entity.getPort()).thenReturn("3260"); } return entity; } }
private boolean isPathEditable(StorageDomain storage) { if (storage.getStorageType().isFileDomain()) { StorageDomainType storageDomainType = storage.getStorageDomainType(); return storageDomainType.isInternalDomain() && isStorageStatusValidForPathEditing(storage); } return false; }
private void updateProblematicDisk(DiskModel diskModel) { StorageDomain storageDomain = diskModel.getStorageDomain().getSelectedItem(); if (storageDomain == null) { return; } String diskAlias = diskModel.getDisk().getDiskAlias(); if (storageDomain.getStorageType().isBlockDomain()) { if (!problematicDisksForWarning.contains(diskAlias)) { problematicDisksForWarning.add(diskAlias); } } else { problematicDisksForWarning.remove(diskAlias); } if (!problematicDisksForWarning.isEmpty()) { getDynamicWarning().setEntity(messages.moveDisksPreallocatedWarning( String.join(", ", problematicDisksForWarning))); //$NON-NLS-1$ getDynamicWarning().setIsAvailable(true); } else { getDynamicWarning().setIsAvailable(false); } }
static StorageServerConnections setUpEntityExpectations(StorageServerConnections entity, int index) { when(entity.getId()).thenReturn(GUIDS[index].toString()); when(entity.getStorageType()).thenReturn(STORAGE_TYPES_MAPPED[index]); when(entity.getConnection()).thenReturn("/data1"); if (STORAGE_TYPES_MAPPED[index].equals(StorageType.ISCSI)) { when(entity.getPort()).thenReturn("3260"); } return entity; }
public boolean isLocal() { return getStorageType().isLocal(); }