use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method savePosixStorage.
private void savePosixStorage(TaskContext context) {
this.context = context;
StorageDomain selectedItem = getSelectedItem();
StorageModel model = (StorageModel) getWindow();
boolean isNew = model.getStorage() == null;
storageModel = model.getCurrentStorageItem();
final PosixStorageModel posixModel = (PosixStorageModel) storageModel;
path = posixModel.getPath().getEntity();
storageDomain = isNew ? new StorageDomainStatic() : (StorageDomainStatic) Cloner.clone(selectedItem.getStorageStaticData());
saveBaseStorageProperties(model);
storageDomain.setStorageFormat(model.getFormat().getSelectedItem());
if (isNew) {
AsyncDataProvider.getInstance().getStorageDomainsByConnection(new AsyncQuery<>(storages -> {
if (storages != null && storages.size() > 0) {
posixModel.getPath().setIsValid(false);
handleDomainAlreadyExists(storages);
} else {
saveNewPosixStorage();
}
}), null, path);
} else {
StorageDomain storageDomain = getSelectedItem();
if (isPathEditable(storageDomain)) {
updatePath();
}
updateStorageDomain();
}
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method saveSanStorage.
private void saveSanStorage(TaskContext context) {
this.context = context;
StorageModel model = (StorageModel) getWindow();
SanStorageModelBase sanModel = (SanStorageModelBase) model.getCurrentStorageItem();
StorageDomain storage = getSelectedItem();
boolean isNew = model.getStorage() == null;
storageDomain = isNew ? new StorageDomainStatic() : (StorageDomainStatic) Cloner.clone(storage.getStorageStaticData());
storageDomain.setStorageType(isNew ? sanModel.getType() : storageDomain.getStorageType());
storageDomain.setStorageDomainType(isNew ? sanModel.getRole() : storageDomain.getStorageDomainType());
storageDomain.setStorageFormat(isNew ? sanModel.getContainer().getFormat().getSelectedItem() : storageDomain.getStorageFormat());
storageDomain.setDescription(model.getDescription().getEntity());
storageDomain.setComment(model.getComment().getEntity());
saveCommonStorageProperties(model);
if (isNew) {
saveNewSanStorage();
} else {
Frontend.getInstance().runAction(ActionType.UpdateStorageDomain, new StorageDomainManagementParameter(storageDomain), new IFrontendActionAsyncCallback() {
@Override
public void executed(FrontendActionAsyncResult result) {
StorageListModel storageListModel = (StorageListModel) result.getState();
StorageModel storageModel = (StorageModel) getWindow();
SanStorageModelBase sanStorageModelBase = (SanStorageModelBase) storageModel.getCurrentStorageItem();
boolean force = sanStorageModelBase.isForce();
StorageDomain storageDomain1 = storageListModel.getSelectedItem();
HashSet<String> lunIds = new HashSet<>();
for (LunModel lun : sanStorageModelBase.getAddedLuns()) {
lunIds.add(lun.getLunId());
}
if (lunIds.size() > 0) {
Frontend.getInstance().runAction(ActionType.ExtendSANStorageDomain, new ExtendSANStorageDomainParameters(storageDomain1.getId(), new HashSet<>(lunIds), force), null, this);
}
Set<String> lunToRefreshIds = sanStorageModelBase.getLunsToRefresh();
if (lunToRefreshIds.size() > 0) {
Frontend.getInstance().runAction(ActionType.RefreshLunsSize, new ExtendSANStorageDomainParameters(storageDomain1.getId(), lunToRefreshIds, false), null, this);
}
if (storageDomain1.getStatus() == StorageDomainStatus.Maintenance) {
Set<String> lunsToRemoveIds = sanStorageModelBase.getLunsToRemove();
if (lunsToRemoveIds.size() > 0) {
Frontend.getInstance().runAction(ActionType.ReduceSANStorageDomainDevices, new ReduceSANStorageDomainDevicesCommandParameters(storageDomain1.getId(), new ArrayList<>(lunsToRemoveIds)), null, this);
}
}
storageListModel.onFinish(storageListModel.context, true, storageListModel.storageModel);
}
}, this);
}
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method edit.
private void edit() {
StorageDomain storage = getSelectedItem();
if (getWindow() != null) {
return;
}
StorageModel model = new StorageModel(new NewEditStorageModelBehavior());
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().editDomainTitle());
model.setHelpTag(HelpTag.edit_domain);
// $NON-NLS-1$
model.setHashName("edit_domain");
model.setStorage(storage);
model.getName().setEntity(storage.getStorageName());
model.getDescription().setEntity(storage.getDescription());
model.getComment().setEntity(storage.getComment());
model.setOriginalName(storage.getStorageName());
model.getDataCenter().setIsChangeable(false);
model.getFormat().setIsChangeable(false);
boolean isStorageNameEditable = model.isStorageActive() || model.isNewStorage();
boolean isStorageInMaintenance = !model.isNewStorage() && model.getStorage().getStatus() == StorageDomainStatus.Maintenance;
model.getHost().setIsChangeable(false);
model.getName().setIsChangeable(isStorageNameEditable);
// set the field domain type to non editable
model.getAvailableStorageTypeItems().setIsChangeable(false);
model.getAvailableStorageDomainTypeItems().setIsChangeable(false);
model.setIsChangeable(isStorageNameEditable && !isStorageInMaintenance);
model.getWarningLowSpaceIndicator().setEntity(storage.getWarningLowSpaceIndicator());
model.getWarningLowSpaceSize().setEntity(ConstantsManager.getInstance().getMessages().bracketsWithGB(storage.getWarningLowSpaceSize()));
model.getWarningLowSpaceSize().setIsAvailable(true);
model.getCriticalSpaceActionBlocker().setEntity(storage.getCriticalSpaceActionBlocker());
IStorageModel item = prepareStorageForEdit(storage, model);
model.setStorageModels(new ArrayList<>(Arrays.asList(new IStorageModel[] { item })));
model.setCurrentStorageItem(item);
model.initialize();
UICommand command;
// $NON-NLS-1$
command = UICommand.createDefaultOkUiCommand("OnSave", this);
model.getCommands().add(command);
// $NON-NLS-1$
command = createCancelCommand("Cancel");
model.getCommands().add(command);
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method checkDomainAttachedToDc.
private void checkDomainAttachedToDc(String commandName, List<StorageDomain> storageDomains, StorageServerConnections storageServerConnections) {
final StorageModel storageModel = (StorageModel) getWindow();
StoragePool storagePool = storageModel.getDataCenter().getSelectedItem();
final UICommand okCommand = UICommand.createDefaultOkUiCommand(commandName, this);
if (storagePool.getId().equals(Guid.Empty)) {
okCommand.execute();
return;
}
VDS host = storageModel.getHost().getSelectedItem();
AsyncDataProvider.getInstance().getStorageDomainsWithAttachedStoragePoolGuid(new AsyncQuery<>(attachedStorageDomains -> {
if (!attachedStorageDomains.isEmpty()) {
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningTitle());
model.setMessage(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningMessage());
model.setHelpTag(HelpTag.import_storage_domain_confirmation);
// $NON-NLS-1$
model.setHashName("import_storage_domain_confirmation");
List<String> stoageDomainNames = new ArrayList<>();
for (StorageDomainStatic domain : attachedStorageDomains) {
stoageDomainNames.add(domain.getStorageName());
}
model.setItems(stoageDomainNames);
// $NON-NLS-1$
UICommand cancelCommand = createCancelCommand("CancelImportConfirm");
model.getCommands().add(okCommand);
model.getCommands().add(cancelCommand);
} else {
okCommand.execute();
}
}), storagePool, storageDomains, storageServerConnections, host.getId());
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method saveNfsStorage.
private void saveNfsStorage(TaskContext context) {
this.context = context;
StorageDomain selectedItem = getSelectedItem();
StorageModel model = (StorageModel) getWindow();
boolean isNew = model.getStorage() == null;
storageModel = model.getCurrentStorageItem();
final NfsStorageModel nfsModel = (NfsStorageModel) storageModel;
path = nfsModel.getPath().getEntity();
storageDomain = isNew ? new StorageDomainStatic() : (StorageDomainStatic) Cloner.clone(selectedItem.getStorageStaticData());
saveBaseStorageProperties(model);
storageDomain.setStorageFormat(model.getFormat().getSelectedItem());
if (isNew) {
AsyncDataProvider.getInstance().getStorageDomainsByConnection(new AsyncQuery<>(storages -> {
if (storages != null && storages.size() > 0) {
nfsModel.getPath().setIsValid(false);
handleDomainAlreadyExists(storages);
} else {
saveNewNfsStorage();
}
}), null, path);
} else {
StorageDomain storageDomain = getSelectedItem();
if (isPathEditable(storageDomain)) {
updatePath();
}
updateStorageDomain();
}
}
Aggregations