use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method saveNewNfsStorage.
public void saveNewNfsStorage() {
StorageModel model = (StorageModel) getWindow();
NfsStorageModel nfsModel = (NfsStorageModel) model.getCurrentStorageItem();
VDS host = model.getHost().getSelectedItem();
hostId = host.getId();
// Create storage connection.
StorageServerConnections storageConnection = new StorageServerConnections();
storageConnection.setConnection(path);
storageConnection.setStorageType(nfsModel.getType());
if (isConnectionOverriden()) {
storageConnection.setNfsVersion((NfsVersion) ((EntityModel) nfsModel.getVersion().getSelectedItem()).getEntity());
storageConnection.setNfsRetrans(nfsModel.getRetransmissions().asConvertible().nullableShort());
storageConnection.setNfsTimeo(nfsModel.getTimeout().asConvertible().nullableShort());
storageConnection.setMountOptions(nfsModel.getMountOptions().getEntity());
}
connection = storageConnection;
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
actionTypes.add(ActionType.AddStorageServerConnection);
actionTypes.add(ActionType.AddNFSStorageDomain);
actionTypes.add(ActionType.DisconnectStorageServerConnection);
parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
StorageDomainManagementParameter tempVar2 = new StorageDomainManagementParameter(storageDomain);
tempVar2.setVdsId(host.getId());
StoragePool dataCenter = model.getDataCenter().getSelectedItem();
tempVar2.setStoragePoolId(dataCenter.getId());
parameters.add(tempVar2);
parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
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();
};
IFrontendActionAsyncCallback callback3 = result -> {
StorageListModel storageListModel = (StorageListModel) result.getState();
StorageModel storageModel = (StorageModel) storageListModel.getWindow();
// Attach storage to data center as necessary.
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(callback1, callback2, callback3)), failureCallback, this);
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method onRemove.
private void onRemove() {
if (getSelectedItem() != null) {
StorageDomain storage = getSelectedItem();
RemoveStorageModel model = (RemoveStorageModel) getWindow();
if (!model.validate()) {
return;
}
VDS host = model.getHostList().getSelectedItem();
RemoveStorageDomainParameters tempVar = new RemoveStorageDomainParameters(storage.getId());
tempVar.setVdsId(host.getId());
tempVar.setDoFormat(model.getFormat().getEntity());
Frontend.getInstance().runAction(ActionType.RemoveStorageDomain, tempVar, null, this);
}
cancel();
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain 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);
}
use of org.ovirt.engine.core.common.businessentities.StorageDomain 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.StorageDomain in project ovirt-engine by oVirt.
the class StorageListModel method saveNewLocalStorage.
public void saveNewLocalStorage() {
StorageModel model = (StorageModel) getWindow();
LocalStorageModel localModel = (LocalStorageModel) model.getCurrentStorageItem();
VDS host = model.getHost().getSelectedItem();
hostId = host.getId();
// Create storage connection.
StorageServerConnections tempVar = new StorageServerConnections();
tempVar.setConnection(path);
tempVar.setStorageType(localModel.getType());
connection = tempVar;
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
actionTypes.add(ActionType.AddStorageServerConnection);
actionTypes.add(ActionType.AddLocalStorageDomain);
parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
StorageDomainManagementParameter tempVar2 = new StorageDomainManagementParameter(storageDomain);
tempVar2.setVdsId(host.getId());
parameters.add(tempVar2);
IFrontendActionAsyncCallback callback1 = result -> {
StorageListModel storageListModel = (StorageListModel) result.getState();
storageListModel.removeConnection = true;
ActionReturnValue actionReturnValue = result.getReturnValue();
storageListModel.storageDomain.setStorage((String) actionReturnValue.getActionReturnValue());
storageListModel.connection.setId((String) actionReturnValue.getActionReturnValue());
};
IFrontendActionAsyncCallback callback2 = result -> {
StorageListModel storageListModel = (StorageListModel) result.getState();
storageListModel.removeConnection = false;
storageListModel.onFinish(storageListModel.context, true, storageListModel.storageModel);
};
IFrontendActionAsyncCallback failureCallback = result -> {
StorageListModel storageListModel = (StorageListModel) result.getState();
if (storageListModel.removeConnection) {
storageListModel.cleanConnection(storageListModel.connection, storageListModel.hostId);
storageListModel.removeConnection = false;
}
storageListModel.onFinish(storageListModel.context, false, storageListModel.storageModel);
};
Frontend.getInstance().runMultipleActions(actionTypes, parameters, new ArrayList<>(Arrays.asList(new IFrontendActionAsyncCallback[] { callback1, callback2 })), failureCallback, this);
}
Aggregations