From b8cb9cd35b75153161713e55f7b0765973dab98e Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Tue, 7 Apr 2015 22:54:14 +0200 Subject: [PATCH] Properly clone the login credentials --- .../compute/options/TemplateOptions.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java b/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java index 4770f65402..450969fb4a 100644 --- a/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java +++ b/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java @@ -86,14 +86,17 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable { to.blockUntilRunning(false); if (!this.shouldBlockOnComplete()) to.blockOnComplete(false); - if (this.getLoginUser() != null) - to.overrideLoginUser(this.getLoginUser()); - if (this.getLoginPassword() != null) - to.overrideLoginPassword(this.getLoginPassword()); - if (this.getLoginPrivateKey() != null) - to.overrideLoginPrivateKey(this.getLoginPrivateKey()); - if (this.shouldAuthenticateSudo() != null) - to.overrideAuthenticateSudo(this.shouldAuthenticateSudo()); + + LoginCredentials fromCreds = new LoginCredentials.Builder(). + user(this.getLoginUser()). + password(this.hasLoginPassword() ? this.getLoginPassword() : null). + privateKey(this.hasLoginPrivateKeyOption() ? this.getLoginPrivateKey() : null). + authenticateSudo(authenticateSudo == null ? false : authenticateSudo). + build(); + if (fromCreds != null) { + to.overrideLoginCredentials(fromCreds); + } + if (this.getTaskName() != null) to.nameTask(this.getTaskName()); if (!this.getNetworks().isEmpty())