Search in sources :

Example 1 with SimpleCustomPropertiesUtil

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

the class HostSetupNetworksValidatorTest method testValidateCustomProperties.

@Test
public void testValidateCustomProperties() throws Exception {
    Network networkA = createNetworkWithName("networkA");
    NetworkAttachment networkAttachment = createNetworkAttachment(networkA);
    Map<String, String> customProperties = new HashMap<>();
    customProperties.put("a", "b");
    networkAttachment.setProperties(customProperties);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).addNetworks(networkA).build();
    // we do not test SimpleCustomPropertiesUtil here, we just state what happens if it does not find ValidationError
    SimpleCustomPropertiesUtil simpleCustomPropertiesUtilMock = mock(SimpleCustomPropertiesUtil.class);
    assertThat(validator.validateCustomProperties(simpleCustomPropertiesUtilMock, Collections.emptyMap(), Collections.emptyMap()), isValid());
}
Also used : SimpleCustomPropertiesUtil(org.ovirt.engine.core.common.utils.customprop.SimpleCustomPropertiesUtil) HashMap(java.util.HashMap) FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 2 with SimpleCustomPropertiesUtil

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

the class HostSetupNetworksValidator method validateCustomProperties.

private ValidationResult validateCustomProperties() {
    String version = host.getClusterCompatibilityVersion().getValue();
    SimpleCustomPropertiesUtil util = SimpleCustomPropertiesUtil.getInstance();
    Map<String, String> validPropertiesForVmNetwork = util.convertProperties(Config.<String>getValue(ConfigValues.PreDefinedNetworkCustomProperties, version));
    validPropertiesForVmNetwork.putAll(util.convertProperties(Config.<String>getValue(ConfigValues.UserDefinedNetworkCustomProperties, version)));
    Map<String, String> validPropertiesForNonVm = new HashMap<>(validPropertiesForVmNetwork);
    validPropertiesForNonVm.remove("bridge_opts");
    return validateCustomProperties(util, validPropertiesForVmNetwork, validPropertiesForNonVm);
}
Also used : SimpleCustomPropertiesUtil(org.ovirt.engine.core.common.utils.customprop.SimpleCustomPropertiesUtil) HashMap(java.util.HashMap)

Example 3 with SimpleCustomPropertiesUtil

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

the class HugePageUtils method getHugePageSize.

/**
 * Get size of the hugepages in KiB.
 */
public static Optional<Integer> getHugePageSize(VmBase vm) {
    SimpleCustomPropertiesUtil util = SimpleCustomPropertiesUtil.getInstance();
    Map<String, String> customProperties = util.convertProperties(vm.getCustomProperties());
    String hugePageStr = customProperties.get("hugepages");
    if (hugePageStr == null) {
        return Optional.empty();
    }
    try {
        return Optional.of(Integer.parseInt(hugePageStr));
    } catch (NumberFormatException e) {
        return Optional.empty();
    }
}
Also used : SimpleCustomPropertiesUtil(org.ovirt.engine.core.common.utils.customprop.SimpleCustomPropertiesUtil)

Example 4 with SimpleCustomPropertiesUtil

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

the class HugePageUtils method isHugepagesShared.

public static boolean isHugepagesShared(VmBase vm) {
    SimpleCustomPropertiesUtil util = SimpleCustomPropertiesUtil.getInstance();
    Map<String, String> customProperties = util.convertProperties(vm.getCustomProperties());
    return Boolean.parseBoolean(customProperties.get("hugepages_shared"));
}
Also used : SimpleCustomPropertiesUtil(org.ovirt.engine.core.common.utils.customprop.SimpleCustomPropertiesUtil)

Aggregations

SimpleCustomPropertiesUtil (org.ovirt.engine.core.common.utils.customprop.SimpleCustomPropertiesUtil)4 HashMap (java.util.HashMap)2 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)1 Network (org.ovirt.engine.core.common.businessentities.network.Network)1 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)1