Sandro Bonazzola has uploaded a new change for review. Change subject: packaging: setup: support non-standard SSH port ......................................................................
packaging: setup: support non-standard SSH port Automatically detect the port used by SSH daemon supporting non-standard SSH port. The detected port can be manually overridden setting OVEHOSTED_NETWORK/sshdPort. Change-Id: Ic3b1264290d7e98d1d84ac2546a078f8941ecf47 Related-To: http://gerrit.ovirt.org/18174 Signed-off-by: Sandro Bonazzola <[email protected]> --- M src/ovirt_hosted_engine_setup/constants.py M src/plugins/ovirt-hosted-engine-setup/engine/add_host.py M src/plugins/ovirt-hosted-engine-setup/system/sshd.py 3 files changed, 40 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/19/18219/1 diff --git a/src/ovirt_hosted_engine_setup/constants.py b/src/ovirt_hosted_engine_setup/constants.py index 8a775ec..c0f70f2 100644 --- a/src/ovirt_hosted_engine_setup/constants.py +++ b/src/ovirt_hosted_engine_setup/constants.py @@ -240,6 +240,13 @@ FIREWALLD_SERVICES = 'OVEHOSTED_NETWORK/firewalldServices' FIREWALLD_SUBST = 'OVEHOSTED_NETWORK/firewalldSubst' + @ohostedattrs( + summary=True, + description=_('SSH daemon port'), + ) + def SSHD_PORT(self): + return 'OVEHOSTED_NETWORK/sshdPort' + @util.export @util.codegen diff --git a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py index 40f2761..019cad5 100644 --- a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py +++ b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py @@ -340,6 +340,9 @@ cluster=engine_api.clusters.get('Default'), ssh=self._ovirtsdk_xml.params.SSH( authentication_method='publickey', + port=self.environment[ + ohostedcons.NetworkEnv.SSHD_PORT + ], ), ) ) diff --git a/src/plugins/ovirt-hosted-engine-setup/system/sshd.py b/src/plugins/ovirt-hosted-engine-setup/system/sshd.py index 01613fe..cd96852 100644 --- a/src/plugins/ovirt-hosted-engine-setup/system/sshd.py +++ b/src/plugins/ovirt-hosted-engine-setup/system/sshd.py @@ -46,6 +46,21 @@ super(Plugin, self).__init__(context=context) @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + ohostedcons.NetworkEnv.SSHD_PORT, + None + ) + + @plugin.event( + stage=plugin.Stages.STAGE_SETUP, + ) + def _setup(self): + self.command.detect('sshd') + + @plugin.event( stage=plugin.Stages.STAGE_CUSTOMIZATION, priority=plugin.Stages.PRIORITY_HIGH, after=( @@ -58,6 +73,21 @@ def _customization(self): if not self.services.exists(name='sshd'): raise RuntimeError(_('sshd service is required')) + if self.environment[ohostedcons.NetworkEnv.SSHD_PORT] is None: + rc, stdout, _stderr = self.execute( + args=( + self.command.get('sshd'), + '-T', + ), + ) + if rc == 0: + for line in stdout: + words = line.split() + if words[0] == 'port': + self.environment[ + ohostedcons.NetworkEnv.SSHD_PORT + ] = int(words[1]) + break @plugin.event( stage=plugin.Stages.STAGE_MISC, -- To view, visit http://gerrit.ovirt.org/18219 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic3b1264290d7e98d1d84ac2546a078f8941ecf47 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
