use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class StoragePopupView method edit.
@Override
public void edit(StorageModel object) {
driver.edit(object);
final StorageModel storageModel = object;
storageModel.getAvailableStorageDomainTypeItems().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
// Display the StorageTypes according to the selected StorageDomainFunction.
updateStorageTypesByDomainType(storageModel);
});
storageModel.getAvailableStorageTypeItems().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
// Reveal the appropriate storage view according to the selected storage type
revealStorageView(storageModel);
});
storageModel.getDataCenterAlert().getEntityChangedEvent().addListener((ev, sender, args) -> {
datacenterAlertIcon.setVisible(storageModel.getDataCenterAlert().getIsAvailable());
datacenterAlertIcon.setTitle(storageModel.getDataCenterAlert().getEntity());
});
warningLowSpaceIndicatorEditor.addKeyUpHandler(event -> {
if (!storageModel.isNewStorage()) {
storageModel.getWarningLowSpaceSize().setEntity(ConstantsManager.getInstance().getMessages().bracketsWithGB(getWarningLowSpaceSize(storageModel)));
}
});
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class VmDiskPopupWidget method edit.
@Override
@SuppressWarnings("unchecked")
public void edit(final AbstractDiskModel disk) {
driver.edit(disk);
disk.getIsDirectLunDiskAvaialable().getEntityChangedEvent().addListener((ev, sender, args) -> {
boolean isDirectLunDiskAvaialable = ((EntityModel<Boolean>) sender).getEntity();
externalDiskPanel.setVisible(isDirectLunDiskAvaialable);
});
disk.getIsUsingScsiReservation().getPropertyChangedEvent().addListener((ev, sender, args) -> {
if ("Entity".equals(args.propertyName) || "IsAvailable".equals(args.propertyName)) {
// $NON-NLS-1$ $NON-NLS-2$
EntityModel<Boolean> entity = disk.getIsUsingScsiReservation();
scsiReservationInfoIcon.setVisible(entity.getEntity() && entity.getIsAvailable());
}
});
disk.getIsVirtioScsiEnabled().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (disk.getVm() == null) {
// not relevant for floating disks
return;
}
boolean isVirtioScsiEnabled = ((EntityModel<Boolean>) sender).getEntity();
// Show the info icon if VirtIO-SCSI is supported by the cluster but disabled for the VM
interfaceInfoIcon.setVisible(!isVirtioScsiEnabled);
// Make room for it by making the control widget narrower
interfaceEditor.removeWidgetColSize(isVirtioScsiEnabled ? ColumnSize.SM_7 : ColumnSize.SM_8);
interfaceEditor.addWidgetColSize(!isVirtioScsiEnabled ? ColumnSize.SM_7 : ColumnSize.SM_8);
});
disk.getCinderVolumeType().getItemsChangedEvent().addListener((ev, sender, args) -> {
Collection<String> volumeTypes = disk.getCinderVolumeType().getItems();
boolean showIcon = volumeTypes == null || volumeTypes.isEmpty();
cinderVolumeTypeInfoIcon.setVisible(showIcon);
cinderVolumeTypeEditor.removeWidgetColSize(!showIcon ? ColumnSize.SM_7 : ColumnSize.SM_8);
cinderVolumeTypeEditor.addWidgetColSize(showIcon ? ColumnSize.SM_7 : ColumnSize.SM_8);
});
disk.getIsModelDisabled().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (disk.getIsModelDisabled().getEntity()) {
disableWidget(getWidget());
enableWidget(radioButtonPanel);
enableWidget(datacenterEditor);
disk.getDefaultCommand().setIsExecutionAllowed(false);
disk.setIsChangeable(false);
} else {
enableWidget(getWidget());
disk.getDefaultCommand().setIsExecutionAllowed(true);
disk.setIsChangeable(true);
driver.edit(disk);
}
});
radioButtonPanel.addRadioButton(constants.imageDisk(), disk.getDisk() == null || disk.getDisk().getDiskStorageType() == DiskStorageType.IMAGE, disk.getIsNew(), event -> {
if (disk.getIsNew()) {
disk.getDiskStorageType().setEntity(DiskStorageType.IMAGE);
revealDiskPanel(disk);
}
});
radioButtonPanel.addRadioButton(constants.directLunDisk(), disk.getDisk() != null && disk.getDisk().getDiskStorageType() == DiskStorageType.LUN, disk.getIsNew(), event -> {
if (disk.getIsNew()) {
disk.getDiskStorageType().setEntity(DiskStorageType.LUN);
revealStorageView(disk);
revealDiskPanel(disk);
}
});
radioButtonPanel.addRadioButton(constants.cinderDisk(), disk.getDisk() != null && disk.getDisk().getDiskStorageType() == DiskStorageType.CINDER, disk.getIsNew(), event -> {
if (disk.getIsNew()) {
disk.getDiskStorageType().setEntity(DiskStorageType.CINDER);
revealDiskPanel(disk);
}
});
if (disk.getStorageModel() == null) {
storageModel = new StorageModel(new NewEditStorageModelBehavior());
// Create IscsiStorageModel
iscsiStorageModel = new IscsiStorageModel();
iscsiStorageModel.setContainer(storageModel);
iscsiStorageModel.setIsGroupedByTarget(true);
iscsiStorageModel.setIgnoreGrayedOut(true);
// Create FcpStorageModel
fcpStorageModel = new FcpStorageModel();
fcpStorageModel.setContainer(storageModel);
fcpStorageModel.setIsGroupedByTarget(false);
fcpStorageModel.setIgnoreGrayedOut(true);
// Set 'StorageModel' items
ArrayList<IStorageModel> items = new ArrayList<>();
items.add(iscsiStorageModel);
items.add(fcpStorageModel);
storageModel.setStorageModels(items);
storageModel.setHost(disk.getHost());
disk.setStorageModel(storageModel);
} else {
storageModel = disk.getStorageModel();
iscsiStorageModel = Linq.findByType(storageModel.getStorageModels(), IscsiStorageModel.class);
iscsiStorageModel.getPropertyChangedEvent().clearListeners();
fcpStorageModel = Linq.findByType(storageModel.getStorageModels(), FcpStorageModel.class);
fcpStorageModel.getPropertyChangedEvent().clearListeners();
}
iscsiStorageView = new IscsiStorageView(false, 196, 304, 244, 275, 142, 55, -67);
iscsiStorageView.setBarTop(0, Unit.PX);
iscsiStorageView.edit(iscsiStorageModel);
fcpStorageView = new FcpStorageView(false, 278, 240);
fcpStorageView.edit(fcpStorageModel);
// SelectedItemChangedEvent handlers
disk.getStorageType().getSelectedItemChangedEvent().addListener((ev, sender, args) -> revealStorageView(disk));
disk.getHost().getSelectedItemChangedEvent().addListener((ev, sender, args) -> revealStorageView(disk));
disk.getDiskStorageType().getPropertyChangedEvent().addListener((ev, sender, args) -> {
String propName = args.propertyName;
if ("IsChangable".equals(propName)) {
// $NON-NLS-1$
if (disk.getDiskStorageType().getIsChangable() && disk.isEditEnabled()) {
enableWidget(radioButtonPanel);
} else {
disableWidget(radioButtonPanel);
}
}
});
revealStorageView(disk);
revealDiskPanel(disk);
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel 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 tempVar = new StorageServerConnections();
tempVar.setConnection(path);
tempVar.setStorageType(nfsModel.getType());
connection = tempVar;
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());
parameters.add(tempVar2);
parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
IFrontendActionAsyncCallback callback1 = result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
ActionReturnValue actionReturnValue = result.getReturnValue();
dataCenterGuideModel.storageDomain.setStorage((String) actionReturnValue.getActionReturnValue());
};
IFrontendActionAsyncCallback callback2 = result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
ActionReturnValue actionReturnValue = result.getReturnValue();
dataCenterGuideModel.storageId = actionReturnValue.getActionReturnValue();
};
IFrontendActionAsyncCallback callback3 = result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
StorageModel storageModel = (StorageModel) dataCenterGuideModel.getWindow();
// Attach storage to data center as neccessary.
StoragePool dataCenter = storageModel.getDataCenter().getSelectedItem();
if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
dataCenterGuideModel.attachStorageToDataCenter(dataCenterGuideModel.storageId, dataCenter.getId());
}
dataCenterGuideModel.onFinish(dataCenterGuideModel.context, true, dataCenterGuideModel.storageModel);
};
IFrontendActionAsyncCallback failureCallback = result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
dataCenterGuideModel.cleanConnection(dataCenterGuideModel.connection, dataCenterGuideModel.hostId);
dataCenterGuideModel.onFinish(dataCenterGuideModel.context, false, dataCenterGuideModel.storageModel);
};
Frontend.getInstance().runMultipleActions(actionTypes, parameters, new ArrayList<>(Arrays.asList(new IFrontendActionAsyncCallback[] { callback1, callback2, callback3 })), failureCallback, this);
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel 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 -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
dataCenterGuideModel.removeConnection = true;
ActionReturnValue actionReturnValue = result.getReturnValue();
dataCenterGuideModel.storageDomain.setStorage((String) actionReturnValue.getActionReturnValue());
};
IFrontendActionAsyncCallback callback2 = result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
dataCenterGuideModel.removeConnection = false;
dataCenterGuideModel.onFinish(dataCenterGuideModel.context, true, dataCenterGuideModel.storageModel);
};
IFrontendActionAsyncCallback failureCallback = result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
if (dataCenterGuideModel.removeConnection) {
dataCenterGuideModel.cleanConnection(dataCenterGuideModel.connection, dataCenterGuideModel.hostId);
dataCenterGuideModel.removeConnection = false;
}
dataCenterGuideModel.onFinish(dataCenterGuideModel.context, false, dataCenterGuideModel.storageModel);
};
Frontend.getInstance().runMultipleActions(actionTypes, parameters, new ArrayList<>(Arrays.asList(new IFrontendActionAsyncCallback[] { callback1, callback2 })), failureCallback, this);
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method saveSanStorage.
private void saveSanStorage(final TaskContext context) {
this.context = context;
StorageModel model = (StorageModel) getWindow();
SanStorageModelBase sanModel = (SanStorageModelBase) model.getCurrentStorageItem();
storageDomain = new StorageDomainStatic();
storageDomain.setStorageType(sanModel.getType());
storageDomain.setStorageDomainType(sanModel.getRole());
storageDomain.setStorageFormat(sanModel.getContainer().getFormat().getSelectedItem());
storageDomain.setStorageName(model.getName().getEntity());
AsyncDataProvider.getInstance().getStorageDomainsByConnection(new AsyncQuery<>(storages -> {
if (storages != null && storages.size() > 0) {
String storageName = storages.get(0).getStorageName();
onFinish(context, false, storageModel, ConstantsManager.getInstance().getMessages().createOperationFailedDcGuideMsg(storageName));
} else {
saveNewSanStorage();
}
getWindow().stopProgress();
}), null, path);
}
Aggregations