Search in sources :

Example 6 with AddVmParameters

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

the class BackendVmsResource method addVmFromScratch.

protected Response addVmFromScratch(VmStatic staticVm, Vm vm, InstanceType instanceType, Cluster cluster) {
    AddVmParameters params = new AddVmParameters(staticVm);
    params.setVmPayload(getPayload(vm));
    params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
    addDevicesToParams(params, vm, null, instanceType, staticVm, cluster);
    IconHelper.setIconToParams(vm, params);
    DisplayHelper.setGraphicsToParams(vm.getDisplay(), params);
    return performCreate(ActionType.AddVmFromScratch, 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 7 with AddVmParameters

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

the class CommonVmPoolCommand method buildAddVmParameters.

private AddVmParameters buildAddVmParameters(String vmName) {
    VmStatic currVm = new VmStatic(getParameters().getVmStaticData());
    currVm.setName(vmName);
    currVm.setStateless(!getVmPool().isStateful());
    if (getParameters().getVmLargeIcon() != null) {
        final VmIconIdSizePair iconIds = iconUtils.ensureIconPairInDatabase(getParameters().getVmLargeIcon());
        currVm.setSmallIconId(iconIds.getSmall());
        currVm.setLargeIconId(iconIds.getLarge());
    }
    AddVmParameters parameters = new AddVmParameters(currVm);
    parameters.setPoolId(getVmPool().getVmPoolId());
    if (getVmPool().isAutoStorageSelect()) {
        parameters.setDiskInfoDestinationMap(autoSelectTargetDomainAndVolumeFormat());
    } else {
        parameters.setDiskInfoDestinationMap(diskInfoDestinationMap);
    }
    if (StringUtils.isEmpty(getParameters().getSessionId())) {
        parameters.setParametersCurrentUser(getCurrentUser());
    } else {
        parameters.setSessionId(getParameters().getSessionId());
    }
    parameters.setParentCommand(getActionType());
    parameters.setParentParameters(getParameters());
    // check if device is enabled or we need to override it to true
    parameters.setSoundDeviceEnabled(Boolean.TRUE.equals(getParameters().isSoundDeviceEnabled()) || vmDeviceUtils.shouldOverrideSoundDevice(getParameters().getVmStaticData(), getEffectiveCompatibilityVersion(), getParameters().isSoundDeviceEnabled()));
    parameters.setConsoleEnabled(getParameters().isConsoleEnabled());
    parameters.setVirtioScsiEnabled(getParameters().isVirtioScsiEnabled());
    parameters.setBalloonEnabled(getParameters().isBalloonEnabled());
    parameters.setEndProcedure(EndProcedure.COMMAND_MANAGED);
    VmRngDevice rngDevice = getParameters().getRngDevice();
    if (rngDevice != null) {
        parameters.setUpdateRngDevice(true);
        parameters.setRngDevice(rngDevice);
    }
    parameters.getGraphicsDevices().putAll(getParameters().getGraphicsDevices());
    return parameters;
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

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