use of org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters 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.action.AddVmFromSnapshotParameters in project ovirt-engine by oVirt.
the class AddVmFromSnapshotCommandTest method createCommand.
@Override
protected AddVmFromSnapshotCommand<AddVmFromSnapshotParameters> createCommand() {
AddVmFromSnapshotParameters param = new AddVmFromSnapshotParameters();
param.setVm(vm);
param.setSourceSnapshotId(SOURCE_SNAPSHOT_ID);
param.setStorageDomainId(Guid.newGuid());
AddVmFromSnapshotCommand<AddVmFromSnapshotParameters> cmd = new AddVmFromSnapshotCommand<>(param, null);
cmd.setVm(vm);
cmd.setVmId(vm.getId());
return cmd;
}
use of org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters in project ovirt-engine by oVirt.
the class BackendVmsResource method cloneVmFromSnapshot.
private Response cloneVmFromSnapshot(org.ovirt.engine.core.common.businessentities.VM configVm, Vm vm, String snapshotId, HashMap<Guid, DiskImage> images) {
VmStatic staticVm = configVm.getStaticData();
Guid sourceSnapshotId = asGuid(snapshotId);
AddVmFromSnapshotParameters params = new AddVmFromSnapshotParameters(staticVm, sourceSnapshotId);
params.setDiskInfoDestinationMap(images);
params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
params.setVirtioScsiEnabled(vm.isSetVirtioScsi() && vm.getVirtioScsi().isSetEnabled() ? vm.getVirtioScsi().isEnabled() : null);
if (vm.isSetSoundcardEnabled()) {
params.setSoundDeviceEnabled(vm.isSoundcardEnabled());
} else {
params.setSoundDeviceEnabled(isVMDeviceTypeExist(configVm.getManagedVmDeviceMap(), VmDeviceGeneralType.SOUND));
}
params.setConsoleEnabled(vm.isSetConsole() && vm.getConsole().isSetEnabled() ? vm.getConsole().isEnabled() : !getConsoleDevicesForEntity(staticVm.getId()).isEmpty());
if (vm.isSetRngDevice()) {
params.setUpdateRngDevice(true);
params.setRngDevice(RngDeviceMapper.map(vm.getRngDevice(), null));
}
DisplayHelper.setGraphicsToParams(vm.getDisplay(), params);
return performCreate(ActionType.AddVmFromSnapshot, params, new QueryIdResolver<Guid>(QueryType.GetVmByVmId, IdQueryParameters.class));
}
Aggregations