Martin Peřina has uploaded a new change for review. Change subject: packaging: Introduce setup plugin to configure fence_kdump listener ......................................................................
packaging: Introduce setup plugin to configure fence_kdump listener Introduces setup plugin to configure fence_kdump listener host and port when during execution of engine-setup. Change-Id: I052cc2296c479caf58d0930a8e678298dde63517 Bug-Url: https://bugzilla.redhat.com/1079821 Signed-off-by: Martin Perina <mper...@redhat.com> --- M ovirt-engine.spec.in A packaging/firewalld/fence-kdump-listener/ovirt-fence-kdump-listener.xml.in M packaging/setup/ovirt_engine_setup/config.py.in M packaging/setup/ovirt_engine_setup/constants.py A packaging/setup/plugins/ovirt-engine-common/fence_kdump_listener/__init__.py A packaging/setup/plugins/ovirt-engine-common/fence_kdump_listener/core.py A packaging/setup/plugins/ovirt-engine-remove/fence_kdump_listener/__init__.py A packaging/setup/plugins/ovirt-engine-remove/fence_kdump_listener/misc.py A packaging/setup/plugins/ovirt-engine-setup/fence_kdump_listener/__init__.py A packaging/setup/plugins/ovirt-engine-setup/fence_kdump_listener/config.py 10 files changed, 447 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/86/27486/1 diff --git a/ovirt-engine.spec.in b/ovirt-engine.spec.in index bc2e526..4914264 100644 --- a/ovirt-engine.spec.in +++ b/ovirt-engine.spec.in @@ -928,10 +928,12 @@ %{_bindir}/engine-upgrade-check %{engine_data}/conf/ovirt-engine-proxy.conf.v2.in %{engine_data}/conf/ovirt-engine-root-redirect.conf.in +%{engine_data}/firewalld/fence-kdump-listener/ %{engine_data}/firewalld/ovirt-engine/ %{engine_data}/setup/bin/ovirt-engine-rename %{engine_data}/setup/bin/ovirt-engine-upgrade-check %{engine_data}/setup/dbutils/ +%{engine_data}/setup/plugins/*/fence_kdump_listener/ %{engine_data}/setup/plugins/*/ovirt-engine/ %{engine_data}/setup/plugins/ovirt-engine-rename/ diff --git a/packaging/firewalld/fence-kdump-listener/ovirt-fence-kdump-listener.xml.in b/packaging/firewalld/fence-kdump-listener/ovirt-fence-kdump-listener.xml.in new file mode 100644 index 0000000..993f7d6 --- /dev/null +++ b/packaging/firewalld/fence-kdump-listener/ovirt-fence-kdump-listener.xml.in @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<service> + <short>ovirt-fence-kdump-listener</short> + <description>oVirt configured fence_kdump listener service</description> + <port protocol="udp" port="@FENCE_KDUMP_LISTENER_PORT@"/> + <destination ipv4="@FENCE_KDUMP_LISTENER_HOST@" /> +</service> diff --git a/packaging/setup/ovirt_engine_setup/config.py.in b/packaging/setup/ovirt_engine_setup/config.py.in index 5a53ad7..4a58444 100644 --- a/packaging/setup/ovirt_engine_setup/config.py.in +++ b/packaging/setup/ovirt_engine_setup/config.py.in @@ -23,6 +23,7 @@ ENGINE_SETUP_CONFIG = '@ENGINE_SETUP_VARS@' ENGINE_SERVICE_CONFIG = '@ENGINE_VARS@' ENGINE_SERVICE_CONFIG_DEFAULTS = '@ENGINE_DEFAULTS@' +ENGINE_FENCE_KDUMP_LISTENER_CONFIG = '@ENGINE_FKLSNR_VARS@' ENGINE_WEBSOCKET_PROXY_CONFIG = '@ENGINE_WSPROXY_VARS@' ENGINE_NOTIFIER_SERVICE_CONFIG = '@ENGINE_NOTIFIER_VARS@' ENGINE_PKIDIR = '@ENGINE_PKI@' diff --git a/packaging/setup/ovirt_engine_setup/constants.py b/packaging/setup/ovirt_engine_setup/constants.py index 508dfe6..4f02d50 100644 --- a/packaging/setup/ovirt_engine_setup/constants.py +++ b/packaging/setup/ovirt_engine_setup/constants.py @@ -77,6 +77,8 @@ OVIRT_ENGINE_SERVICE_CONFIG = config.ENGINE_SERVICE_CONFIG OVIRT_ENGINE_SERVICE_CONFIG_DEFAULTS = \ config.ENGINE_SERVICE_CONFIG_DEFAULTS + OVIRT_ENGINE_FENCE_KDUMP_LISTENER_CONFIG = \ + config.ENGINE_FENCE_KDUMP_LISTENER_CONFIG OVIRT_ENGINE_WEBSOCKET_PROXY_CONFIG = config.ENGINE_WEBSOCKET_PROXY_CONFIG OVIRT_ENGINE_NOTIFIER_SERVICE_CONFIG = \ config.ENGINE_NOTIFIER_SERVICE_CONFIG @@ -307,6 +309,14 @@ '10-setup-pki.conf', ) + OVIRT_ENGINE_FENCE_KDUMP_LISTENER_CONFIGD = ( + '%s.d' % OVIRT_ENGINE_FENCE_KDUMP_LISTENER_CONFIG + ) + OVIRT_ENGINE_FENCE_KDUMP_LISTENER_CONFIG_SETUP = os.path.join( + OVIRT_ENGINE_FENCE_KDUMP_LISTENER_CONFIGD, + '10-setup.conf', + ) + OVIRT_ENGINE_WEBSOCKET_PROXY_CONFIGD = ( '%s.d' % OVIRT_ENGINE_WEBSOCKET_PROXY_CONFIG ) @@ -466,6 +476,9 @@ DEFAULT_NETWORK_JBOSS_DEBUG_ADDRESS = '127.0.0.1:8787' DEFAULT_WEBSOCKET_PROXY_PORT = 6100 + DEFAULT_FENCE_KDUMP_LISTENER_HOST = '0.0.0.0' + DEFAULT_FENCE_KDUMP_LISTENER_PORT = 7410 + DEFAULT_CONFIG_APPLICATION_MODE = 'Both' DEFAULT_CONFIG_STORAGE_TYPE = 'NFS' @@ -511,6 +524,8 @@ DB_SCHEMA = 'osetup.db.schema' NET_FIREWALL_MANAGER_AVAILABLE = 'osetup.net.firewallmanager.available' CONFIG_PROTOCOLS_CUSTOMIZATION = 'osetup.config.protocols.customization' + CONFIG_FENCE_KDUMP_LISTENER_CUSTOMIZATION = \ + 'setup.config.fence-kdump-listener.customization' CONFIG_WEBSOCKET_PROXY_CUSTOMIZATION = \ 'setup.config.websocket-proxy.customization' CONFIG_DB_ENCRYPTION_AVAILABLE = 'osetup.config.encryption.available' @@ -581,6 +596,7 @@ USER_ADMIN = 'admin' DOMAIN_INTERNAL = 'internal' ENGINE_SERVICE_NAME = 'ovirt-engine' + FENCE_KDUMP_LISTENER_SERVICE_NAME = 'ovirt-fence-kdump-listener' WEBSOCKET_PROXY_SERVICE_NAME = 'ovirt-websocket-proxy' PKI_PASSWORD = 'mypass' MINIMUM_SPACE_ISODOMAIN_MB = 350 @@ -860,6 +876,8 @@ JBOSS_AJP_PORT = 'OVESETUP_CONFIG/jbossAjpPort' JBOSS_DIRECT_HTTP_PORT = 'OVESETUP_CONFIG/jbossDirectHttpPort' JBOSS_DIRECT_HTTPS_PORT = 'OVESETUP_CONFIG/jbossDirectHttpsPort' + FENCE_KDUMP_LISTENER_HOST = 'OVESETUP_CONFIG/fenceKdumpListenerHost' + FENCE_KDUMP_LISTENER_PORT = 'OVESETUP_CONFIG/fenceKdumpListenerPort' WEBSOCKET_PROXY_PORT = 'OVESETUP_CONFIG/websocketProxyPort' JBOSS_DEBUG_ADDRESS = 'OVESETUP_CONFIG/jbossDebugAddress' ADD_OVIRT_GLANCE_REPOSITORY = 'OVESETUP_CONFIG/addOvirtGlanceRepository' @@ -967,6 +985,15 @@ @osetupattrs( answerfile=True, summary=True, + description=_('Configure fence_kdump listener'), + postinstallfile=True, + ) + def FENCE_KDUMP_LISTENER_CONFIG(self): + return 'OVESETUP_CONFIG/fenceKdumpListenerConfig' + + @osetupattrs( + answerfile=True, + summary=True, description=_('Configure WebSocket Proxy'), postinstallfile=True, ) diff --git a/packaging/setup/plugins/ovirt-engine-common/fence_kdump_listener/__init__.py b/packaging/setup/plugins/ovirt-engine-common/fence_kdump_listener/__init__.py new file mode 100644 index 0000000..f8f3e82 --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-common/fence_kdump_listener/__init__.py @@ -0,0 +1,33 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2014 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-remove fence_kdump listener plugin.""" + + +from otopi import util + + +from . import core + + +@util.export +def createPlugins(context): + core.Plugin(context=context) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-common/fence_kdump_listener/core.py b/packaging/setup/plugins/ovirt-engine-common/fence_kdump_listener/core.py new file mode 100644 index 0000000..269dc2f --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-common/fence_kdump_listener/core.py @@ -0,0 +1,57 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2014 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. +# + + +"""fence_kdump listener plugin.""" + + +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup') + + +from otopi import util +from otopi import plugin + + +from ovirt_engine_setup import constants as osetupcons + + +@util.export +class Plugin(plugin.PluginBase): + """fence_kdump listener plugin.""" + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + + @plugin.event( + stage=plugin.Stages.STAGE_TRANSACTION_BEGIN, + condition=lambda self: not self.environment[ + osetupcons.CoreEnv.DEVELOPER_MODE + ], + ) + def _transactionBegin(self): + if self.services.exists( + name=osetupcons.Const.FENCE_KDUMP_LISTENER_SERVICE_NAME, + ): + self.logger.info(_('Stopping ovirt-fence-kdump-listener service')) + self.services.state( + name=osetupcons.Const.FENCE_KDUMP_LISTENER_SERVICE_NAME, + state=False + ) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-remove/fence_kdump_listener/__init__.py b/packaging/setup/plugins/ovirt-engine-remove/fence_kdump_listener/__init__.py new file mode 100644 index 0000000..4f8ee4c --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-remove/fence_kdump_listener/__init__.py @@ -0,0 +1,33 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2014 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-remove fence_kdump listener plugin.""" + + +from otopi import util + + +from . import misc + + +@util.export +def createPlugins(context): + misc.Plugin(context=context) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-remove/fence_kdump_listener/misc.py b/packaging/setup/plugins/ovirt-engine-remove/fence_kdump_listener/misc.py new file mode 100644 index 0000000..8e24c00 --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-remove/fence_kdump_listener/misc.py @@ -0,0 +1,50 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2014 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. +# + + +"""fence_kdump listener plugin.""" + + +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup') + + +from otopi import util +from otopi import plugin + + +from ovirt_engine_setup import constants as osetupcons + + +@util.export +class Plugin(plugin.PluginBase): + """fence_kdump listener plugin.""" + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + condition=lambda self: not self.environment[ + osetupcons.CoreEnv.DEVELOPER_MODE + ], + ) + def _misc(self): + self.services.startup( + name=osetupcons.Const.FENCE_KDUMP_LISTENER_SERVICE_NAME, + state=False, + ) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-setup/fence_kdump_listener/__init__.py b/packaging/setup/plugins/ovirt-engine-setup/fence_kdump_listener/__init__.py new file mode 100644 index 0000000..53aa4f7 --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-setup/fence_kdump_listener/__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 websocket_proxy plugin.""" + + +from otopi import util + + +from . import config + + +@util.export +def createPlugins(context): + config.Plugin(context=context) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-setup/fence_kdump_listener/config.py b/packaging/setup/plugins/ovirt-engine-setup/fence_kdump_listener/config.py new file mode 100644 index 0000000..0d7d3d6 --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-setup/fence_kdump_listener/config.py @@ -0,0 +1,204 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2014 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. +# + + +"""fence_kdump listener plugin.""" + + +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup') + + +from otopi import util +from otopi import plugin + + +from ovirt_engine_setup import constants as osetupcons + + +@util.export +class Plugin(plugin.PluginBase): + """fence_kdump listener plugin.""" + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + self._needStart = False + self._enabled = True + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_CONFIG, + None + ) + self.environment.setdefault( + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_HOST, + osetupcons.Defaults.DEFAULT_FENCE_KDUMP_LISTENER_HOST + ) + self.environment.setdefault( + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_PORT, + osetupcons.Defaults.DEFAULT_FENCE_KDUMP_LISTENER_PORT + ) + + @plugin.event( + stage=plugin.Stages.STAGE_LATE_SETUP, + condition=lambda self: not self.environment[ + osetupcons.CoreEnv.DEVELOPER_MODE + ], + ) + def _late_setup_service_state(self): + self._needStart = self.services.status( + name='ovirt-fence-kdump-listener', + ) + + @plugin.event( + stage=plugin.Stages.STAGE_CUSTOMIZATION, + name=osetupcons.Stages.CONFIG_FENCE_KDUMP_LISTENER_CUSTOMIZATION, + condition=lambda self: self._enabled, + before=( + osetupcons.Stages.DIALOG_TITLES_E_SYSTEM, + ), + after=( + osetupcons.Stages.DB_CONNECTION_STATUS, + osetupcons.Stages.DIALOG_TITLES_S_SYSTEM, + ), + ) + def _customization(self): + + if self.environment[ + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_CONFIG + ] is None: + self.environment[ + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_HOST + ] = self.dialog.queryString( + name='OVESETUP_CONFIG_FENCE_KDUMP_LISTENER_HOST', + note=_( + 'Which IP address should fence_kdump listener listen on? ' + '[@DEFAULT@]: ' + ), + prompt=True, + default='0.0.0.0', + ) + self.environment[ + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_PORT + ] = self.dialog.queryString( + name='OVESETUP_CONFIG_FENCE_KDUMP_LISTENER_PORT', + note=_( + 'Which port number should fence_kdump listener listen on? ' + '[@DEFAULT@]: ' + ), + prompt=True, + default='7410', + ) + self.environment[ + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_CONFIG + ] = True + + @plugin.event( + stage=plugin.Stages.STAGE_CUSTOMIZATION, + condition=lambda self: self.environment[ + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_CONFIG + ], + before=( + osetupcons.Stages.DIALOG_TITLES_E_SYSTEM, + ), + after=( + osetupcons.Stages.DB_CONNECTION_STATUS, + osetupcons.Stages.DIALOG_TITLES_S_SYSTEM, + osetupcons.Stages.CONFIG_FENCE_KDUMP_LISTENER_CUSTOMIZATION, + ), + ) + def _customization_firewall(self): + self.environment[osetupcons.NetEnv.FIREWALLD_SERVICES].extend([ + { + 'name': 'ovirt-fence-kdump-listener', + 'directory': 'fence-kdump-listener' + }, + ]) + self.environment[ + osetupcons.NetEnv.FIREWALLD_SUBST + ].update({ + '@FENCE_KDUMP_LISTENER_HOST@': self.environment[ + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_HOST + ], + }) + self.environment[ + osetupcons.NetEnv.FIREWALLD_SUBST + ].update({ + '@FENCE_KDUMP_LISTENER_PORT@': self.environment[ + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_PORT + ], + }) + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + condition=lambda self: self._enabled, + after=( + osetupcons.Stages.DB_CONNECTION_AVAILABLE, + ), + ) + def _misc(self): + + self.logger.info(_('Configuring fence_kdump listener')) + + self.environment[osetupcons.DBEnv.STATEMENT].updateVdcOptions( + options=( + { + 'name': 'FenceKdumpListenerHost', + 'value': self.environment[ + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_HOST + ], + }, + ), + ) + self.environment[osetupcons.DBEnv.STATEMENT].updateVdcOptions( + options=( + { + 'name': 'FenceKdumpListenerPort', + 'value': self.environment[ + osetupcons.ConfigEnv.FENCE_KDUMP_LISTENER_PORT + ], + }, + ), + ) + + @plugin.event( + stage=plugin.Stages.STAGE_CLOSEUP, + condition=lambda self: ( + not self.environment[ + osetupcons.CoreEnv.DEVELOPER_MODE + ] and ( + self._needStart or + self._enabled + ) + ), + ) + def _closeup(self): + for state in (False, True): + self.services.state( + name=osetupcons.Const.FENCE_KDUMP_LISTENER_SERVICE_NAME, + state=state, + ) + self.services.startup( + name=osetupcons.Const.FENCE_KDUMP_LISTENER_SERVICE_NAME, + state=True, + ) + + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/27486 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I052cc2296c479caf58d0930a8e678298dde63517 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Peřina <mper...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches