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());
}
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);
}
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();
}
}
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"));
}
Aggregations