Fabian Deutsch has uploaded a new change for review.

Change subject: Add a note for a to-be-fixed hack
......................................................................

Add a note for a to-be-fixed hack

Change-Id: I3527a7d1d963a2076f04edbe118ad1695a486cff
Signed-off-by: Fabian Deutsch <fabi...@fedoraproject.org>
---
M src/engine_page.py
1 file changed, 28 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node-plugin-vdsm 
refs/changes/49/40649/1

diff --git a/src/engine_page.py b/src/engine_page.py
index 719c246..6fa278b 100644
--- a/src/engine_page.py
+++ b/src/engine_page.py
@@ -92,6 +92,32 @@
     """Validate server str if user provided ':' port schema"""
     return True if ":" in server else False
 
+
+def _hack_to_workaround_pyaug_issues(mgmtIface, cfg, engine_data):
+    """Normally we must not use the Augeas() class directly.
+    Instead we interact with the /etc/default/ovirt class through
+    the ovirt.node.config.defaults module and it's classes.
+    However, this hack is needed to workaround the problem that
+    the augeas object is cachign some values, and will flush them to disk
+    occasionally.
+    This can only be fixed by removing all calls to augeas
+    or by a different solution.
+    """
+    ag = augeas.Augeas()
+    ag.set("/augeas/save/copy_if_rename_fails", "")
+    ag.set("/files/etc/default/ovirt/MANAGED_IFNAMES", "\"%s\"" %
+           ''.join(mgmtIface).encode('utf-8'))
+    ag.set("/files/etc/default/ovirt/OVIRT_MANAGEMENT_SERVER", "\"%s\"" %
+           cfg["server"])
+    ag.set("/files/etc/default/ovirt/OVIRT_MANAGEMENT_PORT", "\"%s\"" %
+           cfg["port"])
+
+    if engine_data is not None and engine_data != "":
+        ag.set("/files/etc/default/ovirt/MANAGED_BY",
+               engine_data.encode('utf-8'))
+    ag.save()
+
+
 def sync_mgmt():
     """Guess mgmt interface and update TUI config
        FIXME: Autoinstall should write MANAGED_BY and MANAGED_IFNAMES
@@ -148,19 +174,8 @@
     if cfg['server'] == 'None' or cfg['server'] is None: cfg['server'] = ""
     if cfg['port'] == 'None': cfg['port'] = config.ENGINE_PORT
 
-    ag = augeas.Augeas()
-    ag.set("/augeas/save/copy_if_rename_fails", "")
-    ag.set("/files/etc/default/ovirt/MANAGED_IFNAMES", "\"%s\"" %
-           ''.join(mgmtIface).encode('utf-8'))
-    ag.set("/files/etc/default/ovirt/OVIRT_MANAGEMENT_SERVER", "\"%s\"" %
-           cfg["server"])
-    ag.set("/files/etc/default/ovirt/OVIRT_MANAGEMENT_PORT", "\"%s\"" %
-           cfg["port"])
-
-    if engine_data is not None and engine_data != "":
-        ag.set("/files/etc/default/ovirt/MANAGED_BY",
-               engine_data.encode('utf-8'))
-    ag.save()
+    # Update the /etc/defaults/ovirt file
+    _hack_to_workaround_pyaug_issues(mgmtIface, cfg, engine_data)
 
 
 class Plugin(plugins.NodePlugin):


-- 
To view, visit https://gerrit.ovirt.org/40649
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3527a7d1d963a2076f04edbe118ad1695a486cff
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node-plugin-vdsm
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabi...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to