Skip to content

Commit 07e4deb

Browse files
committed
Merge release branch 4.17 to main
* 4.17: api: fix new password is applied on host when update host password with update_passwd_on_host=false (#7092) CKS: remove details when delete a cks cluster (#7104) api/server: add project id/name in ssh keypair response (#7100)
2 parents 911f951 + 536a387 commit 07e4deb

6 files changed

Lines changed: 48 additions & 6 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/admin/host/UpdateHostPasswordCmd.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.cloudstack.api.response.ClusterResponse;
2424
import org.apache.cloudstack.api.response.HostResponse;
2525
import org.apache.cloudstack.api.response.SuccessResponse;
26+
import org.apache.commons.lang3.BooleanUtils;
2627
import org.apache.log4j.Logger;
2728

2829
import com.cloud.user.Account;
@@ -66,7 +67,7 @@ public Long getClusterId() {
6667
}
6768

6869
public Boolean getUpdatePasswdOnHost() {
69-
return updatePasswdOnHost == null ? false : true;
70+
return BooleanUtils.isTrue(updatePasswdOnHost);
7071
}
7172

7273
public String getPassword() {

api/src/main/java/org/apache/cloudstack/api/response/SSHKeyPairResponse.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public class SSHKeyPairResponse extends BaseResponseWithAnnotations {
4646
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the keypair owner")
4747
private String domain;
4848

49+
@SerializedName(ApiConstants.PROJECT_ID)
50+
@Param(description = "the project id of the keypair owner")
51+
private String projectId;
52+
53+
@SerializedName(ApiConstants.PROJECT)
54+
@Param(description = "the project name of the keypair owner")
55+
private String projectName;
56+
4957
@SerializedName("fingerprint")
5058
@Param(description = "Fingerprint of the public key")
5159
private String fingerprint;
@@ -106,4 +114,12 @@ public String getId() {
106114
public void setId(String id) {
107115
this.id = id;
108116
}
117+
118+
public void setProjectId(String projectId) {
119+
this.projectId = projectId;
120+
}
121+
122+
public void setProjectName(String projectName) {
123+
this.projectName = projectName;
124+
}
109125
}

api/src/test/java/org/apache/cloudstack/api/command/test/UpdateHostPasswordCmdTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.junit.Before;
2828
import org.junit.Test;
2929
import org.mockito.Mockito;
30+
import org.springframework.test.util.ReflectionTestUtils;
3031

3132
import com.cloud.exception.InvalidParameterValueException;
3233
import com.cloud.resource.ResourceService;
@@ -94,4 +95,15 @@ public void testCreateSuccess() {
9495
assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost());
9596
verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd);
9697
}
97-
}
98+
99+
@Test
100+
public void testGetUpdatePasswdOnHostValues() {
101+
assertFalse(updateHostPasswordCmd.getUpdatePasswdOnHost());
102+
103+
ReflectionTestUtils.setField(updateHostPasswordCmd, "updatePasswdOnHost", false);
104+
assertFalse(updateHostPasswordCmd.getUpdatePasswdOnHost());
105+
106+
ReflectionTestUtils.setField(updateHostPasswordCmd, "updatePasswdOnHost", true);
107+
assertTrue(updateHostPasswordCmd.getUpdatePasswdOnHost());
108+
}
109+
}

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterDestroyWorker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public boolean destroy() throws CloudRuntimeException {
267267
}
268268
stateTransitTo(kubernetesCluster.getId(), KubernetesCluster.Event.OperationSucceeded);
269269
annotationDao.removeByEntityType(AnnotationService.EntityType.KUBERNETES_CLUSTER.name(), kubernetesCluster.getUuid());
270+
kubernetesClusterDetailsDao.removeDetails(kubernetesCluster.getId());
270271
boolean deleted = kubernetesClusterDao.remove(kubernetesCluster.getId());
271272
if (!deleted) {
272273
logMessage(Level.WARN, String.format("Failed to delete Kubernetes cluster : %s", kubernetesCluster.getName()), null);

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4612,7 +4612,13 @@ public SSHKeyPairResponse createSSHKeyPairResponse(SSHKeyPair sshkeyPair, boolea
46124612
sshkeyPair.getFingerprint(), sshkeyPair.getPrivateKey());
46134613
}
46144614
Account account = ApiDBUtils.findAccountById(sshkeyPair.getAccountId());
4615-
response.setAccountName(account.getAccountName());
4615+
if (account.getType() == Account.Type.PROJECT) {
4616+
Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getAccountId());
4617+
response.setProjectId(project.getUuid());
4618+
response.setProjectName(project.getName());
4619+
} else {
4620+
response.setAccountName(account.getAccountName());
4621+
}
46164622
Domain domain = ApiDBUtils.findDomainById(sshkeyPair.getDomainId());
46174623
response.setDomainId(domain.getUuid());
46184624
response.setDomainName(domain.getName());

ui/src/config/section/compute.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ export default {
702702
return fields
703703
},
704704
resourceType: 'SSHKeyPair',
705-
details: ['id', 'name', 'fingerprint', 'account', 'domain'],
705+
details: ['id', 'name', 'fingerprint', 'account', 'domain', 'project'],
706706
related: [{
707707
name: 'vm',
708708
title: 'label.instances',
@@ -734,11 +734,14 @@ export default {
734734
label: 'label.remove.ssh.key.pair',
735735
message: 'message.please.confirm.remove.ssh.key.pair',
736736
dataView: true,
737-
args: ['name', 'account', 'domainid'],
737+
args: ['name', 'account', 'domainid', 'projectid'],
738738
mapping: {
739739
name: {
740740
value: (record, params) => { return record.name }
741741
},
742+
projectid: {
743+
value: (record, params) => { return record.projectid }
744+
},
742745
account: {
743746
value: (record, params) => { return record.account }
744747
},
@@ -752,7 +755,10 @@ export default {
752755
return selection.map(x => {
753756
const data = record.filter(y => { return y.id === x })
754757
return {
755-
name: data[0].name, account: data[0].account, domainid: data[0].domainid
758+
name: data[0].name,
759+
account: data[0].account,
760+
domainid: data[0].domainid,
761+
projectid: data[0].projectid
756762
}
757763
})
758764
}

0 commit comments

Comments
 (0)