use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class VolumeModel method addBricks.
public void addBricks() {
if (getWindow() != null || getCluster().getSelectedItem() == null) {
return;
}
final VolumeBrickModel volumeBrickModel = new VolumeBrickModel();
volumeBrickModel.getVolumeType().setEntity(getTypeList().getSelectedItem());
volumeBrickModel.getReplicaCount().setEntity(getReplicaCount().getEntity());
volumeBrickModel.getReplicaCount().setIsChangeable(true);
volumeBrickModel.getReplicaCount().setIsAvailable(getReplicaCount().getIsAvailable());
volumeBrickModel.getStripeCount().setEntity(getStripeCount().getEntity());
volumeBrickModel.getStripeCount().setIsChangeable(true);
volumeBrickModel.getStripeCount().setIsAvailable(getStripeCount().getIsAvailable());
Cluster cluster = getCluster().getSelectedItem();
if (cluster != null) {
volumeBrickModel.getForce().setIsAvailable(true);
volumeBrickModel.getForce().setEntity(isForceAddBricks());
volumeBrickModel.setIsBrickProvisioningSupported();
}
setWindow(volumeBrickModel);
volumeBrickModel.setTitle(ConstantsManager.getInstance().getConstants().addBricksTitle());
volumeBrickModel.setHelpTag(HelpTag.add_bricks);
// $NON-NLS-1$
volumeBrickModel.setHashName("add_bricks");
AsyncDataProvider.getInstance().getHostListByCluster(volumeBrickModel.asyncQuery(hostList -> {
Iterator<VDS> iterator = hostList.iterator();
while (iterator.hasNext()) {
if (iterator.next().getStatus() != VDSStatus.Up) {
iterator.remove();
}
}
volumeBrickModel.setHostList(hostList);
}), getCluster().getSelectedItem().getName());
// TODO: fetch the mount points to display
if (getBricks().getItems() != null) {
volumeBrickModel.getBricks().setItems(getBricks().getItems());
} else {
volumeBrickModel.getBricks().setItems(new ArrayList<EntityModel<GlusterBrickEntity>>());
}
// $NON-NLS-1$
UICommand command = UICommand.createDefaultOkUiCommand("OnAddBricks", this);
volumeBrickModel.getCommands().add(command);
// $NON-NLS-1$
volumeBrickModel.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class VolumeModel method clusterSelectedItemChanged.
private void clusterSelectedItemChanged() {
setBricks(new ListModel<EntityModel<GlusterBrickEntity>>());
if (getCluster().getSelectedItem() != null) {
final Cluster cluster = getCluster().getSelectedItem();
updateArbiterAvailability();
updateDefaults();
AsyncDataProvider.getInstance().isAnyHostUpInCluster(new AsyncQuery<>(returnValue -> {
// In case the result of previous call is returned after selecting some other cluster
if (!getCluster().getSelectedItem().getId().equals(cluster.getId())) {
return;
}
if (returnValue) {
getAddBricksCommand().setIsExecutionAllowed(true);
setMessage(null);
} else {
getAddBricksCommand().setIsExecutionAllowed(false);
setMessage(ConstantsManager.getInstance().getConstants().volumeEmptyClusterValidationMsg());
}
}), cluster.getName());
} else {
getAddBricksCommand().setIsExecutionAllowed(false);
setMessage(null);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class GlusterClusterSnapshotConfigModel method clusterSelectedItemChanged.
private void clusterSelectedItemChanged() {
Cluster selectedCluster = getClusters().getSelectedItem();
if (selectedCluster == null) {
return;
}
AsyncDataProvider.getInstance().getGlusterSnapshotConfig(new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {
@Override
public void onSuccess(QueryReturnValue returnValue) {
Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>> configs = returnValue.getReturnValue();
if (configs != null) {
List<GlusterVolumeSnapshotConfig> clusterConfigOptions = configs.getFirst();
Collections.sort(clusterConfigOptions, Comparator.comparing(GlusterVolumeSnapshotConfig::getParamName));
setModelItems(getClusterConfigOptions(), clusterConfigOptions, existingClusterConfigs);
} else {
getClusterConfigOptions().setItems(null);
}
}
private void setModelItems(ListModel<EntityModel<GlusterVolumeSnapshotConfig>> listModel, List<GlusterVolumeSnapshotConfig> cfgs, Map<String, String> fetchedCfgsBackup) {
List<EntityModel<GlusterVolumeSnapshotConfig>> coll = new ArrayList<>();
for (GlusterVolumeSnapshotConfig cfg : cfgs) {
EntityModel<GlusterVolumeSnapshotConfig> cfgModel = new EntityModel<>();
cfgModel.setEntity(cfg);
fetchedCfgsBackup.put(cfg.getParamName(), cfg.getParamValue());
coll.add(cfgModel);
}
// set the entity items
listModel.setItems(coll);
}
}), selectedCluster.getId(), null);
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class GlusterClusterSnapshotConfigModel method validate.
public boolean validate() {
boolean isValid = true;
setMessage(null);
Iterable<EntityModel<GlusterVolumeSnapshotConfig>> items1 = getClusterConfigOptions().getItems();
for (EntityModel<GlusterVolumeSnapshotConfig> model : items1) {
GlusterVolumeSnapshotConfig option = model.getEntity();
if (option.getParamValue().trim().length() == 0) {
setMessage(ConstantsManager.getInstance().getMessages().clusterSnapshotOptionValueEmpty(option.getParamName()));
isValid = false;
break;
}
}
return isValid;
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class InstanceImageLineModel method attachDisk.
public void attachDisk() {
if (parentModel.getUnitVmModel().getSelectedCluster() == null || parentModel.getUnitVmModel().getSelectedDataCenter() == null) {
return;
}
InstanceImagesAttachDiskModel model = new InstanceImagesAttachDiskModel() {
@Override
public void onSave() {
if (validate()) {
flush();
List<EntityModel<DiskModel>> selectedDisks = getSelectedDisks();
if (selectedDisks.size() == 1) {
// only 0 or 1 is allowed
setDisk(selectedDisks.iterator().next().getEntity().getDisk());
}
getDiskModel().setEntity(this);
InstanceImageLineModel.this.setChanged(true);
setDiskModel(null);
// from now on only editing is possible
attachCommand.setIsAvailable(false);
fillData();
}
}
@Override
public void updateInterface(Version clusterVersion) {
InstanceImageLineModel.this.updateInterface(clusterVersion, this);
}
@Override
protected void updateBootableDiskAvailable() {
updateBootableFrom(parentModel.getAllCurrentDisksModels());
}
@Override
protected List<Disk> getAttachedNotSubmittedDisks() {
return parentModel.getNotYetAttachedNotAttachableDisks();
}
};
VM realOrFakeVm = vm;
Version compatibilityVersion = parentModel.getUnitVmModel().getSelectedCluster().getCompatibilityVersion();
if (realOrFakeVm == null) {
realOrFakeVm = new VM();
realOrFakeVm.setId(null);
realOrFakeVm.setClusterId(parentModel.getUnitVmModel().getSelectedCluster().getId());
realOrFakeVm.setStoragePoolId(parentModel.getUnitVmModel().getSelectedDataCenter().getId());
realOrFakeVm.setClusterCompatibilityVersion(compatibilityVersion);
}
model.setVm(realOrFakeVm);
setupModelAsDialog(model, ConstantsManager.getInstance().getConstants().attachVirtualDiskTitle(), HelpTag.attach_virtual_disk, // $NON-NLS-1$
"attach_virtual_disk");
setDiskModel(model);
model.initialize(parentModel.getAllCurrentDisksModels());
maybeLoadAttachableDisks(model);
}
Aggregations