Sandro Bonazzola has uploaded a new change for review. Change subject: packaging: setup: added gateway configuration ......................................................................
packaging: setup: added gateway configuration added gateway configuration for allowing HA check for network connectivity. Change-Id: I0dcc0cef9241312411ed1a67b1accc60031a07d4 Signed-off-by: Sandro Bonazzola <[email protected]> --- M src/ovirt_hosted_engine_setup/constants.py M src/plugins/ovirt-hosted-engine-setup/core/conf.py M src/plugins/ovirt-hosted-engine-setup/network/Makefile.am M src/plugins/ovirt-hosted-engine-setup/network/__init__.py A src/plugins/ovirt-hosted-engine-setup/network/gateway.py M templates/hosted-engine.conf.in 6 files changed, 125 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/05/17305/1 diff --git a/src/ovirt_hosted_engine_setup/constants.py b/src/ovirt_hosted_engine_setup/constants.py index 1b3d635..39d560e 100644 --- a/src/ovirt_hosted_engine_setup/constants.py +++ b/src/ovirt_hosted_engine_setup/constants.py @@ -194,6 +194,12 @@ def FIREWALL_MANAGER(self): return 'OVEHOSTED_NETWORK/firewallManager' + @ohostedattrs( + answerfile=True, + ) + def GATEWAY(self): + return 'OVEHOSTED_NETWORK/gateway' + FIREWALLD_SERVICES = 'OVEHOSTED_NETWORK/firewalldServices' FIREWALLD_SUBST = 'OVEHOSTED_NETWORK/firewalldSubst' diff --git a/src/plugins/ovirt-hosted-engine-setup/core/conf.py b/src/plugins/ovirt-hosted-engine-setup/core/conf.py index 9a4741d..bfdefb7 100644 --- a/src/plugins/ovirt-hosted-engine-setup/core/conf.py +++ b/src/plugins/ovirt-hosted-engine-setup/core/conf.py @@ -92,6 +92,7 @@ '@VDSM_USE_SSL@': str( self.environment[ohostedcons.VDSMEnv.USE_SSL] ).lower(), + '@GATEWAY@': self.environment[ohostedcons.NetworkEnv.GATEWAY], } ) with transaction.Transaction() as localtransaction: diff --git a/src/plugins/ovirt-hosted-engine-setup/network/Makefile.am b/src/plugins/ovirt-hosted-engine-setup/network/Makefile.am index bab0737..1d33ec4 100644 --- a/src/plugins/ovirt-hosted-engine-setup/network/Makefile.am +++ b/src/plugins/ovirt-hosted-engine-setup/network/Makefile.am @@ -29,6 +29,7 @@ bridge.py \ firewall_manager.py \ firewall.py \ + gateway.py \ $(NULL) clean-local: \ diff --git a/src/plugins/ovirt-hosted-engine-setup/network/__init__.py b/src/plugins/ovirt-hosted-engine-setup/network/__init__.py index d622da3..6ad9d9a 100644 --- a/src/plugins/ovirt-hosted-engine-setup/network/__init__.py +++ b/src/plugins/ovirt-hosted-engine-setup/network/__init__.py @@ -27,6 +27,7 @@ from . import bridge from . import firewall from . import firewall_manager +from . import gateway @util.export @@ -34,6 +35,7 @@ bridge.Plugin(context=context) firewall.Plugin(context=context) firewall_manager.Plugin(context=context) + gateway.Plugin(context=context) # vim: expandtab tabstop=4 shiftwidth=4 diff --git a/src/plugins/ovirt-hosted-engine-setup/network/gateway.py b/src/plugins/ovirt-hosted-engine-setup/network/gateway.py new file mode 100644 index 0000000..c2088dc --- /dev/null +++ b/src/plugins/ovirt-hosted-engine-setup/network/gateway.py @@ -0,0 +1,114 @@ +# +# ovirt-hosted-engine-setup -- ovirt hosted engine setup +# Copyright (C) 2013 Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + + +""" +gateway configuration plugin. +""" + + +import gettext + + +from otopi import util +from otopi import plugin + + +from ovirt_hosted_engine_setup import constants as ohostedcons + + +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-hosted-engine-setup') + + [email protected] +class Plugin(plugin.PluginBase): + """ + gateway configuration plugin. + """ + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + self._enabled = True + + def _check_gw_pingable(self, address): + try: + self.execute( + ( + self.command.get('ping'), + '-c', + '1', + address, + ), + raiseOnError=True + ) + pingable = True + except RuntimeError: + pingable = False + return pingable + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + ohostedcons.NetworkEnv.GATEWAY, + None + ) + + @plugin.event( + stage=plugin.Stages.STAGE_SETUP, + ) + def _setup(self): + self.command.detect('ping') + + @plugin.event( + stage=plugin.Stages.STAGE_CUSTOMIZATION, + ) + def _customization(self): + + interactive = self.environment[ + ohostedcons.NetworkEnv.GATEWAY + ] is None + valid = False + while not valid: + if interactive: + self.environment[ + ohostedcons.NetworkEnv.GATEWAY + ] = self.dialog.queryString( + name='OVEHOSTED_GATEWAY', + note=_( + 'Please indicate a pingable gateway IP address :' + ), + prompt=True, + caseSensitive=True, + ) + valid = self._check_gw_pingable( + self.environment[ + ohostedcons.NetworkEnv.GATEWAY + ] + ) + if not valid: + if not interactive: + raise RuntimeError(_('Specified gateway is not pingable')) + else: + self.logger.error(_('Specified gateway is not pingable')) + + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/templates/hosted-engine.conf.in b/templates/hosted-engine.conf.in index b1db8c6..854786b 100644 --- a/templates/hosted-engine.conf.in +++ b/templates/hosted-engine.conf.in @@ -13,3 +13,4 @@ ca_cert=@CA_CERT@ ca_subject="@CA_SUBJECT@" vdsm_use_ssl=@VDSM_USE_SSL@ +gateway=@GATEWAY@ -- To view, visit http://gerrit.ovirt.org/17305 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0dcc0cef9241312411ed1a67b1accc60031a07d4 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-setup Gerrit-Branch: master Gerrit-Owner: Sandro Bonazzola <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
