private static StorageDomain getExportDomain(List<StorageDomain> storageDomains) { return storageDomains.stream() .filter(storageDomain -> storageDomain.getStorageDomainType() == StorageDomainType.ImportExport) .filter(storageDomain -> storageDomain.getStatus() == StorageDomainStatus.Active) .findAny() .orElse(null); }
private static StorageDomain getExportDomain(List<StorageDomain> storageDomains) { for (StorageDomain storageDomain : storageDomains) { if (storageDomain.getStorageDomainType() == StorageDomainType.ImportExport && storageDomain.getStatus() == StorageDomainStatus.Active) { return storageDomain; } } return null; }
public boolean isEditable(StorageDomain storage) { return storage.getStatus() == StorageDomainStatus.Maintenance || storage.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached; }
public boolean isEditable(StorageDomain storage) { return storage.getStatus() == StorageDomainStatus.Maintenance || storage.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached; }
private boolean isStorageStatusValidForPathEditing(StorageDomain storage) { return storage.getStatus() == StorageDomainStatus.Maintenance || storage.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached; }
private boolean isDomainMasterAndActive(StorageDomain domain) { return domain.getStorageDomainType() == StorageDomainType.Master && domain.getStatus() == StorageDomainStatus.Active; }
public static boolean isDataActiveStorageDomain(StorageDomain storageDomain) { boolean isData = storageDomain.getStorageDomainType().isDataDomain(); boolean isActive = storageDomain.getStatus() == StorageDomainStatus.Active; return isData && isActive; }
private void updateActionAvailability() { List<Disk> disks = getSelectedItems() != null ? getSelectedItems() : new ArrayList<Disk>(); getRegisterCommand().setIsExecutionAllowed(disks.size() > 0 && getEntity().getStatus() == StorageDomainStatus.Active); }
private void updateAddAndAttachIsoDomainAvailability(List<VDS> upHosts, List<StorageDomain> attachedDataStorages, List<StorageDomain> attachedIsoStorages) { boolean attachOrAddIsoAvailable = attachedIsoStorages.isEmpty(); boolean masterStorageExistsAndRunning = attachedDataStorages.stream().anyMatch (d -> d.getStorageDomainType() == StorageDomainType.Master && d.getStatus() == StorageDomainStatus.Active); boolean addIsoAllowed = attachedDataStorages.size() > 0 && masterStorageExistsAndRunning && attachedIsoStorages.isEmpty() && upHosts.size() > 0; if (attachOrAddIsoAvailable) { UICommand addIsoStorageAction = new UICommand("AddIsoStorage", this); //$NON-NLS-1$ addIsoStorageAction.setTitle(DataCenterConfigureISOLibraryAction); getOptionalActions().add(addIsoStorageAction); UICommand attachIsoStorageAction = new UICommand("AttachIsoStorage", this); //$NON-NLS-1$ attachIsoStorageAction.setTitle(DataCenterAttachISOLibraryAction); getOptionalActions().add(attachIsoStorageAction); if (!masterStorageExistsAndRunning) { addIsoStorageAction.getExecuteProhibitionReasons().add(NoDataDomainAttachedReason); attachIsoStorageAction.getExecuteProhibitionReasons().add(NoDataDomainAttachedReason); } if (upHosts.isEmpty()) { addIsoStorageAction.getExecuteProhibitionReasons().add(NoUpHostReason); attachIsoStorageAction.getExecuteProhibitionReasons().add(NoUpHostReason); } addIsoStorageAction.setIsExecutionAllowed(addIsoAllowed); attachIsoStorageAction.setIsExecutionAllowed(addIsoAllowed && isoStorageDomains.size() > 0); } }
private static org.ovirt.engine.core.common.businessentities.StorageDomain setUpEntityExpectations(org.ovirt.engine.core.common.businessentities.StorageDomain entity, int index, StorageType storageType) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getStatus()).thenReturn(StorageDomainStatus.Active); when(entity.getStorageDomainType()).thenReturn(StorageDomainType.Master); when(entity.getStorageType()).thenReturn(storageType); when(entity.getStorage()).thenReturn(GUIDS[0].toString()); return entity; }
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; }
static org.ovirt.engine.core.common.businessentities.StorageDomain setUpStorageDomainEntityExpectations(org.ovirt.engine.core.common.businessentities.StorageDomain entity, StorageType storageType) { when(entity.getId()).thenReturn(GUIDS[3]); when(entity.getStorageName()).thenReturn(NAMES[2]); when(entity.getStatus()).thenReturn(StorageDomainStatus.Active); when(entity.getStorageDomainType()).thenReturn(StorageDomainType.Master); when(entity.getStorageType()).thenReturn(storageType); when(entity.getStorage()).thenReturn(GUIDS[0].toString()); return entity; } private Action setUpCopyParams(boolean byName) {
private void setValuesForMaintenance(SanStorageModelBase model) { isInMaintenance = false; metadata = null; if (!model.getContainer().isNewStorage()) { isInMaintenance = model.getContainer().getStorage().getStatus() == StorageDomainStatus.Maintenance; metadata = model.getMetadataDevices(); } }
public StorageDomain getStorageDomain() { if (storageDomain == null && getStorageDomainId() != null) { if (storagePoolId != null && getStoragePool() != null) { storageDomain = storageDomainDao.getForStoragePool( getStorageDomainId(), getStoragePool().getId()); } if (storageDomain == null) { final List<StorageDomain> storageDomainList = storageDomainDao.getAllForStorageDomain(getStorageDomainId()); if (storageDomainList.size() != 0) { storageDomain = storageDomainList.get(0); for (final StorageDomain storageDomainFromList : storageDomainList) { if (storageDomainFromList.getStatus() == StorageDomainStatus.Active) { storageDomain = storageDomainFromList; break; } } } } } return storageDomain; }
protected void updateLeaseStorageDomains(final Guid selectedStorageDomainId) { AsyncDataProvider.getInstance().getStorageDomainList(new AsyncQuery<>( returnValue -> { // initialize the list of storage domains that available for lease creation List<StorageDomain> domains = new ArrayList<>(); domains.add(null); for (StorageDomain domain : returnValue) { if (domain.getStorageDomainType().isDataDomain() && domain.getStatus() == StorageDomainStatus.Active) { domains.add(domain); } } getModel().getLease().setItems(domains); // initialize the storage domain that currently holds the lease. // VM lease storage domain can be on non-active domain, therefore we need to search // through all the data domains for the lease storage domain. if (selectedStorageDomainId != null) { returnValue.stream() .filter(d -> d.getStorageDomainType().isDataDomain()) .filter(d -> selectedStorageDomainId.equals(d.getId())) .findFirst().ifPresent(d -> getModel().getLease().setSelectedItem(d)); } setVmLeasesAvailability(); }), getModel().getSelectedDataCenter().getId()); }
private void updateActionAvailability() { List<StorageDomain> items = getSelectedItems() != null ? getSelectedItems() : new ArrayList<StorageDomain>(); StorageDomain item = getSelectedItem(); getNewDomainCommand().setIsAvailable(true); getEditCommand().setIsExecutionAllowed(items.size() == 1 && isEditAvailable(item)); getRemoveCommand().setIsExecutionAllowed(items.size() == 1 && !items.get(0).getStorageType().isOpenStackDomain() && items.get(0).getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached); getDestroyCommand().setIsExecutionAllowed(item != null && items.size() == 1 && !items.get(0).getStorageType().isOpenStackDomain() && item.getStatus() != StorageDomainStatus.Active); getScanDisksCommand().setIsExecutionAllowed(item != null && items.size() == 1 && !items.get(0).getStorageType().isOpenStackDomain() && item.getStatus() == StorageDomainStatus.Active && item.getStorageDomainType().isDataDomain()); getUpdateOvfsCommand().setIsExecutionAllowed(item != null && items.size() == 1 && item.getStorageDomainType().isDataDomain() && item.getStatus() == StorageDomainStatus.Active); getNewDomainCommand().setIsAvailable(true); getRemoveCommand().setIsAvailable(true); getDestroyCommand().setIsAvailable(true); getScanDisksCommand().setIsAvailable(true); getUpdateOvfsCommand().setIsAvailable(true); }
private void dataCenter_SelectedItemChanged() { if (getCurrentStorageItem() instanceof SanStorageModelBase) { SanStorageModelBase sanStorageModel = (SanStorageModelBase) getCurrentStorageItem(); boolean isMaintenance = !isNewStorage() && getStorage().getStatus() == StorageDomainStatus.Maintenance; sanStorageModel.setReduceDeviceSupported(isMaintenance); sanStorageModel.updateRemovableLuns(); } updateItemsAvailability(); behavior.updateDataCenterAlert(); }
@Test public void testGetStorageDomainWithStatusForInvalidPool() { List<StorageDomain> result = dao.getStorageDomains(Guid.newGuid(), existingDomain.getStorageDomainType(), existingDomain.getStatus()); assertTrue(result.isEmpty()); }
public void postUpdateHost(Collection<VDS> hosts) { // Filter hosts hosts = Linq.where(hosts, new Linq.StatusPredicate<>(VDSStatus.Up)); VDS oldSelectedItem = getHost().getSelectedItem(); VDS selectedItem = null; // On Edit of active storage - only SPM is available. In edit of storage in maintenance, //any host can perform the operation, thus no need to filter to use just the SPM if (getStorage() != null && getStorage().getStatus() != StorageDomainStatus.Maintenance) { VDS spm = getSPM(hosts); hosts = spm != null ? Collections.singletonList(spm) : Collections.emptyList(); } // Try to select previously selected host. if (oldSelectedItem != null) { selectedItem = Linq.firstOrNull(hosts, new Linq.IdPredicate<>(oldSelectedItem.getId())); } // Select a default - if there's a SPM choose it, otherwise choose the first host in the list. if (selectedItem == null) { VDS spm = getSPM(hosts); selectedItem = spm == null ? Linq.firstOrNull(hosts) : spm; } getHost().setItems(hosts, selectedItem); }
private void setVmLeasesAvailability() { TModel model = getModel(); if (model.getSelectedCluster() == null) { return; } StorageDomain leaseStorageDomain = model.getLease().getSelectedItem(); if (!model.getIsHighlyAvailable().getEntity()) { model.getLease().setIsChangeable(false); model.getLease().setChangeProhibitionReason(constants.vmLeasesNotSupportedWithoutHA()); } else if (leaseStorageDomain != null && leaseStorageDomain.getStatus() != StorageDomainStatus.Active) { model.getLease().setIsChangeable(false); model.getLease().setChangeProhibitionReason(constants.cannotEditNotActiveLeaseDomain()); } else { model.getLease().setIsChangeable(true); } }