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