Yaniv Bronhaim has uploaded a new change for review. Change subject: Adding initialize function in vdsDeploy ......................................................................
Adding initialize function in vdsDeploy Currently the creation of the client is part of vdsDeploy.execute. We want to allow setting defaultKeyPair before executing the deploy code. This patch separates the initialization of SSHDialog and the execution. Change-Id: I02edaee6bc6e804bb36d3ab4dabaa21faa926fa0 Signed-off-by: Yaniv Bronhaim <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ssh/EngineSSHDialog.java 3 files changed, 25 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/84/16184/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java index 7e19fcf..b5eb2f9 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java @@ -167,6 +167,7 @@ ); } installer.setUser("root"); + installer.initConnection(); installer.useDefaultKeyPair(); break; default: diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java index f5a646e..b96bfa1 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java @@ -832,22 +832,28 @@ } /** + * Establish connection to host + */ + public void initConnection() throws Exception { + _dialog.setHost(_vds.getHostName()); + _dialog.connect(); + _messages.post( + InstallerMessages.Severity.INFO, + String.format( + "Connected to host %1$s with SSH key fingerprint: %2$s", + _vds.getHostName(), + _dialog.getHostFingerprint() + ) + ); + } + + /** * Main method. * Execute the command and initiate the dialog. */ public void execute() throws Exception { InputStream in = null; try { - _dialog.setHost(_vds.getHostName()); - _dialog.connect(); - _messages.post( - InstallerMessages.Severity.INFO, - String.format( - "Connected to host %1$s with SSH key fingerprint: %2$s", - _vds.getHostName(), - _dialog.getHostFingerprint() - ) - ); _dialog.authenticate(); String command = Config.<String> GetValue(ConfigValues.BootstrapCommand); diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ssh/EngineSSHDialog.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ssh/EngineSSHDialog.java index c79f516..036b177 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ssh/EngineSSHDialog.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ssh/EngineSSHDialog.java @@ -22,6 +22,10 @@ * @return fingerprint. */ public String getHostFingerprint() throws IOException { + if (_client == null) { + throw new IOException("failed to get host fingerprint. " + + "SSH connection was not initialized"); + } return ((EngineSSHClient)_client).getHostFingerprint(); } @@ -29,6 +33,10 @@ * Use default engine ssh key. */ public void useDefaultKeyPair() throws KeyStoreException { + if (_client == null) { + throw new KeyStoreException( + "failed to use defaultKeyPair. SSH connection was not initialized"); + } ((EngineSSHClient)_client).useDefaultKeyPair(); } } -- To view, visit http://gerrit.ovirt.org/16184 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I02edaee6bc6e804bb36d3ab4dabaa21faa926fa0 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
