Search in sources :

Example 1 with VmPropertiesUtils

use of org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils in project ovirt-engine by oVirt.

the class RunVmValidatorTest method mockVmPropertiesUtils.

private VmPropertiesUtils mockVmPropertiesUtils() throws InitializationException {
    VmPropertiesUtils utils = spy(new VmPropertiesUtils());
    doReturn("sap_agent=^(true|false)$;sndbuf=^[0-9]+$;" + "vhost=^(([a-zA-Z0-9_]*):(true|false))(,(([a-zA-Z0-9_]*):(true|false)))*$;" + "viodiskcache=^(none|writeback|writethrough)$;" + "mdev_type=^.*$;hugepages=^[0-9]+$").when(utils).getPredefinedVMProperties(any());
    doReturn("").when(utils).getUserDefinedVMProperties(any());
    doReturn(new HashSet<>(Arrays.asList(Version.v3_6, Version.v4_0))).when(utils).getSupportedClusterLevels();
    doReturn(utils).when(runVmValidator).getVmPropertiesUtils();
    utils.init();
    return utils;
}
Also used : VmPropertiesUtils(org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils)

Example 2 with VmPropertiesUtils

use of org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils in project ovirt-engine by oVirt.

the class Backend method initVmPropertiesUtils.

private void initVmPropertiesUtils() {
    VmPropertiesUtils vmPropertiesUtils = VmPropertiesUtils.getInstance();
    SimpleDependencyInjector.getInstance().bind(VmPropertiesUtils.class, vmPropertiesUtils);
}
Also used : VmPropertiesUtils(org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils)

Example 3 with VmPropertiesUtils

use of org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils in project ovirt-engine by oVirt.

the class GetVmChangedFieldsForNextRunQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    VM srcVm = getParameters().getOriginal();
    VM dstVm = getParameters().getUpdated();
    VmStatic srcStatic = srcVm.getStaticData();
    VmStatic dstStatic = dstVm.getStaticData();
    // Copy creationDate to ignore it, because it is never changed by user.
    // Without this creationDate will always show change in milliseconds,
    // because creationDate is saved without milliseconds in OVF, but
    // with milliseconds in the DB.
    dstStatic.setCreationDate(srcStatic.getCreationDate());
    // so it is not needed to include them into changed fields list.
    if (VmCommonUtils.isCpusToBeHotpluggedOrUnplugged(srcVm, dstVm)) {
        dstStatic.setNumOfSockets(srcStatic.getNumOfSockets());
    }
    if (VmCommonUtils.isMemoryToBeHotplugged(srcVm, dstVm)) {
        dstStatic.setMemSizeMb(srcStatic.getMemSizeMb());
        dstStatic.setMinAllocatedMem(srcStatic.getMinAllocatedMem());
    }
    if (VmCommonUtils.isVmLeaseToBeHotPluggedOrUnplugged(srcVm, dstVm)) {
        dstStatic.setLeaseStorageDomainId(srcStatic.getLeaseStorageDomainId());
    }
    VmPropertiesUtils vmPropertiesUtils = SimpleDependencyInjector.getInstance().get(VmPropertiesUtils.class);
    vmPropertiesUtils.separateCustomPropertiesToUserAndPredefined(srcVm.getCompatibilityVersion(), srcStatic);
    vmPropertiesUtils.separateCustomPropertiesToUserAndPredefined(dstVm.getCompatibilityVersion(), dstStatic);
    Set<String> result = new HashSet<>(vmHandler.getChangedFieldsForStatus(srcStatic, dstStatic, VMStatus.Up));
    for (VmDeviceUpdate device : vmHandler.getVmDevicesFieldsToUpdateOnNextRun(srcVm.getId(), VMStatus.Up, getParameters().getUpdateVmParameters())) {
        if (!device.getName().isEmpty()) {
            result.add(device.getName());
        } else {
            switch(device.getType()) {
                case UNKNOWN:
                case VIRTIO:
                    result.add(device.getGeneralType().name());
                    break;
                default:
                    result.add(device.getType().getName());
                    break;
            }
        }
    }
    setReturnValue(new ArrayList<>(result));
}
Also used : VmDeviceUpdate(org.ovirt.engine.core.common.utils.VmDeviceUpdate) VM(org.ovirt.engine.core.common.businessentities.VM) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) VmPropertiesUtils(org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils) HashSet(java.util.HashSet)

Aggregations

VmPropertiesUtils (org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils)3 HashSet (java.util.HashSet)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 VmDeviceUpdate (org.ovirt.engine.core.common.utils.VmDeviceUpdate)1