Vitor de Lima has uploaded a new change for review.

Change subject: core, engine: New property override behaviour in osinfo
......................................................................

core, engine: New property override behaviour in osinfo

This change modifies how the osinfo interprets OS inheritance and value
overriding. Supose there is an OS called "base", with the following
description:

os.base.someProperty.value = valueBaseDefault
os.base.someProperty.value.3.4 = valueBase34

And another OS called "derived", described as:

os.derived.derivedFrom.value = base
os.derived.someProperty.value = valueDerived34

The result of querying the "derived" OS for the value of "someProperty"
is currently "valueBase34", which is counterintuitive.

After applying this patch, the non-versioned value in the derived OS
will override the versioned values in the base OS.

Change-Id: Idbb1699202178b732ea5bf48f5103450dfed1266
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1056577
Signed-off-by: Vitor de Lima <[email protected]>
---
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
M packaging/conf/osinfo-defaults.properties
2 files changed, 27 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/40/25740/1

diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
index 7e40127..8355528 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
@@ -419,11 +419,18 @@
      */
     private String getValueByVersion(String uniqueOsName, String 
relativeKeyPath, Version version) {
         Preferences keyNode = getKeyNode(uniqueOsName, relativeKeyPath, 
version);
-        if (keyNode == emptyNode) {
-            version = null;
-            keyNode = getKeyNode(uniqueOsName, relativeKeyPath, null);
+
+        try {
+            if 
(Arrays.asList(keyNode.keys()).contains(versionedValuePath(version))) {
+                return keyNode.get(versionedValuePath(version), "");
+            }
+        } catch (BackingStoreException e) {
+            // our preferences impl should use storage to back the data 
structure
+            // throwing unchecked exception here to make sure this anomality 
is noticed
+            throw new RuntimeException(e);
         }
-        return keyNode.get(versionedValuePath(version), "");
+
+        return keyNode.get(versionedValuePath(null), "");
     }
 
     /**
@@ -444,8 +451,19 @@
         // first try direct OS node
         try {
             Preferences node = getNodeIfExist(uniqueOsName, relativeKeyPath);
-            if (node != null && 
Arrays.asList(node.keys()).contains(versionedValuePath(version))) {
-                return node;
+
+            boolean containsKeyWithVersion = false;
+            boolean containsDefaultKey = false;
+
+            if (node != null) {
+                List<String> keyList = Arrays.asList(node.keys());
+
+                containsKeyWithVersion = version != null && 
keyList.contains(versionedValuePath(version));
+                containsDefaultKey = 
keyList.contains(versionedValuePath(null));
+            }
+
+            if (containsKeyWithVersion || containsDefaultKey) {
+                    return node;
             } else {
                 // if not exist directly on the OS consult the one its derived 
from
                 String derivedFromOs = preferences.node(OS_ROOT_NODE + 
uniqueOsName + "/derivedFrom").get("value", null);
diff --git a/packaging/conf/osinfo-defaults.properties 
b/packaging/conf/osinfo-defaults.properties
index 6a4ce6f..64befd5 100644
--- a/packaging/conf/osinfo-defaults.properties
+++ b/packaging/conf/osinfo-defaults.properties
@@ -268,12 +268,9 @@
 os.other_ppc64.bus.value = 64
 os.other_ppc64.devices.network.value = pv, spaprVlan, e1000, rtl8139
 os.other_ppc64.devices.cdInterface.value = scsi
-os.other_ppc64.devices.diskInterfaces.value.3.3 = VirtIO, VirtIO_SCSI, 
SPAPR_VSCSI
-os.other_ppc64.devices.diskInterfaces.value.3.4 = VirtIO, VirtIO_SCSI, 
SPAPR_VSCSI
-os.other_ppc64.devices.disk.hotpluggableInterfaces.value.3.3 = VirtIO_SCSI, 
SPAPR_VSCSI
-os.other_ppc64.devices.disk.hotpluggableInterfaces.value.3.4 = VirtIO_SCSI, 
SPAPR_VSCSI
-os.other_ppc64.devices.network.hotplugSupport.value.3.3 = false
-os.other_ppc64.devices.network.hotplugSupport.value.3.4 = false
+os.other_ppc64.devices.diskInterfaces.value = VirtIO, VirtIO_SCSI, SPAPR_VSCSI
+os.other_ppc64.devices.disk.hotpluggableInterfaces.value = VirtIO_SCSI, 
SPAPR_VSCSI
+os.other_ppc64.devices.network.hotplugSupport.value = false
 os.other_ppc64.devices.display.protocols.value = vnc/vga
 os.other_ppc64.devices.watchdog.models.value = i6300esb
 # In the ppc64 architecture there are only three devices occupying


-- 
To view, visit http://gerrit.ovirt.org/25740
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idbb1699202178b732ea5bf48f5103450dfed1266
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vitor de Lima <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to