Skip to content

Commit

Permalink
BugFix: Login used root user, even if use preexisting jenkins was ena…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
felfert committed Feb 6, 2015
1 parent 19b048d commit 878f19c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,17 @@ public NodeMetadata get() {
options.as(CloudStackTemplateOptions.class).setupStaticNat(assignPublicIp);
}

String adminUser = vmUser;
if (this.preExistingJenkinsUser && Strings.isNullOrEmpty(adminUser)) {
adminUser = getJenkinsUser();
}
if (!Strings.isNullOrEmpty(vmPassword)) {
LoginCredentials lc = LoginCredentials.builder().user(vmUser).password(vmPassword).build();
LoginCredentials lc = LoginCredentials.builder().user(adminUser).password(vmPassword).build();
options.overrideLoginCredentials(lc);
} else if (!Strings.isNullOrEmpty(getCloud().privateKey) && !Strings.isNullOrEmpty(vmUser)) {
} else if (!Strings.isNullOrEmpty(getCloud().privateKey) && !Strings.isNullOrEmpty(adminUser)) {
// Skip overriding the credentials if we don't have a VM admin user specified - there are cases where we want the private
// key but we don't to use it for the admin user creds.
LoginCredentials lc = LoginCredentials.builder().user(vmUser).privateKey(getCloud().privateKey).build();
LoginCredentials lc = LoginCredentials.builder().user(adminUser).privateKey(getCloud().privateKey).build();
options.overrideLoginCredentials(lc);
}

Expand Down

0 comments on commit 878f19c

Please sign in to comment.