JCLOUDS-105 - fixing a problem caused in cases where vm.isPasswordEnabled() is false and no keypair is specified.

This commit is contained in:
Andrew Bayer 2013-06-23 16:08:05 -07:00
parent 46f25bc913
commit 95308de808
1 changed files with 2 additions and 2 deletions

View File

@ -222,10 +222,10 @@ public class CloudStackComputeServiceAdapter implements
VirtualMachine vm = blockUntilJobCompletesAndReturnResult.<VirtualMachine>apply(job); VirtualMachine vm = blockUntilJobCompletesAndReturnResult.<VirtualMachine>apply(job);
logger.debug("--- virtualmachine: %s", vm); logger.debug("--- virtualmachine: %s", vm);
LoginCredentials.Builder credentialsBuilder = LoginCredentials.builder(); LoginCredentials.Builder credentialsBuilder = LoginCredentials.builder();
if (!vm.isPasswordEnabled() || templateOptions.getKeyPair() != null) { if (templateOptions.getKeyPair() != null) {
SshKeyPair keyPair = keyPairCache.getUnchecked(templateOptions.getKeyPair()); SshKeyPair keyPair = keyPairCache.getUnchecked(templateOptions.getKeyPair());
credentialsBuilder.privateKey(keyPair.getPrivateKey()); credentialsBuilder.privateKey(keyPair.getPrivateKey());
} else { } else if (vm.isPasswordEnabled()) {
assert vm.getPassword() != null : vm; assert vm.getPassword() != null : vm;
credentialsBuilder.password(vm.getPassword()); credentialsBuilder.password(vm.getPassword());
} }