Search in sources :

Example 6 with VmIconIdSizePair

use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.

the class AddVmCommand method setIconIds.

/**
 * Icon processing policy:
 * <ul>
 *     <li>If there is an attached icon, it is used as large icon as base for computation of small icon.
 *         Predefined icons should not be sent in parameters.</li>
 *     <li>If there are no icon in parameters && both (small and large) icon ids are set then those ids are used.
 *         </li>
 *     <li>Otherwise (at least one icon id is null) both icon ids are copied from template.</li>
 * </ul>
 */
private void setIconIds(VmStatic vmStatic) {
    if (getParameters().getVmLargeIcon() != null) {
        final VmIconIdSizePair iconIds = iconUtils.ensureIconPairInDatabase(getParameters().getVmLargeIcon());
        vmStatic.setLargeIconId(iconIds.getLarge());
        vmStatic.setSmallIconId(iconIds.getSmall());
    } else {
        if (vmStatic.getLargeIconId() == null || vmStatic.getSmallIconId() == null) {
            vmStatic.setSmallIconId(getVmTemplate().getSmallIconId());
            vmStatic.setLargeIconId(getVmTemplate().getLargeIconId());
        }
    }
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair)

Example 7 with VmIconIdSizePair

use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.

the class AddVmTemplateCommand method updateVmIcons.

private void updateVmIcons() {
    if (getParameters().getVmLargeIcon() != null) {
        final VmIconIdSizePair iconIdPair = iconUtils.ensureIconPairInDatabase(getParameters().getVmLargeIcon());
        getVmTemplate().setSmallIconId(iconIdPair.getSmall());
        getVmTemplate().setLargeIconId(iconIdPair.getLarge());
    }
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair)

Example 8 with VmIconIdSizePair

use of org.ovirt.engine.core.common.queries.VmIconIdSizePair 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)

Example 9 with VmIconIdSizePair

use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.

the class IconLoader method setIconsByOs.

private void setIconsByOs(VmBase vmBase) {
    final VmIconIdSizePair iconIdPair = getIconIdPairByOsId(vmBase.getOsId());
    vmBase.setSmallIconId(iconIdPair.getSmall());
    vmBase.setLargeIconId(iconIdPair.getLarge());
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair)

Example 10 with VmIconIdSizePair

use of org.ovirt.engine.core.common.queries.VmIconIdSizePair in project ovirt-engine by oVirt.

the class IconLoader method updateVmIconDefaultsTable.

/**
 * It recreates 'vm_icon_defaults' table based on new configuration.
 */
private void updateVmIconDefaultsTable() {
    vmIconDefaultDao.removeAll();
    for (Map.Entry<Integer, VmIconIdSizePair> entry : osIdToIconIdMap.entrySet()) {
        final VmIconDefault osDefaultIconIds = new VmIconDefault(Guid.newGuid(), entry.getKey(), entry.getValue().getSmall(), entry.getValue().getLarge());
        vmIconDefaultDao.save(osDefaultIconIds);
    }
}
Also used : VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair) HashMap(java.util.HashMap) Map(java.util.Map) VmIconDefault(org.ovirt.engine.core.common.businessentities.VmIconDefault)

Aggregations

VmIconIdSizePair (org.ovirt.engine.core.common.queries.VmIconIdSizePair)12 HashMap (java.util.HashMap)3 Map (java.util.Map)2 VmIconDefault (org.ovirt.engine.core.common.businessentities.VmIconDefault)2 Guid (org.ovirt.engine.core.compat.Guid)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 OperatingSystemInfo (org.ovirt.engine.api.model.OperatingSystemInfo)1 OperatingSystemInfos (org.ovirt.engine.api.model.OperatingSystemInfos)1 AddVmParameters (org.ovirt.engine.core.common.action.AddVmParameters)1 VmRngDevice (org.ovirt.engine.core.common.businessentities.VmRngDevice)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 OsRepository (org.ovirt.engine.core.common.osinfo.OsRepository)1 Pair (org.ovirt.engine.core.common.utils.Pair)1