Yedidyah Bar David has uploaded a new change for review. Change subject: packaging: setup: simplify exports and overide by env ......................................................................
packaging: setup: simplify exports and overide by env Change-Id: If63bb5395f0bf78c8fb61942a7a7c236eedad17b Signed-off-by: Yedidyah Bar David <d...@redhat.com> --- M packaging/setup/ovirt_engine_setup/constants.py M packaging/setup/plugins/ovirt-engine-setup/system/exportfs.py 2 files changed, 34 insertions(+), 44 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/57/22557/1 diff --git a/packaging/setup/ovirt_engine_setup/constants.py b/packaging/setup/ovirt_engine_setup/constants.py index c811e5f..55b2d95 100644 --- a/packaging/setup/ovirt_engine_setup/constants.py +++ b/packaging/setup/ovirt_engine_setup/constants.py @@ -645,6 +645,7 @@ FIREWALL_MANAGER_HUMAN = 'skip' FIREWALL_MANAGER_IPTABLES = 'iptables' FIREWALL_MANAGER_FIREWALLD = 'firewalld' + ISO_DOMAIN_NFS_DEFAULT_CLIENTS = '0.0.0.0/0.0.0.0(rw)' @util.export @@ -926,6 +927,14 @@ @osetupattrs( answerfile=True, + description=_('NFS mount point'), + postinstallfile=True, + ) + def ISO_DOMAIN_NFS_CLIENTS(self): + return 'OVESETUP_CONFIG/isoDomainClients' + + @osetupattrs( + answerfile=True, postinstallfile=True ) def ISO_DOMAIN_NAME(self): diff --git a/packaging/setup/plugins/ovirt-engine-setup/system/exportfs.py b/packaging/setup/plugins/ovirt-engine-setup/system/exportfs.py index 20d4ee9..efbd871 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<clients>[^\#]*[^\#\s]) - (?P<comment>\s*\#.*)? + .* $ """, ) @@ -55,7 +54,6 @@ def _read_and_find_path(self, conf, path): index = None content = None - clients = None if os.path.exists(conf): with open(conf, 'r') as f: content = f.read().splitlines() @@ -63,14 +61,22 @@ matcher = self._RE_EXPORTS_LINE.match(line) if matcher and matcher.group('path') == path: index = i - clients = matcher.group('clients') break - return content, index, clients + return content, index def __init__(self, context): super(Plugin, self).__init__(context=context) self._enabled = True self._conf = None + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + osetupcons.ConfigEnv.ISO_DOMAIN_NFS_CLIENTS, + osetupcons.Const.ISO_DOMAIN_NFS_DEFAULT_CLIENTS + ) @plugin.event( stage=plugin.Stages.STAGE_SETUP, @@ -128,20 +134,21 @@ path = self.environment[ osetupcons.ConfigEnv.ISO_DOMAIN_NFS_MOUNT_POINT ] - default_clients = '0.0.0.0/0.0.0.0(rw)' new_line = '{path}\t{clients}'.format( path=path, - clients=default_clients, + clients=self.environment[ + osetupcons.ConfigEnv.ISO_DOMAIN_NFS_CLIENTS + ], ) - exports_content, exports_index, exports_clients = ( + conf_content, conf_index = ( self._read_and_find_path( - osetupcons.FileLocations.NFS_EXPORT_FILE, + self._conf, path ) ) - if self._conf == osetupcons.FileLocations.NFS_EXPORT_FILE: - if exports_index is None: - exports_content.append(new_line) + if conf_index is None: + if self._conf == osetupcons.FileLocations.NFS_EXPORT_FILE: + content = conf_content + [new_line] exports_uninstall_group.addChanges( group='exportfs', filename=self._conf, @@ -151,41 +158,15 @@ } ], ) - else: - if exports_index is not None: - new_line = exports_content.pop(exports_index) - if exports_clients != default_clients: - self.environment[ - osetupcons.CoreEnv.UNINSTALL_UNREMOVABLE_FILES - ].append(self._conf) - exports_d_content, exports_d_index, exports_d_clients = ( - self._read_and_find_path( - self._conf, - path - ) - ) - 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, - ) + content = [new_line] + self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append( + filetransaction.FileTransaction( + name=self._conf, + content=content, + 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/22557 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If63bb5395f0bf78c8fb61942a7a7c236eedad17b 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