Search in sources :

Example 1 with InitializationException

use of org.ovirt.engine.core.common.utils.exceptions.InitializationException in project ovirt-engine by oVirt.

the class VmPropertiesUtils method init.

public void init() throws InitializationException {
    try {
        predefinedProperties = new HashMap<>();
        userdefinedProperties = new HashMap<>();
        allVmProperties = new HashMap<>();
        Set<Version> versions = getSupportedClusterLevels();
        for (Version version : versions) {
            predefinedProperties.put(version, new HashMap<>());
            userdefinedProperties.put(version, new HashMap<>());
            allVmProperties.put(version, new HashMap<>());
            parsePropertiesRegex(getPredefinedVMProperties(version), predefinedProperties.get(version));
            parsePropertiesRegex(getUserDefinedVMProperties(version), userdefinedProperties.get(version));
            allVmProperties.get(version).putAll(predefinedProperties.get(version));
            allVmProperties.get(version).putAll(userdefinedProperties.get(version));
        }
    } catch (Throwable ex) {
        throw new InitializationException(ex);
    }
}
Also used : Version(org.ovirt.engine.core.compat.Version) InitializationException(org.ovirt.engine.core.common.utils.exceptions.InitializationException)

Example 2 with InitializationException

use of org.ovirt.engine.core.common.utils.exceptions.InitializationException in project ovirt-engine by oVirt.

the class DevicePropertiesUtils method init.

/**
 * Loads device custom properties definition
 *
 * @throws InitializationException
 *             if an error occured during device custom properties definition loading
 */
public void init() throws InitializationException {
    try {
        Set<Version> versions = getSupportedClusterLevels();
        String devicePropertiesStr;
        deviceProperties = new HashMap<>();
        for (Version version : versions) {
            // load device properties
            devicePropertiesStr = getCustomDeviceProperties(version);
            deviceProperties.put(version, new EnumMap<>(VmDeviceGeneralType.class));
            Matcher typeMatcher = devicePropSplitPattern.matcher(devicePropertiesStr);
            while (typeMatcher.find()) {
                String dcpStr = typeMatcher.group();
                // device type definition starts with "{type="
                int start = TYPE_PREFIX_LEN;
                int end = dcpStr.length() - 1;
                if (dcpStr.endsWith(PROPERTIES_DELIMETER)) {
                    // remove trailing ;
                    end--;
                }
                dcpStr = dcpStr.substring(start, end);
                int idx = dcpStr.indexOf(PROPERTIES_DELIMETER);
                VmDeviceGeneralType type = VmDeviceGeneralType.forValue(dcpStr.substring(0, idx));
                // properties definition for device starts with ";prop={"
                String propStr = dcpStr.substring(idx + PROP_PREFIX_LEN, dcpStr.length() - 1);
                Map<String, String> props = new HashMap<>();
                parsePropertiesRegex(propStr, props);
                deviceProperties.get(version).put(type, props);
            }
        }
    } catch (Exception ex) {
        throw new InitializationException(ex);
    }
}
Also used : Version(org.ovirt.engine.core.compat.Version) Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) InitializationException(org.ovirt.engine.core.common.utils.exceptions.InitializationException) InitializationException(org.ovirt.engine.core.common.utils.exceptions.InitializationException)

Aggregations

InitializationException (org.ovirt.engine.core.common.utils.exceptions.InitializationException)2 Version (org.ovirt.engine.core.compat.Version)2 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1 VmDeviceGeneralType (org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType)1