public boolean isStorageActive() { return getStorage().getStorageDomainSharedStatus() == StorageDomainSharedStatus.Active || getStorage().getStorageDomainSharedStatus() == StorageDomainSharedStatus.Mixed; }
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; }
@Override protected StorageDomain deprecatedPopulate(StorageDomain model, org.ovirt.engine.core.common.businessentities.StorageDomain entity) { if (StorageDomainSharedStatus.Unattached.equals(entity.getStorageDomainSharedStatus())) { model.setStatus(StorageDomainStatus.UNATTACHED); } else { model.setStatus(null); } return super.deprecatedPopulate(model, entity); }
private List<StorageDomain> getUnattachedStorages() { List<StorageDomain> unattachedStorage = new ArrayList<>(); for (StorageDomain item : allStorageDomains) { if (item.getStorageDomainType() == StorageDomainType.Data && item.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached) { if (getEntity().getStoragePoolFormatType() == null || getEntity().getStoragePoolFormatType() == item.getStorageStaticData().getStorageFormat()) { unattachedStorage.add(item); } } } return unattachedStorage; }
private void updateActionAvailability() { getRestoreCommand().setIsExecutionAllowed(getEntity() != null && getSelectedItems() != null && getSelectedItems().size() > 0 && getEntity().getStorageDomainSharedStatus() == StorageDomainSharedStatus.Active); getRemoveCommand().setIsExecutionAllowed(getEntity() != null && getSelectedItems() != null && getSelectedItems().size() > 0 && getEntity().getStorageDomainSharedStatus() == StorageDomainSharedStatus.Active); }
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; }
private void checkStorageStatus() { if (getEntity() == null) { return; } if (getEntity().getStorageDomainSharedStatus() == StorageDomainSharedStatus.Inactive || getEntity().getStorageDomainSharedStatus() == StorageDomainSharedStatus.Mixed) { setMessage(ConstantsManager.getInstance().getConstants().theExportDomainIsInactiveMsg()); } else if (getEntity().getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached) { setMessage(ConstantsManager.getInstance().getConstants().exportDomainIsNotAttachedToAnyDcMsg()); } else { setMessage(null); } }
private void updateActionAvailability() { boolean isItemSelected = getSelectedItems() != null && getSelectedItems() != null && getSelectedItems().size() > 0; boolean isDomainActive = getEntity() != null && getEntity().getStorageDomainSharedStatus() == StorageDomainSharedStatus.Active; getImportCommand().setIsExecutionAllowed(isItemSelected && isDomainActive); }
private StorageDomains mapCollection(List<org.ovirt.engine.core.common.businessentities.StorageDomain> entities) { StorageDomains collection = new StorageDomains(); for (org.ovirt.engine.core.common.businessentities.StorageDomain entity : entities) { StorageDomain storageDomain = map(entity); // status is only relevant in the context of a data-center, so it can either be 'Unattached' or null. if (StorageDomainSharedStatus.Unattached.equals(entity.getStorageDomainSharedStatus())) { storageDomain.setStatus(StorageDomainStatus.UNATTACHED); } else { storageDomain.setStatus(null); } collection.getStorageDomains().add(addLinks(storageDomain, getLinksToExclude(storageDomain))); } return collection; }
private void updateActionAvailability() { List<StorageDomain> items = getSelectedItems() != null ? getSelectedItems() : new ArrayList<StorageDomain>(); getActivateCommand().setIsExecutionAllowed(items.size() == 1 && ActionUtils.canExecute(items, StorageDomain.class, ActionType.ActivateStorageDomain)); getMaintenanceCommand().setIsExecutionAllowed(items.size() == 1 && ActionUtils.canExecute(items, StorageDomain.class, ActionType.DeactivateStorageDomainWithOvfUpdate)); getAttachCommand().setIsExecutionAllowed(getEntity() != null && (getEntity().getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached || getEntity().getStorageDomainType() == StorageDomainType.ISO)); getDetachCommand().setIsExecutionAllowed(items.size() > 0 && ActionUtils.canExecute(items, StorageDomain.class, ActionType.DetachStorageDomainFromPool)); }
/** * Asserts the result returned from {@link StorageDomainDao#getAllForStoragePool(Guid)} is correct * @param result The result to check */ private static void assertGetAllForStoragePoolResult(List<StorageDomain> result, Guid expectedStoragePoolId) { assertFalse(result.isEmpty()); for (StorageDomain domain : result) { assertEquals(expectedStoragePoolId, domain.getStoragePoolId()); assertEquals(StorageDomainSharedStatus.Active, domain.getStorageDomainSharedStatus(), "Wrong shared status"); } }
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); }
/** * Ensures that retrieving storage domains works as expected for a privileged user. */ @Test public void testGetAllWithPermissionsPrivilegedUser() { List<StorageDomain> result = dao.getAll(PRIVILEGED_USER_ID, true); assertFalse(result.isEmpty()); assertEquals(NUMBER_OF_STORAGE_DOMAINS_FOR_PRIVELEGED_USER, result.size()); StorageDomain domain = result.get(0); assertEquals(existingDomain, domain); assertEquals(8, domain.getCommittedDiskSize(), "Wrong committed disk size"); assertEquals(4, domain.getActualImagesSize(), "Wrong actual disk size"); assertEquals(StorageDomainSharedStatus.Active, domain.getStorageDomainSharedStatus(), "Wrong shared status"); }
@Override protected void syncSearch() { super.syncSearch(); if (getEntity() == null || getEntity().getStorageDomainType() != StorageDomainType.ImportExport || getEntity().getStorageDomainSharedStatus() != StorageDomainSharedStatus.Active) { setItems(Collections.emptyList()); } else { AsyncDataProvider.getInstance().getDataCentersByStorageDomain(new AsyncQuery<>(list -> { if (list != null && list.size() > 0) { StoragePool dataCenter = list.get(0); Frontend.getInstance().runQuery(QueryType.GetVmsFromExportDomain, new GetAllFromExportDomainQueryParameters(dataCenter.getId(), getEntity().getId()), new SetSortedItemsAsyncQuery(new LexoNumericNameableComparator<>())); } }), getEntity().getId()); } }
/** * Test getting storage for existing image id. */ @Test public void testGetAllStorageDomainsByImageId() { List<StorageDomain> result = dao.getAllStorageDomainsByImageId(FixturesTool.TEMPLATE_IMAGE_ID); assertEquals(1, result.size()); StorageDomain domain = result.get(0); assertEquals(FixturesTool.STORAGE_DOMAIN_SCALE_SD5, domain.getId()); assertEquals(8, domain.getCommittedDiskSize(), "Wrong committed disk size"); assertEquals(4, domain.getActualImagesSize(), "Wrong actual disk size"); assertEquals(StorageDomainSharedStatus.Active, domain.getStorageDomainSharedStatus(), "Wrong shared status"); }
@Test public void testGetStorageDomainWithNoStatus() { List<StorageDomain> result = dao.getStorageDomains(FixturesTool.STORAGE_POOL_NFS_INACTIVE_ISO, StorageDomainType.ISO, null); StorageDomain domain = result.get(0); assertEquals(FixturesTool.STORAGE_DOMAIN_NFS_INACTIVE_ISO, domain.getId()); assertEquals(0, domain.getCommittedDiskSize(), "Wrong committed disk size"); assertEquals(0, domain.getActualImagesSize(), "Wrong actual disk size"); assertEquals(StorageDomainSharedStatus.Inactive, domain.getStorageDomainSharedStatus(), "Wrong shared status"); }
@Test public void testGetPermittedStorageDomains() { List<StorageDomain> result = dao.getPermittedStorageDomainsByStoragePool(FixturesTool.USER_EXISTING_ID, ActionGroup.CONFIGURE_VM_STORAGE, FixturesTool.DATA_CENTER); assertFalse(result.isEmpty()); StorageDomain domain = result.get(0); assertEquals(existingDomain.getId(), domain.getId()); assertEquals(8, domain.getCommittedDiskSize(), "Wrong committed disk size"); assertEquals(4, domain.getActualImagesSize(), "Wrong actual disk size"); assertEquals(StorageDomainSharedStatus.Active, domain.getStorageDomainSharedStatus(), "Wrong shared status"); }
/** * Asserts the result of {@link StorageDomainDao#get(Guid)} returns the correct domain */ private void assertGetResult(StorageDomain result) { assertNotNull(result); assertEquals(existingDomain, result); assertEquals(8, result.getCommittedDiskSize(), "Wrong committed disk size"); assertEquals(4, result.getActualImagesSize(), "Wrong actual disk size"); assertEquals(FixturesTool.LUN_ID_OF_DOMAIN_METADATA, result.getFirstMetadataDevice(), "Wrong first metadata device"); assertEquals(FixturesTool.LUN_ID_OF_DOMAIN_VG_METADATA, result.getVgMetadataDevice(), "Wrong vg metadata device"); assertEquals(StorageDomainSharedStatus.Active, result.getStorageDomainSharedStatus(), "Wrong shared status"); assertFalse(result.isBackup(), "Wrong backup flag status"); }