Yedidyah Bar David has uploaded a new change for review.

Change subject: packaging: setup: read legacy config with trivial parser
......................................................................

packaging: setup: read legacy config with trivial parser

and not with configfile, because it was written without escaping special
chars.

Change-Id: I563e8dcfa54e6d23c1e4828c422dcf88ffe1738e
Signed-off-by: Yedidyah Bar David <[email protected]>
---
M packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-dwh/legacy/config.py
1 file changed, 26 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-dwh refs/changes/24/26024/1

diff --git 
a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-dwh/legacy/config.py 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-dwh/legacy/config.py
index 9e6ec01..914abf7 100644
--- 
a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-dwh/legacy/config.py
+++ 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-dwh/legacy/config.py
@@ -40,22 +40,42 @@
 @util.export
 class Plugin(plugin.PluginBase):
 
-    _RE_JDBC_URL = re.compile(
+    _RE_LEGACY_JDBC_URL = re.compile(
         flags=re.VERBOSE,
         pattern=r"""
-            jdbc:
-            postgresql:
+            jdbc\\:
+            postgresql\\:
             //
             (?P<host>[^:/]+)
-            (:(?P<port>\d+))?
+            (\\:(?P<port>\d+))?
             /
             (?P<database>\w+)
             (\?(?P<extra>.*))?
         """,
     )
 
+    _RE_LEGACY_CONF = re.compile(
+        flags=re.VERBOSE,
+        pattern=r"""
+            \s*
+            (?P<param>[a-zA-Z]+)
+            \s*
+            =
+            (?P<value>.*)
+        """,
+    )
+
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
+
+    def _parse_legacy_conf(self, filename):
+        result = {}
+        with open(filename) as f:
+            for line in f.read().splitlines():
+                matches = self._RE_LEGACY_CONF.match(line)
+                if matches and matches.group('param'):
+                    result[matches.group('param')] = matches.group('value')
+        return result
 
     @plugin.event(
         stage=plugin.Stages.STAGE_SETUP,
@@ -64,11 +84,7 @@
         ),
     )
     def _setup(self):
-        legacy = configfile.ConfigFile(
-            files=[
-                odwhcons.FileLocations.LEGACY_CONFIG,
-            ],
-        )
+        legacy = self._parse_legacy_conf(odwhcons.FileLocations.LEGACY_CONFIG)
         current = configfile.ConfigFile(
             files=[
                 odwhcons.FileLocations.
@@ -118,7 +134,7 @@
                     )
                 )
 
-            jdbcurl = self._RE_JDBC_URL.match(
+            jdbcurl = self._RE_LEGACY_JDBC_URL.match(
                 legacy.get('ovirtEngineHistoryDbJdbcConnection')
             )
             if (


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I563e8dcfa54e6d23c1e4828c422dcf88ffe1738e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-dwh
Gerrit-Branch: master
Gerrit-Owner: Yedidyah Bar David <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to