use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class RegisterDiskModel method onExecute.
private void onExecute() {
if (getProgress() != null) {
return;
}
startProgress();
for (DiskModel item : getDisks()) {
DiskImage disk = (DiskImage) item.getDisk();
if (item.getQuota().getSelectedItem() != null) {
disk.setQuotaId(item.getQuota().getSelectedItem().getId());
}
RegisterDiskParameters registerDiskParams = new RegisterDiskParameters(disk, disk.getStorageIds().get(0));
registerDiskParams.setRefreshFromStorage(true);
Frontend.getInstance().runMultipleAction(ActionType.RegisterDisk, Arrays.asList(registerDiskParams));
}
stopProgress();
getCancelCommand().execute();
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class DisksAllocationModel method updateImageToDestinationDomainMap.
private void updateImageToDestinationDomainMap() {
if (disks == null) {
return;
}
for (DiskModel diskModel : disks) {
StorageDomain storageDomain = diskModel.getStorageDomain().getSelectedItem();
DiskImage diskImage = (DiskImage) diskModel.getDisk();
diskImage.setStorageIds(new ArrayList<>(Collections.singletonList(storageDomain.getId())));
diskImage.setDiskAlias(diskModel.getAlias().getEntity());
DiskProfile diskProfile = diskModel.getDiskProfile().getSelectedItem();
diskImage.setDiskProfileId(diskProfile != null ? diskProfile.getId() : null);
if (diskModel.getQuota().getSelectedItem() != null) {
diskImage.setQuotaId(diskModel.getQuota().getSelectedItem().getId());
}
if (diskModel.getVolumeFormat().getIsAvailable()) {
VolumeFormat volumeFormat = diskModel.getVolumeFormat().getSelectedItem();
diskImage.setVolumeFormat(volumeFormat);
diskImage.setVolumeType(AsyncDataProvider.getInstance().getVolumeType(volumeFormat, storageDomain.getStorageType()));
} else if (diskModel.getVolumeType().getIsAvailable()) {
VolumeType volumeType = diskModel.getVolumeType().getSelectedItem();
diskImage.setVolumeType(volumeType);
diskImage.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(volumeType, storageDomain.getStorageType()));
}
imageToDestinationDomainMap.put(diskImage.getId(), diskImage);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class DisksAllocationModel method setDisks.
public void setDisks(List<DiskModel> value) {
disks = value;
if (disks == null) {
return;
}
sortDisks();
setDefaultVolumeInformationSelection(disks);
for (final DiskModel diskModel : disks) {
diskModel.getStorageDomain().getSelectedItemChangedEvent().removeListener(storageDomainEventListener);
diskModel.getStorageDomain().getSelectedItemChangedEvent().addListener(storageDomainEventListener);
diskModel.getStorageDomain().getItemsChangedEvent().addListener((ev, sender, args) -> {
DiskImage disk = (DiskImage) diskModel.getDisk();
if (diskModel.getStorageDomain().getItems() != null && disk.getStorageIds() != null && !disk.getStorageIds().isEmpty() && !diskModel.getStorageDomain().getItems().isEmpty()) {
diskModel.getStorageDomain().setSelectedItem(Linq.firstOrDefault(diskModel.getStorageDomain().getItems(), new Linq.IdsPredicate<>(disk.getStorageIds()), diskModel.getStorageDomain().getItems().iterator().next()));
}
});
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class DisksAllocationModel method updateDisks.
private void updateDisks(Object sender) {
StorageDomain storageDomain = ((ListModel<StorageDomain>) sender).getSelectedItem();
if (storageDomain != null) {
for (DiskModel innerDisk : disks) {
if (innerDisk.getStorageDomain().equals(sender)) {
Guid diskQuotaId = null;
if (innerDisk.getDisk() instanceof DiskImage) {
DiskImage img = (DiskImage) innerDisk.getDisk();
diskQuotaId = img.getQuotaId();
}
updateQuota(storageDomain.getId(), innerDisk.getQuota(), diskQuotaId);
updateDiskProfile(storageDomain.getId(), innerDisk.getDiskProfile());
break;
}
}
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class DisksAllocationModel method updateTargetChangeable.
public void updateTargetChangeable(boolean enabled) {
if (disks != null) {
for (DiskModel diskModel : disks) {
diskModel.getStorageDomain().setIsChangeable(enabled);
diskModel.getDiskProfile().setIsChangeable(enabled);
}
}
}
Aggregations