use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic 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.StorageDomainStatic 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.StorageDomainStatic 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.StorageDomainStatic 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();
}
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class StorageListModel method onImportSanDomainApprove.
private void onImportSanDomainApprove() {
ArrayList<Object> data = (ArrayList<Object>) context.getState();
hostId = (Guid) data.get(1);
ImportSanStorageModel importSanStorageModel = (ImportSanStorageModel) storageModel;
final List<StorageDomain> storageDomains = importSanStorageModel.getStorageDomains().getSelectedItems();
ArrayList<ActionParametersBase> parametersList = new ArrayList<>(items.size());
List<IFrontendActionAsyncCallback> callbacks = new LinkedList<>();
for (final StorageDomain storageDomain : storageDomains) {
StorageDomainStatic staticData = storageDomain.getStorageStaticData();
saveDefaultedStorageProperties((StorageModel) getWindow(), staticData);
StorageDomainManagementParameter parameters = new StorageDomainManagementParameter(staticData);
parameters.setVdsId(hostId);
parametersList.add(parameters);
callbacks.add(result -> {
ActionReturnValue returnValue = result.getReturnValue();
boolean success = returnValue != null && returnValue.getSucceeded();
if (success) {
StorageModel model = (StorageModel) getWindow();
StoragePool dataCenter = model.getDataCenter().getSelectedItem();
if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
attachStorageToDataCenter(storageDomain.getId(), dataCenter.getId(), model.getActivateDomain().getEntity());
}
boolean isLastDomain = storageDomain == storageDomains.get(storageDomains.size() - 1);
if (isLastDomain) {
onFinish(context, true, storageModel);
}
} else {
onFinish(context, false, storageModel);
}
});
}
Frontend.getInstance().runMultipleActions(ActionType.AddExistingBlockStorageDomain, parametersList, callbacks);
}
Aggregations