Yedidyah Bar David has uploaded a new change for review.

Change subject: packaging: setup: simplify nfs exports
......................................................................

packaging: setup: simplify nfs exports

Change-Id: I2004fb577af99d6cd288c00d633a2481478e1943
Signed-off-by: Yedidyah Bar David <d...@redhat.com>
---
M packaging/setup/plugins/ovirt-engine-setup/system/exportfs.py
1 file changed, 20 insertions(+), 42 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/16/22616/1

diff --git a/packaging/setup/plugins/ovirt-engine-setup/system/exportfs.py 
b/packaging/setup/plugins/ovirt-engine-setup/system/exportfs.py
index 7599247..c09f3c6 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/system/exportfs.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/system/exportfs.py
@@ -46,8 +46,7 @@
             ^
             (?P<path>\S+)
             \s+
-            (?P<acl>[^\#]*[^\#\s])
-            (?P<comment>\s*\#.*)?
+            .*
             $
         """,
     )
@@ -55,7 +54,6 @@
     def _read_and_find_path(self, conf, path):
         index = None
         content = None
-        acl = None
         if os.path.exists(conf):
             with open(conf, 'r') as f:
                 content = f.read().splitlines()
@@ -63,9 +61,8 @@
                 matcher = self._RE_EXPORTS_LINE.match(line)
                 if matcher and matcher.group('path') == path:
                     index = i
-                    acl = matcher.group('acl')
                     break
-        return content, index, acl
+        return content, index
 
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
@@ -144,15 +141,23 @@
             path=path,
             acl=default_acl,
         )
-        exports_content, exports_index, exports_acl = (
+        exports_content, exports_index = (
             self._read_and_find_path(
                 osetupcons.FileLocations.NFS_EXPORT_FILE,
                 path
             )
         )
-        if self._conf == osetupcons.FileLocations.NFS_EXPORT_FILE:
-            if exports_index is None:
-                exports_content.append(new_line)
+        exports_d_content, exports_d_index = (
+            self._read_and_find_path(
+                osetupcons.FileLocations.OVIRT_NFS_EXPORT_FILE,
+                path
+            )
+        )
+        content = []
+        if exports_index is None and exports_d_index is None:
+            if self._conf == osetupcons.FileLocations.NFS_EXPORT_FILE:
+                if exports_content is not None:
+                    content.extend(exports_content)
                 exports_uninstall_group.addChanges(
                     group='exportfs',
                     filename=self._conf,
@@ -162,41 +167,14 @@
                         }
                     ],
                 )
-        else:
-            if exports_index is not None:
-                new_line = exports_content.pop(exports_index)
-                if exports_acl != default_acl:
-                    self.environment[
-                        osetupcons.CoreEnv.UNINSTALL_UNREMOVABLE_FILES
-                    ].append(self._conf)
-            exports_d_content, exports_d_index, exports_d_acl = (
-                self._read_and_find_path(
-                    self._conf,
-                    path
+            content.append(new_line)
+            self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
+                filetransaction.FileTransaction(
+                    name=self._conf,
+                    content=content,
+                    modifiedList=uninstall_files,
                 )
             )
-            if exports_d_index is not None:
-                self.logger.debug(
-                    '{path} already in {conf}, not changing it'.format(
-                        path=path,
-                        conf=self._conf,
-                    )
-                )
-            else:
-                self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
-                    filetransaction.FileTransaction(
-                        name=self._conf,
-                        content=[new_line],
-                        modifiedList=uninstall_files,
-                    )
-                )
-        self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
-            filetransaction.FileTransaction(
-                name=osetupcons.FileLocations.NFS_EXPORT_FILE,
-                content=exports_content,
-                modifiedList=uninstall_files,
-            )
-        )
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CLOSEUP,


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2004fb577af99d6cd288c00d633a2481478e1943
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yedidyah Bar David <d...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to