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 org.ovirt.engine.core.common.businessentities.StorageDomain getStorageDomain(Guid guid) { org.ovirt.engine.core.common.businessentities.StorageDomain sd = new org.ovirt.engine.core.common.businessentities.StorageDomain(); sd.setStorageName("Storage_Domain_1"); sd.setId(guid); return sd; }
private void scanDisks() { StorageDomain storageDomain = getSelectedItem(); if (storageDomain != null) { Frontend.getInstance().runAction(ActionType.ScanStorageForUnregisteredDisks, new StorageDomainParametersBase(storageDomain.getStoragePoolId(), storageDomain.getId())); } }
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; }
@Override public String render(T storageDomain) { if (storageDomain == null) { return ""; //$NON-NLS-1$ } if (storageDomain.getAvailableDiskSize() == null || storageDomain.getStorageType() == StorageType.CINDER) { // 'getAvailableDiskSize' may return null when there's a connectivity issue with the storage domain return storageDomain.getStorageName(); } return messages.storageDomainFreeSpace(storageDomain.getStorageName(), storageDomain.getAvailableDiskSize(), storageDomain.getTotalDiskSize()); } }
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; }
/** * Finds the identifier of the storage domain corresponding to the given provider. * * @param resource the resource that will be used to perform the operation * @param providerId identifier of the provider * @return the identifier of the corresponding storage domain or {@code null} if no such storage domain exists */ public static Guid getStorageDomainId(BackendResource resource, String providerId) { // The backend doesn't have any mechanism to obtain the images other than listing the images provided by the // storage domain that is created for the provider, and the only way to find that provider is to iterate the // complete list. This is potentially very slow, so it should be improved in the future. Guid storageDomainId = null; List<StorageDomain> storageDomains = resource.runQuery(QueryType.GetAllStorageDomains, new QueryParametersBase()).getReturnValue(); for (StorageDomain storageDomain : storageDomains) { String storageId = storageDomain.getStorage(); if (providerId.equals(storageId)) { storageDomainId = storageDomain.getId(); break; } } return storageDomainId; } }
@Override public String getValue(StorageDomain model) { return model.getStorageName(); } };
private Guid getStorageDomainIdByName(String storageDomainName) { List<org.ovirt.engine.core.common.businessentities.StorageDomain> storageDomains = getBackendCollection(org.ovirt.engine.core.common.businessentities.StorageDomain.class, QueryType.GetAllStorageDomains, new QueryParametersBase()); for (org.ovirt.engine.core.common.businessentities.StorageDomain storageDomain : storageDomains) { if (storageDomain.getStorageName().equals(storageDomainName)) { return storageDomain.getId(); } } return null; }
@Override protected org.ovirt.engine.core.common.businessentities.StorageDomain getInverse(StorageDomainStatic to) { org.ovirt.engine.core.common.businessentities.StorageDomain inverse = new org.ovirt.engine.core.common.businessentities.StorageDomain(); inverse.setId(to.getId()); inverse.setStorageName(to.getStorageName()); inverse.setStorageDomainType(to.getStorageDomainType()); inverse.setStorageType(to.getStorageType()); inverse.setStorageFormat(to.getStorageFormat()); inverse.setComment(to.getComment()); return inverse; }
if (storageDomain.getStorageType() != StorageType.LOCALFS) { DetachStorageDomainFromPoolParameters param = new DetachStorageDomainFromPoolParameters(); param.setStorageDomainId(getEntity().getId()); if (storageDomain.getStoragePoolId() != null) { param.setStoragePoolId(storageDomain.getStoragePoolId()); new RemoveStorageDomainParameters(storage.getId()); tempVar.setVdsId(locaVds != null ? locaVds.getId() : null); tempVar.setDoFormat(model.getForce().getEntity()); storageDomain.getStoragePoolName());
private void removeTemplateBackup() { List<ActionParametersBase> prms = getSelectedItems() .stream() .map(item -> new VmTemplateImportExportParameters(item.getId(), getEntity().getId(), pool.getId())) .collect(Collectors.toList()); Frontend.getInstance().runMultipleAction(ActionType.RemoveVmTemplateFromImportExport, prms); cancel(); }
private org.ovirt.engine.core.common.businessentities.StorageDomain getStorageDomain(Guid id, StorageDomainType type) { org.ovirt.engine.core.common.businessentities.StorageDomain sd = new org.ovirt.engine.core.common.businessentities.StorageDomain(); sd.setId(id); sd.setStorageDomainType(type); return sd; }
private String getLocalStoragesFormattedString() { StringBuilder localStorages = new StringBuilder(); for (StorageDomain a : getSelectedItems()) { if (a.getStorageType() == StorageType.LOCALFS) { localStorages.append(a.getStorageName()).append(", "); //$NON-NLS-1$ } } return localStorages.substring(0, localStorages.length() - 2); }
@Override protected void syncSearch() { if (getEntity() == null) { return; } super.syncSearch(); IdQueryParameters tempVar = new IdQueryParameters(getEntity().getId()); tempVar.setRefresh(getIsQueryFirstTime()); Frontend.getInstance().runQuery(QueryType.GetStorageDomainListById, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> { ArrayList<StorageDomain> domains = returnValue.getReturnValue(); for (StorageDomain domain : domains) { domain.setId(domain.getStoragePoolId()); } Collections.sort (domains, Comparator.comparing(StorageDomain::getStoragePoolName, new LexoNumericComparator())); setItems(domains); setIsEmpty(getItems().size() == 0); })); }
private boolean containsLocalStorage(ConfirmationModel model) { for (StorageDomain a : getSelectedItems()) { if (a.getStorageType() == StorageType.LOCALFS) { return true; } } return false; }
protected void updateCinderVolumeTypes() { StorageDomain storageDomain = getStorageDomain().getSelectedItem(); if (storageDomain == null || storageDomain.getStorageType() != StorageType.CINDER) { return; } AsyncDataProvider.getInstance().getCinderVolumeTypesList(new AsyncQuery<>(cinderVolumeTypes -> { List<String> volumeTypesNames = new ArrayList<>(); for (CinderVolumeType cinderVolumeType : cinderVolumeTypes) { volumeTypesNames.add(cinderVolumeType.getName()); } getCinderVolumeType().setItems(volumeTypesNames); }), storageDomain.getId()); }
private void updateActionAvailability() { List<Disk> disks = getSelectedItems() != null ? getSelectedItems() : new ArrayList<Disk>(); getRegisterCommand().setIsExecutionAllowed(disks.size() > 0 && getEntity().getStatus() == StorageDomainStatus.Active); }
@Mapping(from = org.ovirt.engine.core.common.businessentities.StorageDomain.class, to = HostStorage.class) public static HostStorage map(org.ovirt.engine.core.common.businessentities.StorageDomain entity, HostStorage template) { HostStorage model = template != null ? template : new HostStorage(); model.setId(entity.getStorage()); model.setType(StorageDomainMapper.map(entity.getStorageType(), null)); model.setVolumeGroup(new VolumeGroup()); model.getVolumeGroup().setId(entity.getStorage()); return model; }