use of org.ovirt.engine.core.common.businessentities.StorageDomain 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.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method remove.
private void remove() {
if (getWindow() != null) {
return;
}
final RemoveStorageModel model = new RemoveStorageModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().removeStoragesTitle());
model.setHelpTag(HelpTag.remove_storage);
// $NON-NLS-1$
model.setHashName("remove_storage");
StorageDomain storage = getSelectedItem();
boolean localFsOnly = storage.getStorageType() == StorageType.LOCALFS;
AsyncDataProvider.getInstance().getHostsForStorageOperation(new AsyncQuery<>(hosts -> {
model.getHostList().setItems(hosts);
model.getHostList().setSelectedItem(Linq.firstOrNull(hosts));
if (hosts.isEmpty()) {
// $NON-NLS-1$
UICommand tempVar = createCancelCommand("Cancel");
tempVar.setIsDefault(true);
model.getCommands().add(tempVar);
} else {
UICommand command;
// $NON-NLS-1$
command = UICommand.createDefaultOkUiCommand("OnRemove", StorageListModel.this);
model.getCommands().add(command);
// $NON-NLS-1$
command = createCancelCommand("Cancel");
model.getCommands().add(command);
}
}), null, localFsOnly);
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method saveLocalStorage.
private void saveLocalStorage(TaskContext context) {
this.context = context;
StorageDomain selectedItem = getSelectedItem();
StorageModel model = (StorageModel) getWindow();
VDS host = model.getHost().getSelectedItem();
boolean isNew = model.getStorage() == null;
storageModel = model.getCurrentStorageItem();
LocalStorageModel localModel = (LocalStorageModel) storageModel;
path = localModel.getPath().getEntity();
storageDomain = isNew ? new StorageDomainStatic() : (StorageDomainStatic) Cloner.clone(selectedItem.getStorageStaticData());
saveBaseStorageProperties(model);
if (isNew) {
AsyncDataProvider.getInstance().getStorageDomainsByConnection(new AsyncQuery<>(storages -> {
if (storages != null && storages.size() > 0) {
handleDomainAlreadyExists(storages);
} else {
saveNewLocalStorage();
}
}), host.getStoragePoolId(), 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 updateOvfs.
private void updateOvfs() {
StorageDomain storage = getSelectedItem();
if (storage != null) {
StorageDomainParametersBase params = new StorageDomainParametersBase(storage.getId());
Frontend.getInstance().runAction(ActionType.UpdateOvfStoreForStorageDomain, params, null, this);
}
cancel();
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class VmBaseListModel method export.
protected void export() {
T selectedEntity = getSelectedItem();
if (selectedEntity == null) {
return;
}
if (getWindow() != null) {
return;
}
ExportVmModel model = new ExportVmModel();
setWindow(model);
model.startProgress();
setupExportModel(model);
AsyncDataProvider.getInstance().getStorageDomainList(new AsyncQuery<>(storageDomains -> {
List<StorageDomain> filteredStorageDomains = new ArrayList<>();
for (StorageDomain a : storageDomains) {
if (a.getStorageDomainType() == StorageDomainType.ImportExport) {
filteredStorageDomains.add(a);
}
}
postExportGetStorageDomainList(filteredStorageDomains);
}), extractStoragePoolIdNullSafe(selectedEntity));
// check, if the VM has a disk which doesn't allow snapshot
sendWarningForNonExportableDisks(selectedEntity);
}
Aggregations