use of org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel in project ovirt-engine by oVirt.
the class ExistingPoolModelBehavior method postInitStorageDomains.
@Override
protected void postInitStorageDomains() {
ArrayList<DiskModel> disks = (ArrayList<DiskModel>) getModel().getDisks();
if (disks == null) {
return;
}
ActionGroup actionGroup = getModel().isCreateInstanceOnly() ? ActionGroup.CREATE_INSTANCE : ActionGroup.CREATE_VM;
StoragePool dataCenter = getModel().getSelectedDataCenter();
AsyncDataProvider.getInstance().getPermittedStorageDomainsByStoragePoolId(asyncQuery(storageDomains -> {
ArrayList<DiskModel> disks1 = (ArrayList<DiskModel>) getModel().getDisks();
ArrayList<StorageDomain> activeStorageDomains = filterStorageDomains(storageDomains);
DisksAllocationModel disksAllocationModel = getModel().getDisksAllocationModel();
disksAllocationModel.setActiveStorageDomains(activeStorageDomains);
getModel().getStorageDomain().setItems(activeStorageDomains);
for (DiskModel diskModel : disks1) {
// Setting Quota
diskModel.getQuota().setItems(getModel().getQuota().getItems());
diskModel.getQuota().setIsChangeable(false);
List<Guid> storageIds = ((DiskImage) diskModel.getDisk()).getStorageIds();
for (DiskImage disk : pool.getDiskList()) {
if (diskModel.getDisk() instanceof DiskImage && ((DiskImage) diskModel.getDisk()).getImageId().equals(disk.getImageTemplateId())) {
storageIds = new ArrayList<>(disk.getStorageIds());
break;
}
}
if (storageIds == null || storageIds.size() == 0) {
continue;
}
Guid storageId = storageIds.get(0);
StorageDomain storageDomain = activeStorageDomains.stream().filter(new Linq.IdPredicate<>(storageId)).findFirst().orElse(null);
List<StorageDomain> diskStorageDomains = new ArrayList<>();
diskStorageDomains.add(storageDomain);
diskModel.getStorageDomain().setItems(diskStorageDomains);
diskModel.getStorageDomain().setIsChangeable(false);
}
}), dataCenter.getId(), actionGroup);
getModel().getDisksAllocationModel().initializeAutoSelectTarget(false, actualPool.isAutoStorageSelect());
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel in project ovirt-engine by oVirt.
the class NewTemplateVmModelBehavior method initialize.
@Override
public void initialize() {
super.initialize();
getModel().getVmInitEnabled().setEntity(vm.getVmInit() != null);
getModel().getVmInitModel().init(vm.getStaticData());
getModel().getVmType().setIsChangeable(true);
getModel().getCopyPermissions().setIsAvailable(true);
DisksAllocationModel disksAllocationModel = getModel().getDisksAllocationModel();
disksAllocationModel.setIsVolumeFormatAvailable(true);
disksAllocationModel.setIsVolumeFormatChangeable(true);
disksAllocationModel.setIsAliasChangable(true);
disksAllocationModel.setContainer(getModel());
disksAllocationModel.setIsThinProvisioning(false);
AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(dataCenter -> {
if (dataCenter == null) {
disableNewTemplateModel(ConstantsManager.getInstance().getConstants().dataCenterIsNotAccessibleMsg());
} else {
AsyncDataProvider.getInstance().getClusterListByService(new AsyncQuery<>(clusters -> {
List<Cluster> filteredClusters = AsyncDataProvider.getInstance().filterByArchitecture(clusters, vm.getClusterArch());
getModel().setDataCentersAndClusters(getModel(), Arrays.asList(dataCenter), filteredClusters, vm.getClusterId());
initTemplate();
}), true, false);
AsyncDataProvider.getInstance().isSoundcardEnabled(new AsyncQuery<>(returnValue -> getModel().getIsSoundcardEnabled().setEntity(returnValue)), vm.getId());
}
}), vm.getStoragePoolId());
}
Aggregations