Hello Yedidyah Bar David, I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/18537 to review the following change. Change subject: packaging: setup: firewalld services cleanup ...................................................................... packaging: setup: firewalld services cleanup Change-Id: I5c36ee32302a93edabb06f90c12c3caedc9d4129 Signed-off-by: Yedidyah Bar David <d...@redhat.com> --- M packaging/setup/ovirt_engine_setup/constants.py M packaging/setup/plugins/ovirt-engine-remove/files/simple.py A packaging/setup/plugins/ovirt-engine-remove/network/__init__.py A packaging/setup/plugins/ovirt-engine-remove/network/firewalld.py M packaging/setup/plugins/ovirt-engine-setup/legacy/firewalld.py 5 files changed, 127 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/18537/1 diff --git a/packaging/setup/ovirt_engine_setup/constants.py b/packaging/setup/ovirt_engine_setup/constants.py index 7204f62..7078426 100644 --- a/packaging/setup/ovirt_engine_setup/constants.py +++ b/packaging/setup/ovirt_engine_setup/constants.py @@ -130,10 +130,14 @@ '.pgpass', ) - LEGACY_FIREWALLD_SERVICE_FILE = os.path.join( + FIREWALLD_SERVICES_DIR = os.path.join( SYSCONFDIR, 'firewalld', 'services', + ) + + LEGACY_FIREWALLD_SERVICE_FILE = os.path.join( + FIREWALLD_SERVICES_DIR, 'ovirt.xml' ) @@ -561,6 +565,7 @@ REMOVE_CUSTOMIZATION_COMMON = 'osetup.remove.customization.common' REMOVE_CUSTOMIZATION_GROUPS = 'osetup.remove.customization.groups' + REMOVE_FIREWALLD_SERVICES = 'osetup.remove.firewalld.services' RENAME_PKI_CONF_MISC = 'osetup.rename.pki.conf.misc' @@ -1027,6 +1032,8 @@ def REMOVE_ALL(self): return 'OVESETUP_REMOVE/removeAll' + FILES_TO_REMOVE = 'OVESETUP_REMOVE/filesToRemove' + @util.export @util.codegen diff --git a/packaging/setup/plugins/ovirt-engine-remove/files/simple.py b/packaging/setup/plugins/ovirt-engine-remove/files/simple.py index f56bb7f..484c6de 100644 --- a/packaging/setup/plugins/ovirt-engine-remove/files/simple.py +++ b/packaging/setup/plugins/ovirt-engine-remove/files/simple.py @@ -102,6 +102,10 @@ osetupcons.RemoveEnv.ASK_GROUPS, True ) + self.environment.setdefault( + osetupcons.RemoveEnv.FILES_TO_REMOVE, + [] + ) self._infos = sorted( glob.glob( os.path.join( @@ -232,6 +236,9 @@ self.logger.debug('files=%s', self._files) self.logger.debug('unremovable=%s', unremovable) self.logger.debug('toremove=%s', self._toremove) + self.environment[ + osetupcons.RemoveEnv.FILES_TO_REMOVE + ] = self._toremove @plugin.event( stage=plugin.Stages.STAGE_MISC, diff --git a/packaging/setup/plugins/ovirt-engine-remove/network/__init__.py b/packaging/setup/plugins/ovirt-engine-remove/network/__init__.py new file mode 100644 index 0000000..651da8a --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-remove/network/__init__.py @@ -0,0 +1,33 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2013 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +"""ovirt-host-setup network plugin.""" + + +from otopi import util + + +from . import firewalld + + +@util.export +def createPlugins(context): + firewalld.Plugin(context=context) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-remove/network/firewalld.py b/packaging/setup/plugins/ovirt-engine-remove/network/firewalld.py new file mode 100644 index 0000000..568a5ef --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-remove/network/firewalld.py @@ -0,0 +1,67 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2013 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +"""Firewalld plugin.""" + + +import os + + +from otopi import util +from otopi import plugin +from otopi import constants as otopicons + + +from ovirt_engine_setup import constants as osetupcons + + +@util.export +class Plugin(plugin.PluginBase): + """Firewalld plugin.""" + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + + @plugin.event( + stage=plugin.Stages.STAGE_VALIDATION, + name=osetupcons.Stages.REMOVE_FIREWALLD_SERVICES, + # TODO: Add: + # before=( + # otopicons.Stages.FIREWALLD_VALIDATION, + #), + # and remove: + priority=plugin.Stages.PRIORITY_HIGH, + ) + def _validation(self): + enable_firewalld = False + for file in self.environment[osetupcons.RemoveEnv.FILES_TO_REMOVE]: + if file.startswith( + osetupcons.FileLocations.FIREWALLD_SERVICES_DIR + ): + enable_firewalld = True + self.environment[ + otopicons.NetEnv.FIREWALLD_DISABLE_SERVICES + ].append( + os.path.splitext( + os.path.basename(file) + )[0] + ) + self.environment[otopicons.NetEnv.FIREWALLD_ENABLE] = enable_firewalld + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-setup/legacy/firewalld.py b/packaging/setup/plugins/ovirt-engine-setup/legacy/firewalld.py index 99708cc..e5e92ea 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/legacy/firewalld.py +++ b/packaging/setup/plugins/ovirt-engine-setup/legacy/firewalld.py @@ -27,7 +27,6 @@ from otopi import util from otopi import plugin from otopi import constants as otopicons -from otopi import filetransaction from ovirt_engine_setup import constants as osetupcons @@ -41,30 +40,30 @@ super(Plugin, self).__init__(context=context) @plugin.event( - stage=plugin.Stages.STAGE_MISC, + stage=plugin.Stages.STAGE_VALIDATION, condition=lambda self: self.environment[ osetupcons.CoreEnv.UPGRADE_FROM_LEGACY ], + # TODO: add: + # before=( + # otopicons.Stages.FIREWALLD_VALIDATION, + #), + # and remove: + priority=plugin.Stages.PRIORITY_HIGH, ) - def _misc(self): + def _validation(self): if os.path.exists( osetupcons.FileLocations.LEGACY_FIREWALLD_SERVICE_FILE ): - self.environment[otopicons.NetEnv.FIREWALLD_DISABLE_SERVICES] = [ + self.environment[ + otopicons.NetEnv.FIREWALLD_DISABLE_SERVICES + ].append( os.path.splitext( os.path.basename( osetupcons.FileLocations. LEGACY_FIREWALLD_SERVICE_FILE ) - )[0], - ] - self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append( - filetransaction.FileTransaction( - name=( - osetupcons.FileLocations.LEGACY_FIREWALLD_SERVICE_FILE - ), - content='', - ) + )[0] ) @plugin.event( -- To view, visit http://gerrit.ovirt.org/18537 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5c36ee32302a93edabb06f90c12c3caedc9d4129 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com> Gerrit-Reviewer: Yedidyah Bar David <d...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches