use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class StorageListModel method addExistingFileStorageDomain.
public void addExistingFileStorageDomain() {
StorageDomain sdToAdd = Linq.firstOrNull(storageDomainsToAdd);
StorageDomainStatic sdsToAdd = sdToAdd.getStorageStaticData();
storageDomain = sdsToAdd;
saveBaseStorageProperties((StorageModel) getWindow());
StorageDomainManagementParameter params = new StorageDomainManagementParameter(sdsToAdd);
params.setVdsId(hostId);
Frontend.getInstance().runAction(ActionType.AddExistingFileStorageDomain, params, result -> {
Object[] array = (Object[]) result.getState();
StorageListModel storageListModel = (StorageListModel) array[0];
StorageDomain sdToAdd1 = (StorageDomain) array[1];
ActionReturnValue returnVal = result.getReturnValue();
boolean success = returnVal != null && returnVal.getSucceeded();
if (success) {
StorageModel model = (StorageModel) storageListModel.getWindow();
StoragePool dataCenter = model.getDataCenter().getSelectedItem();
if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
storageListModel.attachStorageToDataCenter(sdToAdd1.getId(), dataCenter.getId(), model.getActivateDomain().getEntity());
onFinish(storageListModel.context, true, storageListModel.storageModel, null);
} else {
postImportFileStorage(storageListModel.context, true, storageListModel.storageModel, null);
}
} else {
// $NON-NLS-1$
postImportFileStorage(storageListModel.context, false, storageListModel.storageModel, "");
cleanConnection(fileConnection, hostId);
}
}, new Object[] { this, sdToAdd });
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class StorageListModel method saveNewPosixStorage.
public void saveNewPosixStorage() {
StorageModel model = (StorageModel) getWindow();
PosixStorageModel posixModel = (PosixStorageModel) model.getCurrentStorageItem();
VDS host = model.getHost().getSelectedItem();
hostId = host.getId();
// Create storage connection.
StorageServerConnections connection = new StorageServerConnections();
connection.setConnection(path);
connection.setStorageType(posixModel.getType());
connection.setVfsType(posixModel.getVfsType().getEntity());
connection.setMountOptions(posixModel.getMountOptions().getEntity());
if (posixModel instanceof GlusterStorageModel) {
GlusterStorageModel glusterModel = (GlusterStorageModel) posixModel;
Guid glusterVolId = null;
if (glusterModel.getLinkGlusterVolume().getEntity()) {
glusterVolId = ((GlusterStorageModel) posixModel).getGlusterVolumes().getSelectedItem() != null ? ((GlusterStorageModel) posixModel).getGlusterVolumes().getSelectedItem().getId() : null;
}
connection.setGlusterVolumeId(glusterVolId);
}
this.connection = connection;
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
actionTypes.add(ActionType.AddStorageServerConnection);
actionTypes.add(posixModel.getAddStorageDomainVdcAction());
parameters.add(new StorageServerConnectionParametersBase(this.connection, host.getId(), false));
StorageDomainManagementParameter parameter = new StorageDomainManagementParameter(storageDomain);
parameter.setVdsId(host.getId());
StoragePool dataCenter = model.getDataCenter().getSelectedItem();
parameter.setStoragePoolId(dataCenter.getId());
parameters.add(parameter);
IFrontendActionAsyncCallback callback1 = result -> {
StorageListModel storageListModel = (StorageListModel) result.getState();
ActionReturnValue actionReturnValue = result.getReturnValue();
storageListModel.storageDomain.setStorage((String) actionReturnValue.getActionReturnValue());
storageListModel.connection.setId((String) actionReturnValue.getActionReturnValue());
};
IFrontendActionAsyncCallback callback2 = result -> {
StorageListModel storageListModel = (StorageListModel) result.getState();
ActionReturnValue actionReturnValue = result.getReturnValue();
storageListModel.storageId = actionReturnValue.getActionReturnValue();
// Attach storage to data center as necessary.
StorageModel storageModel = (StorageModel) storageListModel.getWindow();
StoragePool dataCenter1 = storageModel.getDataCenter().getSelectedItem();
if (!dataCenter1.getId().equals(StorageModel.UnassignedDataCenterId)) {
storageListModel.attachStorageToDataCenter(storageListModel.storageId, dataCenter1.getId(), storageModel.getActivateDomain().getEntity());
}
storageListModel.onFinish(storageListModel.context, true, storageListModel.storageModel);
};
IFrontendActionAsyncCallback failureCallback = result -> {
StorageListModel storageListModel = (StorageListModel) result.getState();
storageListModel.cleanConnection(storageListModel.connection, storageListModel.hostId);
storageListModel.onFinish(storageListModel.context, false, storageListModel.storageModel);
};
Frontend.getInstance().runMultipleActions(actionTypes, parameters, new ArrayList<>(Arrays.asList(new IFrontendActionAsyncCallback[] { callback1, callback2 })), failureCallback, this);
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class StorageListModel method saveNewSanStorage.
public void saveNewSanStorage() {
StorageModel model = (StorageModel) getWindow();
SanStorageModelBase sanModel = (SanStorageModelBase) model.getCurrentStorageItem();
VDS host = model.getHost().getSelectedItem();
boolean force = sanModel.isForce();
HashSet<String> lunIds = new HashSet<>();
for (LunModel lun : sanModel.getAddedLuns()) {
lunIds.add(lun.getLunId());
}
AddSANStorageDomainParameters params = new AddSANStorageDomainParameters(storageDomain);
params.setVdsId(host.getId());
params.setLunIds(lunIds);
params.setForce(force);
Frontend.getInstance().runAction(ActionType.AddSANStorageDomain, params, result -> {
StorageListModel storageListModel = (StorageListModel) result.getState();
StorageModel storageModel = (StorageModel) storageListModel.getWindow();
storageListModel.storageModel = storageModel.getCurrentStorageItem();
if (!result.getReturnValue().getSucceeded()) {
storageListModel.onFinish(storageListModel.context, false, storageListModel.storageModel);
return;
}
StoragePool dataCenter = storageModel.getDataCenter().getSelectedItem();
if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
ActionReturnValue returnValue = result.getReturnValue();
Guid storageId = returnValue.getActionReturnValue();
storageListModel.attachStorageToDataCenter(storageId, dataCenter.getId(), storageModel.getActivateDomain().getEntity());
}
storageListModel.onFinish(storageListModel.context, true, storageListModel.storageModel);
}, this);
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class VmBaseListModel method postShowWarningOnExistingVms.
private void postShowWarningOnExistingVms(final ExportVmModel exportModel, List<StoragePool> storagePools, QueryType getVmOrTemplateQuery) {
StoragePool storagePool = storagePools.size() > 0 ? storagePools.get(0) : null;
if (storagePool != null) {
Guid storageDomainId = exportModel.getStorage().getSelectedItem().getId();
GetAllFromExportDomainQueryParameters tempVar = new GetAllFromExportDomainQueryParameters(storagePool.getId(), storageDomainId);
Frontend.getInstance().runQuery(getVmOrTemplateQuery, tempVar, new AsyncQuery<>((AsyncCallback<QueryReturnValue>) returnValue -> {
ExportVmModel windowModel = (ExportVmModel) getWindow();
List<T> foundVms = new ArrayList<>();
if (returnValue != null) {
Iterable<T> iterableReturnValue = asIterableReturnValue(returnValue.getReturnValue());
for (T selectedItem1 : getSelectedItems()) {
for (T returnValueItem : iterableReturnValue) {
if (entititesEqualsNullSafe(returnValueItem, selectedItem1)) {
foundVms.add(selectedItem1);
break;
}
}
}
}
if (foundVms.size() != 0) {
windowModel.setMessage(composeEntityOnStorage(composeExistingVmsWarningMessage(foundVms)));
}
exportModel.stopProgress();
}));
} else {
exportModel.stopProgress();
}
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class VmBackupModel method onRemove.
private void onRemove() {
ConfirmationModel model = (ConfirmationModel) getWindow();
if (model.getProgress() != null) {
return;
}
model.startProgress();
AsyncDataProvider.getInstance().getDataCentersByStorageDomain(new AsyncQuery<>(pools -> {
if (pools != null && pools.size() > 0) {
StoragePool pool = pools.get(0);
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (VM vm : getSelectedItems()) {
list.add(new RemoveVmFromImportExportParameters(vm.getId(), getEntity().getId(), pool.getId()));
}
Frontend.getInstance().runMultipleAction(ActionType.RemoveVmFromImportExport, list, result -> {
ConfirmationModel localModel = (ConfirmationModel) result.getState();
localModel.stopProgress();
cancel();
onEntityChanged();
}, getWindow());
}
}), getEntity().getId());
}
Aggregations