Search in sources :

Example 1 with AddVmParameters

use of org.ovirt.engine.core.common.action.AddVmParameters in project ovirt-engine by oVirt.

the class VmBaseListModel method saveNewVm.

private void saveNewVm(final UnitVmModel model) {
    if (model.getProgress() != null) {
        return;
    }
    model.startProgress();
    VM vm = getcurrentVm();
    if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
        vm.setId(new Guid(model.getVmId().getEntity()));
    }
    vm.setUseLatestVersion(model.getTemplateWithVersion().getSelectedItem().isLatest());
    AddVmParameters parameters = new AddVmParameters(vm);
    parameters.setDiskInfoDestinationMap(model.getDisksAllocationModel().getImageToDestinationDomainMap());
    parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
    parameters.setBalloonEnabled(balloonEnabled(model));
    parameters.setCopyTemplatePermissions(model.getCopyPermissions().getEntity());
    parameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
    parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
    parameters.setVmLargeIcon(IconUtils.filterPredefinedIcons(model.getIcon().getEntity().getIcon()));
    parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
    setVmWatchdogToParams(model, parameters);
    setRngDeviceToParams(model, parameters);
    if (model.getIsHeadlessModeEnabled().getEntity()) {
        parameters.getVmStaticData().setDefaultDisplayType(DisplayType.none);
    }
    BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
    if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
        parameters.setVmId(new Guid(model.getVmId().getEntity()));
    }
    Frontend.getInstance().runAction(model.getProvisioning().getEntity() ? ActionType.AddVmFromTemplate : ActionType.AddVm, parameters, createUnitVmModelNetworkAsyncCallback(vm, model), this);
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters)

Example 2 with AddVmParameters

use of org.ovirt.engine.core.common.action.AddVmParameters in project ovirt-engine by oVirt.

the class UpdateVmVersionCommand method buildAddVmParameters.

private AddVmParameters buildAddVmParameters() {
    AddVmParameters addVmParams = new AddVmParameters(getParameters().getVmStaticData());
    addVmParams.setPoolId(getParameters().getVmPoolId());
    addVmParams.setDiskInfoDestinationMap(buildDiskInfoDestinationMap());
    addVmParams.setConsoleEnabled(deviceExists(VmDeviceGeneralType.CONSOLE));
    addVmParams.setBalloonEnabled(deviceExists(VmDeviceGeneralType.BALLOON, VmDeviceType.MEMBALLOON));
    addVmParams.setSoundDeviceEnabled(deviceExists(VmDeviceGeneralType.SOUND));
    addVmParams.setVirtioScsiEnabled(deviceExists(VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI));
    List<VmWatchdog> watchdogs = runInternalQuery(QueryType.GetWatchdog, new IdQueryParameters(getVmTemplateId())).getReturnValue();
    if (!watchdogs.isEmpty()) {
        addVmParams.setWatchdog(watchdogs.get(0));
    }
    loadVmPayload(addVmParams);
    // then there is no session, so using the current user.
    if (StringUtils.isEmpty(getParameters().getSessionId())) {
        addVmParams.setParametersCurrentUser(getCurrentUser());
    } else {
        addVmParams.setSessionId(getParameters().getSessionId());
    }
    addVmParams.setDiskOperatorAuthzPrincipalDbId(getParameters().getPreviousDiskOperatorAuthzPrincipalDbId());
    // reset vm to not initialized
    addVmParams.getVmStaticData().setInitialized(false);
    return addVmParams;
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 3 with AddVmParameters

use of org.ovirt.engine.core.common.action.AddVmParameters in project ovirt-engine by oVirt.

the class AddUnmanagedVmsCommand method addExternallyManagedVm.

// Visible for testing
protected void addExternallyManagedVm(VmStatic vmStatic) {
    ActionReturnValue returnValue = runInternalAction(ActionType.AddVmFromScratch, new AddVmParameters(vmStatic), createAddExternalVmContext(vmStatic));
    if (!returnValue.getSucceeded()) {
        log.debug("Failed adding Externally managed VM '{}'", vmStatic.getName());
        return;
    }
    resourceManager.getVmManager(vmStatic.getId()).update(vmStatic);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters)

Example 4 with AddVmParameters

use of org.ovirt.engine.core.common.action.AddVmParameters in project ovirt-engine by oVirt.

the class BackendVmsResource method cloneVmFromTemplate.

private Response cloneVmFromTemplate(VmStatic staticVm, Vm vm, VmTemplate template, InstanceType instanceType, Cluster cluster) {
    AddVmParameters params = new AddVmParameters(staticVm);
    params.setDiskInfoDestinationMap(getDisksToClone(vm.getDiskAttachments(), template.getId()));
    params.setVmPayload(getPayload(vm));
    addDevicesToParams(params, vm, template, instanceType, staticVm, cluster);
    IconHelper.setIconToParams(vm, params);
    params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
    setupCloneTemplatePermissions(params);
    DisplayHelper.setGraphicsToParams(vm.getDisplay(), params);
    return performCreate(ActionType.AddVmFromTemplate, params, new QueryIdResolver<Guid>(QueryType.GetVmByVmId, IdQueryParameters.class));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters)

Example 5 with AddVmParameters

use of org.ovirt.engine.core.common.action.AddVmParameters in project ovirt-engine by oVirt.

the class BackendVmsResource method addVm.

protected Response addVm(VmStatic staticVm, Vm vm, Guid storageDomainId, VmTemplate template, InstanceType instanceType, Cluster cluster) {
    AddVmParameters params = new AddVmParameters(staticVm);
    params.setVmPayload(getPayload(vm));
    params.setStorageDomainId(storageDomainId);
    params.setDiskInfoDestinationMap(getDisksToClone(vm.getDiskAttachments(), template.getId()));
    params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
    setupCloneTemplatePermissions(params);
    addDevicesToParams(params, vm, template, instanceType, staticVm, cluster);
    IconHelper.setIconToParams(vm, params);
    DisplayHelper.setGraphicsToParams(vm.getDisplay(), params);
    return performCreate(ActionType.AddVm, params, new QueryIdResolver<Guid>(QueryType.GetVmByVmId, IdQueryParameters.class));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters)

Aggregations

AddVmParameters (org.ovirt.engine.core.common.action.AddVmParameters)7 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Guid (org.ovirt.engine.core.compat.Guid)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VmRngDevice (org.ovirt.engine.core.common.businessentities.VmRngDevice)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)1 VmIconIdSizePair (org.ovirt.engine.core.common.queries.VmIconIdSizePair)1 UnitToGraphicsDeviceParamsBuilder (org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder)1