use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method initTemplateDisks.
protected void initTemplateDisks(List<DiskImage> disks) {
disks.sort(new DiskByDiskAliasComparator());
ArrayList<DiskModel> list = new ArrayList<>();
for (DiskImage disk : disks) {
DiskModel diskModel = new DiskModel();
diskModel.getAlias().setEntity(disk.getDiskAlias());
diskModel.getVolumeType().setIsAvailable(false);
switch(disk.getDiskStorageType()) {
case IMAGE:
diskModel.setSize(new EntityModel<>((int) disk.getSizeInGigabytes()));
ListModel volumes = new ListModel();
volumes.setItems(disk.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Collections.singletonList(VolumeType.Preallocated)) : AsyncDataProvider.getInstance().getVolumeTypeList(), disk.getVolumeType());
diskModel.setVolumeType(volumes);
break;
case CINDER:
CinderDisk cinderDisk = (CinderDisk) disk;
diskModel.setSize(new EntityModel<>((int) cinderDisk.getSizeInGigabytes()));
ListModel volumeTypes = new ListModel();
volumeTypes.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeType())), cinderDisk.getVolumeType());
diskModel.setVolumeType(volumeTypes);
ListModel volumeFormats = new ListModel();
volumeFormats.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeFormat())), cinderDisk.getVolumeFormat());
diskModel.setVolumeFormat(volumeFormats);
break;
}
diskModel.setDisk(disk);
list.add(diskModel);
}
getModel().setDisks(list);
updateIsDisksAvailable();
initStorageDomains();
}
use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator in project ovirt-engine by oVirt.
the class StorageRegisterDiskListModel method syncSearch.
@Override
protected void syncSearch() {
if (getEntity() == null) {
return;
}
IdQueryParameters parameters = new IdQueryParameters(getEntity().getId());
parameters.setRefresh(getIsQueryFirstTime());
Frontend.getInstance().runQuery(QueryType.GetUnregisteredCinderDisksByStorageDomainId, parameters, new SetSortedItemsAsyncQuery(new DiskByDiskAliasComparator()));
}
use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator in project ovirt-engine by oVirt.
the class VmDiskListModel method setItems.
@Override
public void setItems(Collection value) {
ArrayList<Disk> disks = value != null ? new ArrayList<>(value) : new ArrayList<Disk>();
Collections.sort(disks, new DiskByDiskAliasComparator());
super.setItems(disks);
updateActionAvailability();
}
use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator in project ovirt-engine by oVirt.
the class SnapshotModel method updateVmConfiguration.
public void updateVmConfiguration(final AsyncCallback<Void> onUpdateAsyncCallback) {
Snapshot snapshot = getEntity();
if (snapshot == null) {
return;
}
AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(vm -> {
Snapshot snapshot1 = getEntity();
if (vm != null && snapshot1 != null) {
setVm(vm);
setDisks(vm.getDiskList());
setNics(vm.getInterfaces());
setApps(Arrays.asList(snapshot1.getAppList() != null ? snapshot1.getAppList().split(",") : // $NON-NLS-1$
new String[] {}));
Collections.sort(getDisks(), new DiskByDiskAliasComparator());
Collections.sort(getNics(), new LexoNumericNameableComparator<>());
}
onUpdateAsyncCallback.onSuccess(null);
}), snapshot.getId());
}
use of org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator in project ovirt-engine by oVirt.
the class GetVmTemplatesFromStorageDomainQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
List<VmTemplate> returnValue = vmTemplateDao.getAllForStorageDomain(getParameters().getId(), getUserID(), getParameters().isFiltered());
if (getParameters().isWithDisks()) {
for (VmTemplate template : returnValue) {
vmTemplateHandler.updateDisksFromDb(template);
Collections.sort(template.getDiskList(), new DiskByDiskAliasComparator());
}
}
Collections.sort(returnValue, Comparator.comparing(VmTemplate::getActualDiskSize).reversed());
getQueryReturnValue().setReturnValue(returnValue);
}
Aggregations