Search in sources :

Example 1 with AddVmFromSnapshotParameters

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);
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) AddVmFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with AddVmFromSnapshotParameters

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;
}
Also used : AddVmFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters)

Example 3 with AddVmFromSnapshotParameters

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));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Guid(org.ovirt.engine.core.compat.Guid) AddVmFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters)

Aggregations

AddVmFromSnapshotParameters (org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters)3 Guid (org.ovirt.engine.core.compat.Guid)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 UnitToGraphicsDeviceParamsBuilder (org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder)1