use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method postInitStorageDomains.
protected void postInitStorageDomains() {
if (getModel().getDisks() == null) {
return;
}
ActionGroup actionGroup = getModel().isCreateInstanceOnly() ? ActionGroup.CREATE_INSTANCE : ActionGroup.CREATE_VM;
StoragePool dataCenter = getModel().getSelectedDataCenter();
AsyncDataProvider.getInstance().getPermittedStorageDomainsByStoragePoolId(new AsyncQuery<>(storageDomains -> {
ArrayList<StorageDomain> activeStorageDomains = filterStorageDomains(storageDomains);
boolean provisioning = getModel().getProvisioning().getEntity();
ArrayList<DiskModel> disks = (ArrayList<DiskModel>) getModel().getDisks();
activeStorageDomains.sort(new NameableComparator());
List<DiskModel> diskImages = Linq.filterDisksByType(disks, DiskStorageType.IMAGE);
for (DiskModel diskModel : diskImages) {
List<StorageDomain> availableDiskStorageDomains;
diskModel.getQuota().setItems(getModel().getQuota().getItems());
List<Guid> storageIds = ((DiskImage) diskModel.getDisk()).getStorageIds();
// Active storage domains that the disk resides on
List<StorageDomain> activeDiskStorageDomains = Linq.getStorageDomainsByIds(storageIds, activeStorageDomains);
// Set target storage domains
availableDiskStorageDomains = provisioning ? activeStorageDomains : activeDiskStorageDomains;
availableDiskStorageDomains.sort(new NameableComparator());
diskModel.getStorageDomain().setItems(availableDiskStorageDomains);
diskModel.getStorageDomain().setChangeProhibitionReason(constants.noActiveTargetStorageDomainAvailableMsg());
diskModel.getStorageDomain().setIsChangeable(!availableDiskStorageDomains.isEmpty());
}
List<DiskModel> cinderDisks = Linq.filterDisksByType(disks, DiskStorageType.CINDER);
Collection<StorageDomain> cinderStorageDomains = Linq.filterStorageDomainsByStorageType(storageDomains, StorageType.CINDER);
initStorageDomainsForCinderDisks(cinderDisks, cinderStorageDomains);
}), dataCenter.getId(), actionGroup);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class VmSnapshotListModel method onPreview.
private void onPreview() {
Snapshot snapshot = getSelectedItem();
if (snapshot == null) {
cancel();
return;
}
VM vm = getEntity();
SnapshotModel snapshotModel = (SnapshotModel) getWindow();
boolean memory = false;
List<DiskImage> disks = null;
if (snapshotModel.isShowPartialSnapshotWarning()) {
switch(snapshotModel.getPartialPreviewSnapshotOptions().getSelectedItem()) {
case preserveActiveDisks:
// get snapshot disks
disks = snapshotModel.getDisks();
// add active disks missed from snapshot
disks.addAll(imagesSubtract(getVmDisks(), disks));
break;
case excludeActiveDisks:
// nothing to do - default behaviour
break;
case openCustomPreviewDialog:
setWindow(null);
getCustomPreviewCommand().execute();
return;
}
}
if (snapshotModel.isShowMemorySnapshotWarning()) {
memory = snapshotModel.getMemory().getEntity();
}
runTryBackToAllSnapshotsOfVm(snapshotModel, vm, snapshot, memory, disks, true, null);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class VmSnapshotListModel method updateVmActiveDisks.
private void updateVmActiveDisks() {
VM vm = getEntity();
if (vm == null) {
return;
}
AsyncDataProvider.getInstance().getVmDiskList(new AsyncQuery<>(disks -> {
setVmDisks(disks.stream().filter(d -> d.getDiskStorageType() != DiskStorageType.LUN).map(d -> (DiskImage) d).collect(Collectors.toList()));
}), vm.getId());
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class VmSnapshotListModel method onCloneVM.
private void onCloneVM() {
UnitVmModel model = (UnitVmModel) getWindow();
CloneVmFromSnapshotModelBehavior behavior = (CloneVmFromSnapshotModelBehavior) model.getBehavior();
Snapshot snapshot = getSelectedItem();
if (snapshot == null) {
cancel();
return;
}
if (!model.validate()) {
return;
}
VM vm = behavior.getVm();
// Save changes.
buildVmOnClone(model, vm);
vm.setUseHostCpuFlags(model.getHostCpu().getEntity());
vm.setDiskMap(behavior.getVm().getDiskMap());
HashMap<Guid, DiskImage> imageToDestinationDomainMap = model.getDisksAllocationModel().getImageToDestinationDomainMap();
AddVmFromSnapshotParameters parameters = new AddVmFromSnapshotParameters(vm.getStaticData(), snapshot.getId());
parameters.setDiskInfoDestinationMap(imageToDestinationDomainMap);
parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
parameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
parameters.setVmId(new Guid(model.getVmId().getEntity()));
}
model.startProgress();
Frontend.getInstance().runAction(ActionType.AddVmFromSnapshot, parameters, result -> {
VmSnapshotListModel vmSnapshotListModel = (VmSnapshotListModel) result.getState();
vmSnapshotListModel.getWindow().stopProgress();
ActionReturnValue returnValueBase = result.getReturnValue();
if (returnValueBase != null && returnValueBase.getSucceeded()) {
vmSnapshotListModel.cancel();
vmSnapshotListModel.updateActionAvailability();
}
}, this);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class AddVmCommand method validateSpaceRequirements.
/**
* Check if destination storage has enough space
*/
protected boolean validateSpaceRequirements() {
for (Map.Entry<Guid, List<DiskImage>> sdImageEntry : storageToDisksMap.entrySet()) {
StorageDomain destStorageDomain = destStorages.get(sdImageEntry.getKey());
List<DiskImage> disksList = sdImageEntry.getValue();
StorageDomainValidator storageDomainValidator = createStorageDomainValidator(destStorageDomain);
if (!validateDomainsThreshold(storageDomainValidator) || !validateFreeSpace(storageDomainValidator, disksList)) {
return false;
}
}
return true;
}
Aggregations