use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class StorageDataCenterListModel method detach.
private void detach() {
if (getWindow() != null) {
return;
}
ConfirmationModel model = new ConfirmationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().detachStorageTitle());
model.setHelpTag(HelpTag.detach_storage);
// $NON-NLS-1$
model.setHashName("detach_storage");
model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantDetachStorageFromDcsMsg());
ArrayList<String> items = new ArrayList<>();
boolean shouldAddressWarnning = false;
for (Object item : getSelectedItems()) {
StorageDomain a = (StorageDomain) item;
items.add(a.getStoragePoolName());
if (a.getStorageDomainType().isDataDomain()) {
shouldAddressWarnning = true;
break;
}
}
model.setItems(items);
if (containsLocalStorage(model)) {
model.getForce().setIsAvailable(true);
model.getForce().setIsChangeable(true);
model.setForceLabel(ConstantsManager.getInstance().getConstants().storageRemovePopupFormatLabel());
shouldAddressWarnning = false;
model.setNote(ConstantsManager.getInstance().getMessages().detachNote(getLocalStoragesFormattedString()));
}
if (shouldAddressWarnning) {
model.setNote(ConstantsManager.getInstance().getConstants().detachWarnningNote());
}
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnDetach", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class AbstractDiskModel method updateDiskProfiles.
private void updateDiskProfiles(StoragePool selectedItem) {
StorageDomain storageDomain = getStorageDomain().getSelectedItem();
if (storageDomain == null) {
return;
}
Frontend.getInstance().runQuery(QueryType.GetDiskProfilesByStorageDomainId, new IdQueryParameters(storageDomain.getId()), new AsyncQuery<QueryReturnValue>(value -> setDiskProfilesList((List<DiskProfile>) value.getReturnValue())));
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class AbstractDiskModel method updateQuota.
private void updateQuota(StoragePool datacenter) {
if (datacenter.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED) || !getDiskStorageType().getEntity().isInternal()) {
getQuota().setIsAvailable(false);
return;
}
getQuota().setIsAvailable(true);
StorageDomain storageDomain = getStorageDomain().getSelectedItem();
if (storageDomain == null) {
return;
}
final Guid diskQuota = getDisk() != null ? ((DiskImage) getDisk()).getQuotaId() : null;
final Guid vmQuota = getVm() != null ? getVm().getQuotaId() : null;
final Guid defaultQuota = diskQuota != null ? diskQuota : vmQuota;
AsyncDataProvider.getInstance().getAllRelevantQuotasForStorageSorted(new AsyncQuery<>(quotaList -> {
if (quotaList != null && !quotaList.isEmpty()) {
getQuota().setItems(quotaList);
// If list contains default quota, return
if (quotaList.get(0).getId().equals(defaultQuota)) {
return;
}
}
if (diskQuota != null) {
Quota quota = new Quota();
quota.setId(diskQuota);
quota.setQuotaName(getDiskImage().getQuotaName());
if (quotaList == null) {
quotaList = new ArrayList<>();
}
quotaList.add(quota);
getQuota().setItems(quotaList);
getQuota().setSelectedItem(quota);
}
}), storageDomain.getId(), defaultQuota);
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainPopupView method addStorageDomainsColumn.
private void addStorageDomainsColumn() {
CustomSelectionCell customSelectionCellStorageDomain = new CustomSelectionCell(new ArrayList<String>());
customSelectionCellStorageDomain.setStyle(EMPTY_STYLE);
Column<DiskImage, String> storageDomainsColumn = new Column<DiskImage, String>(customSelectionCellStorageDomain) {
@Override
public String getValue(DiskImage disk) {
ImportDiskData importData = importModel.getDiskImportData(disk.getId());
ArrayList<String> storageDomainsNameList = new ArrayList<>();
StorageDomain selectedStorageDomain = null;
if (importData != null && importData.getStorageDomains() != null) {
for (StorageDomain storageDomain : importData.getStorageDomains()) {
storageDomainsNameList.add(new StorageDomainFreeSpaceRenderer<>().render(storageDomain));
if (importData.getSelectedStorageDomain() != null) {
if (storageDomain.getId().equals(importData.getSelectedStorageDomain().getId())) {
selectedStorageDomain = storageDomain;
}
}
}
}
((CustomSelectionCell) getCell()).setOptions(storageDomainsNameList);
if (!storageDomainsNameList.isEmpty()) {
if (selectedStorageDomain != null) {
return new StorageDomainFreeSpaceRenderer<>().render(selectedStorageDomain);
} else {
return storageDomainsNameList.get(0);
}
}
return "";
}
};
storageDomainsColumn.setFieldUpdater((index, disk, value) -> {
// $NON-NLS-1$
String storageDomainName = value.substring(0, value.lastIndexOf(" ("));
importModel.getDiskImportData(disk.getId()).setSelectedStorageDomainString(storageDomainName);
diskTable.asEditor().edit(importModel.getImportDiskListModel());
});
// $NON-NLS-1$
diskTable.addColumn(storageDomainsColumn, constants.storageDomainDisk(), "180px");
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class GetStorageDomainStatsVDSCommand method buildStorageDynamicStruct.
@SuppressWarnings("unchecked")
public static StorageDomain buildStorageDynamicStruct(Map<String, Object> struct) {
try {
StorageDomain domain = new StorageDomain();
if (struct.containsKey("status")) {
if ("Attached".equals(struct.get("status").toString())) {
domain.setStatus(StorageDomainStatus.Inactive);
} else {
domain.setStatus(EnumUtils.valueOf(StorageDomainStatus.class, struct.get("status").toString(), true));
}
}
Long size = IrsBrokerCommand.assignLongValue(struct, "diskfree");
domain.setAvailableDiskSize((size == null) ? null : (int) (size / SizeConverter.BYTES_IN_GB));
size = IrsBrokerCommand.assignLongValue(struct, "disktotal");
domain.setUsedDiskSize((size == null || domain.getAvailableDiskSize() == null) ? null : (int) (size / SizeConverter.BYTES_IN_GB) - domain.getAvailableDiskSize());
if (struct.containsKey("alerts")) {
Object[] rawAlerts = (Object[]) struct.get("alerts");
Set<EngineError> alerts = new HashSet<>(rawAlerts.length);
for (Object rawAlert : rawAlerts) {
Map<String, Object> alert = (Map<String, Object>) rawAlert;
Integer alertCode = (Integer) alert.get("code");
if (alertCode == null || EngineError.forValue(alertCode) == null) {
log.warn("Unrecognized alert code: {}.", alertCode);
StringBuilder alertStringBuilder = new StringBuilder();
ObjectDescriptor.toStringBuilder(alert, alertStringBuilder);
log.info("The received alert is: {}", alertStringBuilder);
} else {
alerts.add(EngineError.forValue(alertCode));
}
}
domain.setAlerts(alerts);
}
return domain;
} catch (RuntimeException ex) {
log.error("vdsBroker::buildStorageDynamicFromStruct::Failed building Storage dynamic, struct = {}", struct);
VDSErrorException outEx = new VDSErrorException(ex);
log.error("Exception", outEx);
throw outEx;
}
}
Aggregations